From 2017fc843026657177ced279ab56c353c8d1560d Mon Sep 17 00:00:00 2001 From: Icarus <1375400884@qq.com> Date: Wed, 25 Sep 2019 16:58:09 +0800 Subject: [PATCH] =?UTF-8?q?!OW=20=E8=AE=A9=E4=BD=BF=E7=94=A8=E8=80=85?= =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E8=87=AA=E5=AE=9A=E4=B9=89=E4=B8=8D=E9=9C=80?= =?UTF-8?q?=E8=A6=81=E6=98=BE=E7=A4=BA=E7=9A=84=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Scripts/Editor/NodeEditor.cs | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/Scripts/Editor/NodeEditor.cs b/Scripts/Editor/NodeEditor.cs index 71529ff..efa0fcc 100644 --- a/Scripts/Editor/NodeEditor.cs +++ b/Scripts/Editor/NodeEditor.cs @@ -23,11 +23,34 @@ namespace XNodeEditor { #if ODIN_INSPECTOR internal static bool inNodeEditor = false; #endif + private List _excludesField; + public sealed override void OnCreate() + { + _excludesField = new List { "m_Script", "graph", "position", "ports" }; + + var fields = GetExcludesField(); + + if (fields != null) + { + _excludesField.AddRange(fields); + } + + Init(); + } + + protected virtual void Init() + { + } public virtual void OnHeaderGUI() { GUILayout.Label(target.name, NodeEditorResources.styles.nodeHeader, GUILayout.Height(30)); } + protected virtual IEnumerable GetExcludesField() + { + return null; + } + /// Draws standard field editors for all public fields public virtual void OnBodyGUI() { #if ODIN_INSPECTOR @@ -38,8 +61,7 @@ namespace XNodeEditor { // serializedObject.Update(); must go at the start of an inspector gui, and // serializedObject.ApplyModifiedProperties(); goes at the end. serializedObject.Update(); - string[] excludes = { "m_Script", "graph", "position", "ports" }; - + #if ODIN_INSPECTOR InspectorUtilities.BeginDrawPropertyTree(objectTree, true); GUIHelper.PushLabelWidth(84); @@ -55,7 +77,7 @@ namespace XNodeEditor { List _names = new List(); while (iterator.NextVisible(enterChildren)) { enterChildren = false; - if (excludes.Contains(iterator.name)) continue; + if (_excludesField.Contains(iterator.name)) continue; NodeEditorGUILayout.PropertyField(iterator, true); _names.Add(iterator.name); }