5 Commits
1.0 ... 1.2

Author SHA1 Message Date
max
78e4fb0ad1 #if UNITY_EDITOR
Added '#if UNITY_EDITOR' to all the scripts that should only run/be used in the editor.
2019-05-04 13:29:02 +02:00
max
7990f987dc Settings, Hotkey bugfix.
null errors.
2019-03-31 18:45:16 +02:00
max
82efcbb6d0 Duplicate Quad, Settings, Hotkeys.
Added the option to duplicate the selected quad.
Added settings for focus, duplication, hotkeys.
Added hotkeys, can be enabled in the settings file.
2019-03-31 18:09:53 +02:00
7f5e22b3c1 Update README.md 2018-09-01 00:40:20 +02:00
c91c1cb7ee Update LICENSE 2018-08-27 12:07:30 +02:00
23 changed files with 196 additions and 30 deletions

View File

@ -1,6 +1,6 @@
MIT License MIT License
Copyright (c) 2018 Max Copyright (c) 2018 Max Kruf
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

@ -1,3 +1,4 @@
#if UNITY_EDITOR
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
@ -100,4 +101,5 @@ namespace MA_TextureAtlasserPro
} }
} }
} }
} }
#endif

View File

@ -1,3 +1,4 @@
#if UNITY_EDITOR
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
@ -163,4 +164,5 @@ namespace MA_TextureAtlasserPro
debugMode = isDebugging; debugMode = isDebugging;
} }
} }
} }
#endif

View File

@ -0,0 +1,27 @@
#if UNITY_EDITOR
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using MA_Editor;
namespace MA_TextureAtlasserPro
{
[System.Serializable]
public class MA_TextureAtlasserProSettings : ScriptableObject
{
[Header("Selection")]
public bool autoFocus = true;
[Header("Duplication:")]
public bool copySelectedQuadData = false;
public string duplicatedQuadNamePrefix = "new ";
[Header("Hotkeys:")]
public bool useHotkeys = false;
public KeyCode addQuadHotKey = KeyCode.Q;
public KeyCode removeQuadHotKey = KeyCode.R;
public KeyCode duplicateHotKey = KeyCode.D;
}
}
#endif

View File

@ -1,4 +1,5 @@
using System.Collections; #if UNITY_EDITOR
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
@ -17,3 +18,4 @@ namespace MA_TextureAtlasserPro
public string name; public string name;
} }
} }
#endif

View File

@ -1,3 +1,4 @@
#if UNITY_EDITOR
using UnityEngine; using UnityEngine;
using UnityEditor; using UnityEditor;
@ -12,6 +13,7 @@ namespace MA_TextureAtlasserPro
public static GUIContent exportAtlasIcon; public static GUIContent exportAtlasIcon;
public static GUIContent createQuadIcon; public static GUIContent createQuadIcon;
public static GUIContent removeQuadIcon; public static GUIContent removeQuadIcon;
public static GUIContent duplicateQuadIcon;
public static GUIContent showTexturesOnIcon; public static GUIContent showTexturesOnIcon;
public static GUIContent showTexturesOffIcon; public static GUIContent showTexturesOffIcon;
public static GUIContent dragHandleIcon; public static GUIContent dragHandleIcon;
@ -24,10 +26,12 @@ namespace MA_TextureAtlasserPro
exportAtlasIcon = new GUIContent("", (Texture)EditorGUIUtility.Load(LOADICONPATH + "exportAtlasIcon" + ".png")); exportAtlasIcon = new GUIContent("", (Texture)EditorGUIUtility.Load(LOADICONPATH + "exportAtlasIcon" + ".png"));
createQuadIcon = new GUIContent("", (Texture)EditorGUIUtility.Load(LOADICONPATH + "createQuadIcon" + ".png")); createQuadIcon = new GUIContent("", (Texture)EditorGUIUtility.Load(LOADICONPATH + "createQuadIcon" + ".png"));
removeQuadIcon = new GUIContent("", (Texture)EditorGUIUtility.Load(LOADICONPATH + "removeQuadIcon" + ".png")); removeQuadIcon = new GUIContent("", (Texture)EditorGUIUtility.Load(LOADICONPATH + "removeQuadIcon" + ".png"));
duplicateQuadIcon = new GUIContent("", (Texture)EditorGUIUtility.Load(LOADICONPATH + "duplicateQuadIcon" + ".png"));
showTexturesOnIcon = new GUIContent("", (Texture)EditorGUIUtility.Load(LOADICONPATH + "showTexturesOnIcon" + ".png")); showTexturesOnIcon = new GUIContent("", (Texture)EditorGUIUtility.Load(LOADICONPATH + "showTexturesOnIcon" + ".png"));
showTexturesOffIcon = new GUIContent("", (Texture)EditorGUIUtility.Load(LOADICONPATH + "showTexturesOffIcon" + ".png")); showTexturesOffIcon = new GUIContent("", (Texture)EditorGUIUtility.Load(LOADICONPATH + "showTexturesOffIcon" + ".png"));
dragHandleIcon = new GUIContent("", (Texture)EditorGUIUtility.Load(LOADICONPATH + "dragHandleIcon" + ".png")); dragHandleIcon = new GUIContent("", (Texture)EditorGUIUtility.Load(LOADICONPATH + "dragHandleIcon" + ".png"));
editIcon = new GUIContent("", (Texture)EditorGUIUtility.Load(LOADICONPATH + "editIcon" + ".png")); editIcon = new GUIContent("", (Texture)EditorGUIUtility.Load(LOADICONPATH + "editIcon" + ".png"));
} }
} }
} }
#endif

View File

@ -1,3 +1,4 @@
#if UNITY_EDITOR
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
@ -9,12 +10,43 @@ namespace MA_TextureAtlasserPro
{ {
public static class MA_TextureAtlasserProUtils public static class MA_TextureAtlasserProUtils
{ {
public const string SETTINGSASSETPATH = "Assets/MA_ToolBox/MA_TextureAtlasserPro/Settings/";
public const string SAVEASSETPATH = "Assets/MA_ToolBox/MA_TextureAtlasserPro/Atlasses/"; public const string SAVEASSETPATH = "Assets/MA_ToolBox/MA_TextureAtlasserPro/Atlasses/";
public const string LOADASSETPATH = "Assets/MA_ToolBox/MA_TextureAtlasserPro/Atlasses/"; public const string LOADASSETPATH = "Assets/MA_ToolBox/MA_TextureAtlasserPro/Atlasses/";
public const string EXPORTASSETPATH = "Assets/MA_ToolBox/MA_TextureAtlasserPro/Exports/"; public const string EXPORTASSETPATH = "Assets/MA_ToolBox/MA_TextureAtlasserPro/Exports/";
public const float VIEWOFFSET = 20; public const float VIEWOFFSET = 20;
public const string DEFAULTTEXTUREGROUPNAME = "Albedo"; public const string DEFAULTTEXTUREGROUPNAME = "Albedo";
public static MA_TextureAtlasserProSettings CreateSettings()
{
MA_TextureAtlasserProSettings _settings = (MA_TextureAtlasserProSettings)ScriptableObject.CreateInstance<MA_TextureAtlasserProSettings>();
if(_settings != null)
{
AssetDatabase.CreateAsset(_settings, SETTINGSASSETPATH + "MA_TextureAtlasserProSettings.asset");
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
return _settings;
}
else
{
return null;
}
}
public static MA_TextureAtlasserProSettings LoadSettings()
{
MA_TextureAtlasserProSettings _settings = AssetDatabase.LoadAssetAtPath(SETTINGSASSETPATH + "MA_TextureAtlasserProSettings.asset", typeof(MA_TextureAtlasserProSettings)) as MA_TextureAtlasserProSettings;
if (_settings == null)
{
_settings = CreateSettings();
}
return _settings;
}
public static MA_TextureAtlasserProAtlas CreateTextureAtlas(string name, Vector2 size) public static MA_TextureAtlasserProAtlas CreateTextureAtlas(string name, Vector2 size)
{ {
MA_TextureAtlasserProAtlas _atlas = (MA_TextureAtlasserProAtlas)ScriptableObject.CreateInstance<MA_TextureAtlasserProAtlas>(); MA_TextureAtlasserProAtlas _atlas = (MA_TextureAtlasserProAtlas)ScriptableObject.CreateInstance<MA_TextureAtlasserProAtlas>();
@ -113,7 +145,7 @@ namespace MA_TextureAtlasserPro
} }
} }
public static void CreateTextureQuad(MA_TextureAtlasserProAtlas atlas, string name, Rect rect) public static void CreateTextureQuad(MA_TextureAtlasserProAtlas atlas, string name, Rect rect, bool focus = true)
{ {
if(atlas != null) if(atlas != null)
{ {
@ -140,6 +172,11 @@ namespace MA_TextureAtlasserPro
AssetDatabase.AddObjectToAsset(_quad, atlas); AssetDatabase.AddObjectToAsset(_quad, atlas);
AssetDatabase.SaveAssets(); AssetDatabase.SaveAssets();
AssetDatabase.Refresh(); AssetDatabase.Refresh();
if(focus)
{
atlas.selectedTextureQuad = atlas.textureQuads[atlas.textureQuads.Count - 1];
}
} }
else else
{ {
@ -152,14 +189,41 @@ namespace MA_TextureAtlasserPro
} }
} }
public static void RemoveTextureQuad(MA_TextureAtlasserProAtlas atlas) public static void RemoveTextureQuad(MA_TextureAtlasserProAtlas atlas, bool focus = true)
{ {
if(atlas != null && atlas.selectedTextureQuad != null) if(atlas != null && atlas.selectedTextureQuad != null)
{ {
atlas.textureQuads.Remove(atlas.selectedTextureQuad); int _index = atlas.textureQuads.IndexOf(atlas.selectedTextureQuad);
atlas.textureQuads.RemoveAt(_index);
GameObject.DestroyImmediate(atlas.selectedTextureQuad, true); GameObject.DestroyImmediate(atlas.selectedTextureQuad, true);
AssetDatabase.SaveAssets(); AssetDatabase.SaveAssets();
AssetDatabase.Refresh(); AssetDatabase.Refresh();
if (focus && atlas.textureQuads.Count > 0)
{
_index = Mathf.Clamp(_index, 0, atlas.textureQuads.Count - 1);
atlas.selectedTextureQuad = atlas.textureQuads[_index];
}
}
}
public static void DuplicateTextureQuad(MA_TextureAtlasserProAtlas atlas, bool focus = true, bool copyData = false, string namePrefix = "new ")
{
if(atlas != null && atlas.selectedTextureQuad != null)
{
CreateTextureQuad(atlas, namePrefix + atlas.selectedTextureQuad.name, atlas.selectedTextureQuad.rect, false);
if(copyData)
{
atlas.textureQuads[atlas.textureQuads.Count - 1].meshes = atlas.selectedTextureQuad.meshes;
atlas.textureQuads[atlas.textureQuads.Count - 1].textureGroups = atlas.selectedTextureQuad.textureGroups;
}
if(focus)
{
atlas.selectedTextureQuad = atlas.textureQuads[atlas.textureQuads.Count - 1];
}
} }
} }
@ -314,4 +378,5 @@ namespace MA_TextureAtlasserPro
} }
} }
} }
} }
#endif

