Allow split w & h
This commit is contained in:
parent
6cde8075b4
commit
d11bf80aac
1 changed files with 8 additions and 6 deletions
|
|
@ -9,7 +9,8 @@ namespace gay.lilyy.TextureAtlasGenerator
|
|||
public class TextureAtlasSettings : ScriptableObject
|
||||
{
|
||||
public Texture2D[] textures;
|
||||
public int atlasSize = 1024;
|
||||
public int atlasWidth = 1024;
|
||||
public int atlasHeight = 1024;
|
||||
public int columns = 4;
|
||||
public int rows = 4;
|
||||
public string savePath = "Assets/Atlas.png";
|
||||
|
|
@ -34,7 +35,8 @@ namespace gay.lilyy.TextureAtlasGenerator
|
|||
serializedObject.Update();
|
||||
|
||||
EditorGUILayout.LabelField("Texture Atlas Settings", EditorStyles.boldLabel);
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("atlasSize"));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("atlasWidth"));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("atlasHeight"));
|
||||
EditorGUILayout.PropertyField(columnsProp);
|
||||
EditorGUILayout.PropertyField(rowsProp);
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("savePath"));
|
||||
|
|
@ -88,13 +90,13 @@ namespace gay.lilyy.TextureAtlasGenerator
|
|||
return;
|
||||
}
|
||||
|
||||
Texture2D atlas = new Texture2D(settings.atlasSize, settings.atlasSize);
|
||||
Color[] blackPixels = new Color[settings.atlasSize * settings.atlasSize];
|
||||
Texture2D atlas = new Texture2D(settings.atlasWidth, settings.atlasHeight);
|
||||
Color[] blackPixels = new Color[settings.atlasWidth * settings.atlasHeight];
|
||||
for (int i = 0; i < blackPixels.Length; i++) blackPixels[i] = Color.black;
|
||||
atlas.SetPixels(blackPixels);
|
||||
|
||||
int cellWidth = settings.atlasSize / settings.columns;
|
||||
int cellHeight = settings.atlasSize / settings.rows;
|
||||
int cellWidth = settings.atlasWidth / settings.columns;
|
||||
int cellHeight = settings.atlasHeight / settings.rows;
|
||||
|
||||
for (int i = 0; i < settings.textures.Length; i++)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue