Skip to content

Commit

Permalink
add custom header and footer
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonMa0012 committed Jul 6, 2023
1 parent 73b0cc2 commit 2f1cd4f
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Editor/CustomGUISample.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions Editor/CustomGUISample/CustomFooter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using UnityEngine;
using UnityEditor;

namespace LWGUI.CustomGUISample
{
public static class CustomFooter
{
public static void DoCustomFooter(LWGUI lwgui)
{
// Draw your custom gui...

// Debug.Log(lwgui.shader);
}

[InitializeOnLoadMethod]
private static void RegisterEvent()
{
LWGUI.onCustomFooter += DoCustomFooter;
}
}
}
3 changes: 3 additions & 0 deletions Editor/CustomGUISample/CustomFooter.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions Editor/CustomGUISample/CustomHeadercs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using UnityEngine;
using UnityEditor;

namespace LWGUI.CustomGUISample
{
public static class CustomHeader
{
public static void DoCustomHeader(LWGUI lwgui)
{
// Draw your custom gui...

// Debug.Log(lwgui.shader);
}

[InitializeOnLoadMethod]
private static void RegisterEvent()
{
LWGUI.onCustomFooter += DoCustomHeader;
}
}
}
3 changes: 3 additions & 0 deletions Editor/CustomGUISample/CustomHeadercs.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 13 additions & 1 deletion Editor/LWGUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public enum SearchMode
All,
Modified
}

public delegate void LWGUICustomGUIEvent(LWGUI lwgui);

public class LWGUI : ShaderGUI
{
Expand All @@ -36,7 +38,10 @@ public class LWGUI : ShaderGUI
public LwguiEventType lwguiEventType = LwguiEventType.Init;
public Shader shader;

private static bool _forceInit = false;
public static LWGUICustomGUIEvent onCustomHeader;
public static LWGUICustomGUIEvent onCustomFooter;

private static bool _forceInit = false;

/// <summary>
/// Called when switch to a new Material Window, each window has a LWGUI instance
Expand Down Expand Up @@ -69,6 +74,9 @@ public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] pro

// draw with metadata
{
if (onCustomHeader != null)
onCustomHeader(this);

// Search Field
if (searchResult == null)
searchResult = MetaDataHelper.SearchProperties(shader, material, props, String.Empty, searchMode);
Expand Down Expand Up @@ -145,6 +153,10 @@ public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] pro

EditorGUILayout.Space();
EditorGUILayout.Space();

if (onCustomFooter != null)
onCustomFooter(this);

#if UNITY_2019_4_OR_NEWER
if (SupportedRenderingFeatures.active.editableMaterialRenderQueue)
#endif
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "com.jasonma.lwgui",
"version": "1.8.2",
"version": "1.9.0",
"displayName": "LWGUI",
"description": "A Lightweight, Flexible, Powerful Shader GUI System for Unity.",
"keywords": [
Expand Down

0 comments on commit 2f1cd4f

Please sign in to comment.