View File

@ -1,3 +1,4 @@
#if UNITY_EDITOR
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
@ -75,4 +76,5 @@ namespace MA_TextureAtlasserPro
} }
} }
} }
} }
#endif

View File

@ -1,3 +1,4 @@
#if UNITY_EDITOR
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
@ -131,4 +132,5 @@ namespace MA_TextureAtlasserPro
base.ProcessEvents(e, editorViewRect); base.ProcessEvents(e, editorViewRect);
} }
} }
} }
#endif

View File

@ -1,3 +1,4 @@
#if UNITY_EDITOR
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
@ -52,12 +53,17 @@ namespace MA_TextureAtlasserPro
GUILayout.Space(MA_TextureAtlasserProUtils.VIEWOFFSET); GUILayout.Space(MA_TextureAtlasserProUtils.VIEWOFFSET);
if(GUILayout.Button(MA_TextureAtlasserProIcons.createQuadIcon, GUILayout.ExpandWidth(false), GUILayout.ExpandHeight(true))) if(GUILayout.Button(MA_TextureAtlasserProIcons.createQuadIcon, GUILayout.ExpandWidth(false), GUILayout.ExpandHeight(true)))
{ {
MA_TextureAtlasserProUtils.CreateTextureQuad(curWindow.textureAtlas, "new Quad", new Rect(0, 0, 128, 128)); MA_TextureAtlasserProUtils.CreateTextureQuad(curWindow.textureAtlas, "new Quad", new Rect(0, 0, 128, 128), curWindow.settings.autoFocus);
} }
if(curWindow.textureAtlas.selectedTextureQuad != null && GUILayout.Button(MA_TextureAtlasserProIcons.removeQuadIcon, GUILayout.ExpandWidth(false), GUILayout.ExpandHeight(true))) if(curWindow.textureAtlas.selectedTextureQuad != null && GUILayout.Button(MA_TextureAtlasserProIcons.removeQuadIcon, GUILayout.ExpandWidth(false), GUILayout.ExpandHeight(true)))
{ {
if(curWindow.textureAtlas.selectedTextureQuad != null) if(curWindow.textureAtlas.selectedTextureQuad != null)
MA_TextureAtlasserProUtils.RemoveTextureQuad(curWindow.textureAtlas); MA_TextureAtlasserProUtils.RemoveTextureQuad(curWindow.textureAtlas, curWindow.settings.autoFocus);
}
if (curWindow.textureAtlas.selectedTextureQuad != null && GUILayout.Button(MA_TextureAtlasserProIcons.duplicateQuadIcon, GUILayout.ExpandWidth(false), GUILayout.ExpandHeight(true)))
{
if (curWindow.textureAtlas.selectedTextureQuad != null)
MA_TextureAtlasserProUtils.DuplicateTextureQuad(curWindow.textureAtlas, curWindow.settings.autoFocus, curWindow.settings.copySelectedQuadData, curWindow.settings.duplicatedQuadNamePrefix);
} }
} }
@ -73,4 +79,5 @@ namespace MA_TextureAtlasserPro
base.ProcessEvents(e, editorViewRect); base.ProcessEvents(e, editorViewRect);
} }
} }
} }
#endif

View File

@ -1,4 +1,5 @@
using System.Collections; #if UNITY_EDITOR
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using UnityEditor; using UnityEditor;
@ -52,4 +53,5 @@ namespace MA_TextureAtlasserPro
} }
} }
} }
} }
#endif

View File

@ -1,4 +1,5 @@
using System.Collections; #if UNITY_EDITOR
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using MA_Editor; using MA_Editor;
@ -89,6 +90,34 @@ namespace MA_TextureAtlasserPro
e.Use(); e.Use();
} }
//Hotkeys.
if (curWindow.settings.useHotkeys)
{
if(curWindow.textureAtlas != null)
{
if (e.type == EventType.KeyDown && e.keyCode == curWindow.settings.addQuadHotKey)
{
MA_TextureAtlasserProUtils.CreateTextureQuad(curWindow.textureAtlas, "new Quad", new Rect(0, 0, 128, 128), curWindow.settings.autoFocus);
e.Use();
}
if (curWindow.textureAtlas.selectedTextureQuad != null)
{
if (e.type == EventType.KeyDown && e.keyCode == curWindow.settings.removeQuadHotKey)
{
MA_TextureAtlasserProUtils.RemoveTextureQuad(curWindow.textureAtlas, curWindow.settings.autoFocus);
e.Use();
}
if (e.type == EventType.KeyDown && e.keyCode == curWindow.settings.duplicateHotKey)
{
MA_TextureAtlasserProUtils.DuplicateTextureQuad(curWindow.textureAtlas, curWindow.settings.autoFocus, curWindow.settings.copySelectedQuadData, curWindow.settings.duplicatedQuadNamePrefix);
e.Use();
}
}
}
}
} }
private Vector2 ConvertScreenCoordsToZoomCoords(Vector2 screenCoords) private Vector2 ConvertScreenCoordsToZoomCoords(Vector2 screenCoords)
@ -119,4 +148,5 @@ namespace MA_TextureAtlasserPro
zoomCoordsOrigin = new Vector2(-(curWindow.position.width / 2) + (curWindow.position.width / 3), -(curWindow.position.height / 2) + (curWindow.position.height / 3)); zoomCoordsOrigin = new Vector2(-(curWindow.position.width / 2) + (curWindow.position.width / 3), -(curWindow.position.height / 2) + (curWindow.position.height / 3));
} }
} }
} }
#endif

View File

@ -1,4 +1,5 @@
using System.Collections; #if UNITY_EDITOR
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using UnityEditor; using UnityEditor;
@ -167,4 +168,5 @@ namespace MA_TextureAtlasserPro
isLoaded = true; isLoaded = true;
} }
} }
} }
#endif

View File

@ -1,4 +1,5 @@
using System.Collections; #if UNITY_EDITOR
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using UnityEditor; using UnityEditor;
@ -132,4 +133,5 @@ namespace MA_TextureAtlasserPro
isLoaded = true; isLoaded = true;
} }
} }
} }
#endif

View File

