-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First iteration, buttons now have optional tooltips and labels. By default the editor will load with them on, this can be changed in the settings.
- Loading branch information
Showing
12 changed files
with
200 additions
and
56 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
Assets/MA_ToolBox/MA_TextureAtlasserPro/Scripts/Data/Editor.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
30 changes: 30 additions & 0 deletions
30
..._ToolBox/MA_TextureAtlasserPro/Scripts/Data/Editor/MA_TextureAtlasserProSettingsEditor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#if UNITY_EDITOR | ||
using UnityEditor; | ||
using UnityEngine; | ||
|
||
namespace MA_TextureAtlasserPro | ||
{ | ||
[CustomEditor(typeof(MA_TextureAtlasserProSettings))] | ||
[CanEditMultipleObjects] | ||
public class MA_TextureAtlasserProSettingsEditor : Editor | ||
{ | ||
GUIContent reloadButton = new GUIContent("Reload", "Update the editor with the changes made."); | ||
|
||
public override void OnInspectorGUI() | ||
{ | ||
GUILayout.BeginVertical(); | ||
DrawDefaultInspector(); | ||
|
||
GUILayout.Space(15); | ||
|
||
if(GUILayout.Button(reloadButton, GUILayout.Height(40), GUILayout.ExpandWidth(true))) | ||
{ | ||
//Update necessary systems. | ||
MA_TextureAtlasserProGuiLoader.LoadEditorGui((MA_TextureAtlasserProSettings)this.target); | ||
} | ||
|
||
GUILayout.EndVertical(); | ||
} | ||
} | ||
} | ||
#endif |
5 changes: 2 additions & 3 deletions
5
.../Utils/MA_TextureAtlasserProIcons.cs.meta → ..._TextureAtlasserProSettingsEditor.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
115 changes: 115 additions & 0 deletions
115
...s/MA_ToolBox/MA_TextureAtlasserPro/Scripts/Editor/Utils/MA_TextureAtlasserProGuiLoader.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
#if UNITY_EDITOR | ||
using UnityEngine; | ||
using UnityEditor; | ||
|
||
namespace MA_TextureAtlasserPro | ||
{ | ||
public static class MA_TextureAtlasserProGuiLoader | ||
{ | ||
private const string LOADICONPATH = "Assets/MA_ToolBox/MA_TextureAtlasserPro/Icons/"; | ||
|
||
public static GUIContent createAtlasGC; | ||
public static GUIContent loadAtlasGC; | ||
public static GUIContent exportAtlasGC; | ||
public static GUIContent createQuadGC; | ||
public static GUIContent removeQuadGC; | ||
public static GUIContent duplicateQuadGC; | ||
public static GUIContent showTexturesOnGC; | ||
public static GUIContent showTexturesOffGC; | ||
public static GUIContent dragHandleGC; | ||
public static GUIContent editGC; | ||
public static GUIContent createExportSettingsGC; | ||
|
||
public static void LoadEditorGui(MA_TextureAtlasserProSettings settings) | ||
{ | ||
createAtlasGC = new GUIContent(); | ||
loadAtlasGC = new GUIContent(); | ||
exportAtlasGC = new GUIContent(); | ||
createQuadGC = new GUIContent(); | ||
removeQuadGC = new GUIContent(); | ||
duplicateQuadGC = new GUIContent(); | ||
showTexturesOnGC = new GUIContent(); | ||
showTexturesOffGC = new GUIContent(); | ||
dragHandleGC = new GUIContent(); | ||
editGC = new GUIContent(); | ||
createExportSettingsGC = new GUIContent(); | ||
|
||
switch (settings.editorGuiSettings.editorGuiMode) | ||
{ | ||
case MA_EditorGuiMode.IconAndText: | ||
LoadIcons(); | ||
LoadText(); | ||
break; | ||
case MA_EditorGuiMode.Icon: | ||
LoadIcons(); | ||
break; | ||
case MA_EditorGuiMode.Text: | ||
LoadText(); | ||
break; | ||
default: | ||
LoadIcons(); | ||
break; | ||
} | ||
|
||
if(settings.editorGuiSettings.enableToolTips) | ||
{ | ||
LoadToolTips(settings); | ||
} | ||
|
||
//Exceptions. | ||
dragHandleGC.image = (Texture)EditorGUIUtility.Load(LOADICONPATH + "dragHandleIcon" + ".png"); | ||
dragHandleGC.text = ""; | ||
editGC.image = (Texture)EditorGUIUtility.Load(LOADICONPATH + "editIcon" + ".png"); | ||
editGC.text = ""; | ||
} | ||
|
||
private static void LoadIcons() | ||
{ | ||
createAtlasGC.image = (Texture)EditorGUIUtility.Load(LOADICONPATH + "createAtlasIcon" + ".png"); | ||
loadAtlasGC.image = (Texture)EditorGUIUtility.Load(LOADICONPATH + "loadAtlasIcon" + ".png"); | ||
exportAtlasGC.image = (Texture)EditorGUIUtility.Load(LOADICONPATH + "exportAtlasIcon" + ".png"); | ||
createQuadGC.image = (Texture)EditorGUIUtility.Load(LOADICONPATH + "createQuadIcon" + ".png"); | ||
removeQuadGC.image = (Texture)EditorGUIUtility.Load(LOADICONPATH + "removeQuadIcon" + ".png"); | ||
duplicateQuadGC.image = (Texture)EditorGUIUtility.Load(LOADICONPATH + "duplicateQuadIcon" + ".png"); | ||
showTexturesOnGC.image = (Texture)EditorGUIUtility.Load(LOADICONPATH + "showTexturesOnIcon" + ".png"); | ||
showTexturesOffGC.image = (Texture)EditorGUIUtility.Load(LOADICONPATH + "showTexturesOffIcon" + ".png"); | ||
createExportSettingsGC.image = (Texture)EditorGUIUtility.Load(LOADICONPATH + "createAtlasIcon" + ".png"); | ||
} | ||
|
||
private static void LoadText() | ||
{ | ||
createAtlasGC.text = "Create Atlas"; | ||
loadAtlasGC.text = "Load Atlas"; | ||
exportAtlasGC.text = "Export Atlas"; | ||
createQuadGC.text = "Create Quad"; | ||
removeQuadGC.text = "Remove Quad"; | ||
duplicateQuadGC.text = "Duplicate Quad"; | ||
showTexturesOnGC.text = "Hide Textures"; | ||
showTexturesOffGC.text = "Show Textures"; | ||
createExportSettingsGC.text = "Create Export Settings"; | ||
} | ||
|
||
private static void LoadToolTips(MA_TextureAtlasserProSettings settings) | ||
{ | ||
createAtlasGC.tooltip = "Opens the create atlas window."; | ||
loadAtlasGC.tooltip = "Load an existing atlas."; | ||
exportAtlasGC.tooltip = "Opens the export window."; | ||
if (settings.useHotkeys) | ||
{ | ||
createQuadGC.tooltip = string.Format("({0} + {1}), Creates a new quad.", settings.modifierKey, settings.addQuadHotKey); | ||
removeQuadGC.tooltip = string.Format("({0} + {1}), Removes the selected quad.", settings.modifierKey, settings.removeQuadHotKey); | ||
duplicateQuadGC.tooltip = string.Format("({0} + {1}), Duplicates the selected quad.", settings.modifierKey, settings.duplicateHotKey); | ||
} | ||
else | ||
{ | ||
createQuadGC.tooltip = "Creates a new quad."; | ||
removeQuadGC.tooltip = "Removes the selected quad."; | ||
duplicateQuadGC.tooltip = "Duplicates the selected quad."; | ||
} | ||
showTexturesOnGC.tooltip = "Hides the preview of the first texture on the quads."; | ||
showTexturesOffGC.tooltip = "Shows a preview of the first texture on the quads."; | ||
createExportSettingsGC.tooltip = "Opens the create export settings window."; | ||
} | ||
} | ||
} | ||
#endif |
11 changes: 11 additions & 0 deletions
11
...ToolBox/MA_TextureAtlasserPro/Scripts/Editor/Utils/MA_TextureAtlasserProGuiLoader.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
37 changes: 0 additions & 37 deletions
37
Assets/MA_ToolBox/MA_TextureAtlasserPro/Scripts/Editor/Utils/MA_TextureAtlasserProIcons.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters