From 2f1cd4f2dec97b0c22e3afa48f7e9743c6834041 Mon Sep 17 00:00:00 2001 From: JasonMa <1312119064@qq.com> Date: Thu, 6 Jul 2023 11:31:44 +0800 Subject: [PATCH] add custom header and footer --- Editor/CustomGUISample.meta | 3 +++ Editor/CustomGUISample/CustomFooter.cs | 21 +++++++++++++++++++ Editor/CustomGUISample/CustomFooter.cs.meta | 3 +++ Editor/CustomGUISample/CustomHeadercs.cs | 21 +++++++++++++++++++ Editor/CustomGUISample/CustomHeadercs.cs.meta | 3 +++ Editor/LWGUI.cs | 14 ++++++++++++- package.json | 2 +- 7 files changed, 65 insertions(+), 2 deletions(-) create mode 100644 Editor/CustomGUISample.meta create mode 100644 Editor/CustomGUISample/CustomFooter.cs create mode 100644 Editor/CustomGUISample/CustomFooter.cs.meta create mode 100644 Editor/CustomGUISample/CustomHeadercs.cs create mode 100644 Editor/CustomGUISample/CustomHeadercs.cs.meta diff --git a/Editor/CustomGUISample.meta b/Editor/CustomGUISample.meta new file mode 100644 index 0000000..3a4bf04 --- /dev/null +++ b/Editor/CustomGUISample.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 1126f19081e143caa82b7f5ab01b9b6a +timeCreated: 1688612154 \ No newline at end of file diff --git a/Editor/CustomGUISample/CustomFooter.cs b/Editor/CustomGUISample/CustomFooter.cs new file mode 100644 index 0000000..c1a5114 --- /dev/null +++ b/Editor/CustomGUISample/CustomFooter.cs @@ -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; + } + } +} \ No newline at end of file diff --git a/Editor/CustomGUISample/CustomFooter.cs.meta b/Editor/CustomGUISample/CustomFooter.cs.meta new file mode 100644 index 0000000..ff92dc0 --- /dev/null +++ b/Editor/CustomGUISample/CustomFooter.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 421a56cca25d486298053d5eeca0c669 +timeCreated: 1688612200 \ No newline at end of file diff --git a/Editor/CustomGUISample/CustomHeadercs.cs b/Editor/CustomGUISample/CustomHeadercs.cs new file mode 100644 index 0000000..3ae4202 --- /dev/null +++ b/Editor/CustomGUISample/CustomHeadercs.cs @@ -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; + } + } +} \ No newline at end of file diff --git a/Editor/CustomGUISample/CustomHeadercs.cs.meta b/Editor/CustomGUISample/CustomHeadercs.cs.meta new file mode 100644 index 0000000..6a9e1c8 --- /dev/null +++ b/Editor/CustomGUISample/CustomHeadercs.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 12f48d96821d4f33aa8d9a7618a9ae0b +timeCreated: 1688613396 \ No newline at end of file diff --git a/Editor/LWGUI.cs b/Editor/LWGUI.cs index 74662fe..0d7f629 100644 --- a/Editor/LWGUI.cs +++ b/Editor/LWGUI.cs @@ -21,6 +21,8 @@ public enum SearchMode All, Modified } + + public delegate void LWGUICustomGUIEvent(LWGUI lwgui); public class LWGUI : ShaderGUI { @@ -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; /// /// Called when switch to a new Material Window, each window has a LWGUI instance @@ -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); @@ -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 diff --git a/package.json b/package.json index 68d2e2c..cffec6c 100644 --- a/package.json +++ b/package.json @@ -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": [