@ -1,4 +1,5 @@
using System.Collections; #if UNITY_EDITOR
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using UnityEditor; using UnityEditor;
@ -8,6 +9,7 @@ namespace MA_TextureAtlasserPro
public class MA_TextureAtlasserProWindow : EditorWindow public class MA_TextureAtlasserProWindow : EditorWindow
{ {
public static MA_TextureAtlasserProWindow thisWindow; public static MA_TextureAtlasserProWindow thisWindow;
public MA_TextureAtlasserProSettings settings;
public MA_TextureAtlasserProAtlas textureAtlas; public MA_TextureAtlasserProAtlas textureAtlas;
public MA_TextureAtlasserProWorkView workView; public MA_TextureAtlasserProWorkView workView;
@ -56,6 +58,7 @@ namespace MA_TextureAtlasserPro
GetCurrentWindow(); GetCurrentWindow();
} }
thisWindow.settings = MA_TextureAtlasserProUtils.LoadSettings();
thisWindow.workView = new MA_TextureAtlasserProWorkView(thisWindow, "workView"); thisWindow.workView = new MA_TextureAtlasserProWorkView(thisWindow, "workView");
thisWindow.menuView = new MA_TextureAtlasserProMenuView(thisWindow, "menuView"); thisWindow.menuView = new MA_TextureAtlasserProMenuView(thisWindow, "menuView");
thisWindow.inspectorView = new MA_TextureAtlasserProInspectorView(thisWindow, "inspectorView"); thisWindow.inspectorView = new MA_TextureAtlasserProInspectorView(thisWindow, "inspectorView");
@ -86,7 +89,7 @@ namespace MA_TextureAtlasserPro
} }
//Check views //Check views
if(workView == null || menuView == null || inspectorView == null || debugView == null) if(settings == null || workView == null || menuView == null || inspectorView == null || debugView == null)
{ {
CreateViews(); CreateViews();
return; return;
@ -116,4 +119,5 @@ namespace MA_TextureAtlasserPro
isLoaded = true; isLoaded = true;
} }
} }
} }
#endif

View File

@ -0,0 +1 @@
Settigns are supposed to be here.

View File

@ -1,6 +1,7 @@
//Maxartz15 //Maxartz15
//Version 1.0 //Version 1.0
#if UNITY_EDITOR
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
@ -58,4 +59,5 @@ namespace MA_Editor.Grid
Handles.EndGUI(); Handles.EndGUI();
} }
} }
} }
#endif

View File

@ -1,6 +1,7 @@
//Maxartz15 //Maxartz15
//Version 1.0 //Version 1.0
#if UNITY_EDITOR
using UnityEngine; using UnityEngine;
using MA_Editor; using MA_Editor;
@ -67,4 +68,5 @@ namespace MA_Editor.RectUtils
return multipliedRect; return multipliedRect;
} }
} }
} }
#endif

View File

@ -1,6 +1,7 @@
//Maxartz15 //Maxartz15
//Version 1.0 //Version 1.0
#if UNITY_EDITOR
using UnityEngine; using UnityEngine;
using MA_Editor; using MA_Editor;
using MA_Editor.RectUtils; using MA_Editor.RectUtils;
@ -36,4 +37,5 @@ namespace MA_Editor.GUILayoutZoom
GUI.BeginGroup(new Rect(0.0f, EditorWindowTabHeight, Screen.width, Screen.height)); GUI.BeginGroup(new Rect(0.0f, EditorWindowTabHeight, Screen.width, Screen.height));
} }
} }
} }
#endif

View File

@ -1,6 +1,7 @@
//Maxartz15 //Maxartz15
//Version 1.0 //Version 1.0
#if UNITY_EDITOR
using System; using System;
using System.IO; using System.IO;
using System.Text; using System.Text;
@ -184,4 +185,5 @@ namespace MA_Mesh
public string name; public string name;
public string textureName; public string textureName;
} }
} }
#endif

View File

@ -3,6 +3,7 @@
//Part of MA_TextureUtils //Part of MA_TextureUtils
//https://github.com/maxartz15/MA_TextureUtils //https://github.com/maxartz15/MA_TextureUtils
#if UNITY_EDITOR
using UnityEngine; using UnityEngine;
using UnityEditor; using UnityEditor;
using System.IO; using System.IO;
@ -200,4 +201,5 @@ namespace MA_Texture
} }
#endregion #endregion
} }
} }
#endif

View File

@ -6,4 +6,6 @@ By having full control over the size and position of the textures that are being
https://youtu.be/PBRKlopkZP0 https://youtu.be/PBRKlopkZP0
Download the UnityPackage here: https://github.com/maxartz15/MA_TextureAtlasser/releases
For more information: https://maxartz15.com/ma_textureatlas/ For more information: https://maxartz15.com/ma_textureatlas/