Skip to content

Commit

Permalink
chore
Browse files Browse the repository at this point in the history
  • Loading branch information
sator-imaging committed Sep 3, 2023
1 parent 9fe5523 commit c7fee13
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
25 changes: 13 additions & 12 deletions Editor/ProjectSettingsPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,11 @@ void OnGUI()
static string[] _emitterPaths = Array.Empty<string>();
static string _generatorPathToShowEmitters = null;
static Dictionary<string, string> _generatorNameToOutputFileName = new();
static GUIContent gui_emitterBtn;
// GUI classes cannot be initialized on field definition.
static GUIContent gui_emittersBtn;
static GUIContent gui_deleteBtn;
static GUIContent gui_generateBtn;
static GUIContent gui_goGeneratedBtn;
static GUIContent gui_runBtn;
static GUIContent gui_unveilBtn;
static GUILayoutOption gui_toggleWidth;
static GUILayoutOption gui_buttonWidth;
static GUIStyle gui_noBGButtonStyle;
Expand All @@ -104,11 +105,10 @@ void OnGUI()
// to take reference to newly created object, need `ref` chain.
static void Wakeup(ref Editor cachedEditor)
{
// GUI classes cannot be initialized on field definition.
gui_emitterBtn ??= new(EditorGUIUtility.IconContent("d_icon dropdown"));
gui_emittersBtn ??= new(EditorGUIUtility.IconContent("d_icon dropdown"));
gui_deleteBtn ??= new(EditorGUIUtility.IconContent("d_TreeEditor.Trash"));
gui_generateBtn ??= new(EditorGUIUtility.IconContent("PlayButton On"));//d_playLoopOff
gui_goGeneratedBtn ??= new(EditorGUIUtility.IconContent("d_Linked"));//SavePassive/SaveActive/SaveFromPlay/d_pick/
gui_runBtn ??= new(EditorGUIUtility.IconContent("PlayButton On"));//d_playLoopOff
gui_unveilBtn ??= new(EditorGUIUtility.IconContent("d_Linked"));//SavePassive/SaveActive/SaveFromPlay/d_pick/
gui_toggleWidth ??= GUILayout.Width(16);
gui_buttonWidth ??= GUILayout.Width(32);
if (gui_noBGButtonStyle == null)
Expand Down Expand Up @@ -227,7 +227,7 @@ static void DrawGenerator(string filePath, bool showEmitterBtn)
}

//run
if (GUILayout.Button(gui_generateBtn, gui_buttonWidth))
if (GUILayout.Button(gui_runBtn, gui_buttonWidth))
{
Debug.Log($"[{nameof(UnitySourceGenerator)}] Generator running: {fileName}");
USGUtility.ForceGenerateByName(fileName, false);
Expand All @@ -238,18 +238,19 @@ static void DrawGenerator(string filePath, bool showEmitterBtn)
{
EditorGUIUtility.PingObject(AssetDatabase.LoadAssetAtPath<Object>(filePath));
}
//emitter??

//emitters??
if (showEmitterBtn)
{
if (GUILayout.Button(gui_emitterBtn, gui_noBGButtonStyle))
if (GUILayout.Button(gui_emittersBtn, gui_noBGButtonStyle))
{
_emitterPaths = GetEmitters(filePath);
}
}
//goGenerated??
//unveil??
else
{
if (GUILayout.Button(gui_goGeneratedBtn, gui_noBGButtonStyle))
if (GUILayout.Button(gui_unveilBtn, gui_noBGButtonStyle))
{
EditorGUIUtility.PingObject(AssetDatabase.LoadAssetAtPath<Object>(
USGEngine.GetGeneratorOutputPath(filePath, _generatorNameToOutputFileName[fileName])));
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ There are utility functions to perform source code generation on build event.
USGUtility.ForceGenerateByName(nameof(MinimalGenerator));

// perform code generation by known path.
USGEngine.ProcessFile(assetPath, true, true); // force overwrite all related generators
USGEngine.ProcessFile(assetPath, true, true); // force re-generate all related files
```


Expand Down

0 comments on commit c7fee13

Please sign in to comment.