Skip to content

Commit ec5b0d7

Browse files
committed
feat: Prettify editor window
1 parent 84d3355 commit ec5b0d7

File tree

2 files changed

+37
-35
lines changed

2 files changed

+37
-35
lines changed

Assets/JCSUnity/Editor/JCSUnity_EditorWindow.cs

Lines changed: 13 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ public static string NAME
3838

3939
private static bool prefsLoaded = false;
4040

41-
private bool mFO_Scene = false;
41+
private bool mFO_Project = false;
4242
private bool mFO_Basic = false;
43-
private bool mFO_GUI = false;
43+
private bool mFO_Scene = false;
44+
private bool mFO_UI = false;
45+
private bool mFO_Input = false;
4446
private bool mFO_Effect = false;
4547
private bool mFO_ARVR = false;
46-
private bool mFO_Input = false;
47-
private bool mFO_Tool = false;
4848

4949
public string PROJECT_NAME = "_Project";
5050
public const string PROJECT_NAME_SUFFIX = "";
@@ -92,33 +92,13 @@ private void Init()
9292

9393
private void Draw()
9494
{
95-
mFO_Scene = EditorGUILayout.Foldout(mFO_Scene, "Scene");
96-
if (mFO_Scene)
97-
JCSUnity_EditortUtil.CreateGroup(Part_Scene);
98-
99-
mFO_Basic = EditorGUILayout.Foldout(mFO_Basic, "Basic");
100-
if (mFO_Basic)
101-
JCSUnity_EditortUtil.CreateGroup(Part_Basic);
102-
103-
mFO_GUI = EditorGUILayout.Foldout(mFO_GUI, "GUI");
104-
if (mFO_GUI)
105-
JCSUnity_EditortUtil.CreateGroup(Part_GUI);
106-
107-
mFO_Effect = EditorGUILayout.Foldout(mFO_Effect, "Effect");
108-
if (mFO_Effect)
109-
JCSUnity_EditortUtil.CreateGroup(Part_Effect);
110-
111-
mFO_ARVR = EditorGUILayout.Foldout(mFO_ARVR, "AR / VR");
112-
if (mFO_ARVR)
113-
JCSUnity_EditortUtil.CreateGroup(Part_ARVR);
114-
115-
mFO_Input = EditorGUILayout.Foldout(mFO_Input, "Input");
116-
if (mFO_Input)
117-
JCSUnity_EditortUtil.CreateGroup(Part_Input);
118-
119-
mFO_Tool = EditorGUILayout.Foldout(mFO_Tool, "Tool");
120-
if (mFO_Tool)
121-
JCSUnity_EditortUtil.CreateGroup(Part_Tool);
95+
mFO_Project = JCSUnity_EditortUtil.Foldout(mFO_Project, "Project", Part_Project, "d_Folder Icon");
96+
mFO_Basic = JCSUnity_EditortUtil.Foldout(mFO_Basic, "Basic", Part_Basic, "_Popup");
97+
mFO_Scene = JCSUnity_EditortUtil.Foldout(mFO_Scene, "Scene", Part_Scene, "d_ToggleUVOverlay");
98+
mFO_UI = JCSUnity_EditortUtil.Foldout(mFO_UI, "UI", Part_UI, "d_UnityEditor.SceneHierarchyWindow");
99+
mFO_Input = JCSUnity_EditortUtil.Foldout(mFO_Input, "Input", Part_Input, "d_UnityEditor.GameView");
100+
mFO_Effect = JCSUnity_EditortUtil.Foldout(mFO_Effect, "Effect", Part_Effect, "ParticleSystem Gizmo");
101+
mFO_ARVR = JCSUnity_EditortUtil.Foldout(mFO_ARVR, "AR / VR", Part_ARVR, "animationvisibilitytoggleon");
122102
}
123103

124104
private void SavePref()
@@ -188,7 +168,7 @@ private void Part_Basic()
188168
/// <summary>
189169
/// Compile the GUI part to Unity's GUI inspector.
190170
/// </summary>
191-
private void Part_GUI()
171+
private void Part_UI()
192172
{
193173
GUILayout.Label("Cursor", EditorStyles.boldLabel);
194174

@@ -269,10 +249,8 @@ private void Part_Input()
269249
/// <summary>
270250
/// Compile the Tool part to Tool inspector.
271251
/// </summary>
272-
private void Part_Tool()
252+
private void Part_Project()
273253
{
274-
GUILayout.Label("Project", EditorStyles.boldLabel);
275-
276254
/* Project Name */
277255
{
278256
// Provide default project name.

Assets/JCSUnity/Editor/JCSUnity_EditortUtil.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* $Notice: See LICENSE.txt for modification and distribution information
88
* Copyright © 2021 by Shen, Jen-Chieh $
99
*/
10+
using System.Xml.Linq;
1011
using UnityEditor;
1112
using UnityEngine;
1213

@@ -61,6 +62,29 @@ public static void Indent(EmptyFunction func)
6162
func.Invoke();
6263
EditorGUI.indentLevel--;
6364
}
65+
66+
public static bool Foldout(bool foldout, string content, EmptyFunction func, string texName = "")
67+
{
68+
Texture tex = FindTexture(texName);
69+
70+
GUIContent guic = (tex) ? new GUIContent(" " + content, tex) : new GUIContent(content);
71+
72+
foldout = EditorGUILayout.Foldout(foldout, guic);
73+
74+
if (foldout)
75+
CreateGroup(func);
76+
77+
return foldout;
78+
}
79+
80+
/// <summary>
81+
/// Get a texture from its source filename.
82+
/// </summary>
83+
public static Texture FindTexture(string texName)
84+
{
85+
Texture tex = (texName == "") ? null : EditorGUIUtility.FindTexture(texName);
86+
return tex;
87+
}
6488
}
6589
}
6690
#endif

0 commit comments

Comments
 (0)