From ba47fbd54967c4045afb15622a119adb362d8029 Mon Sep 17 00:00:00 2001 From: Icarus <1375400884@qq.com> Date: Sun, 22 Sep 2019 01:50:44 +0800 Subject: [PATCH 01/65] =?UTF-8?q?!W=20=E5=8A=A0=E5=85=A5=E4=BA=86IcSkillSy?= =?UTF-8?q?stme=E8=BF=9E=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Scripts/Editor/NodeEditorPreferences.cs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Scripts/Editor/NodeEditorPreferences.cs b/Scripts/Editor/NodeEditorPreferences.cs index b3026b9..1bba650 100644 --- a/Scripts/Editor/NodeEditorPreferences.cs +++ b/Scripts/Editor/NodeEditorPreferences.cs @@ -106,8 +106,24 @@ namespace XNodeEditor { private static void PreferencesGUI() { VerifyLoaded(); Settings settings = NodeEditorPreferences.settings[lastKey]; + + EditorGUILayout.BeginHorizontal(); + { + EditorGUILayout.Space(); + { + if (GUILayout.Button(new GUIContent("XNode Documentation", "https://github.com/Siccity/xNode/wiki"), + GUILayout.Width(180))) + Application.OpenURL("https://github.com/Siccity/xNode/wiki"); + + if (GUILayout.Button( + new GUIContent("IcSkill Documentation", "https://github.com/yika-aixi/IcSkillSystem"), + GUILayout.Width(180))) + Application.OpenURL("https://github.com/yika-aixi/IcSkillSystem"); + } + EditorGUILayout.Space(); + } + EditorGUILayout.EndHorizontal(); - if (GUILayout.Button(new GUIContent("Documentation", "https://github.com/Siccity/xNode/wiki"), GUILayout.Width(100))) Application.OpenURL("https://github.com/Siccity/xNode/wiki"); EditorGUILayout.Space(); NodeSettingsGUI(lastKey, settings); From 113eb4b48d160e679481d1203d376f1a2ed452c2 Mon Sep 17 00:00:00 2001 From: Icarus <1375400884@qq.com> Date: Sun, 22 Sep 2019 02:40:53 +0800 Subject: [PATCH 02/65] =?UTF-8?q?!T=20=E8=B0=83=E6=95=B4=E4=BA=86=E7=BB=98?= =?UTF-8?q?=E5=88=B6=E9=A1=BA=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Scripts/Editor/NodeEditorGUI.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Scripts/Editor/NodeEditorGUI.cs b/Scripts/Editor/NodeEditorGUI.cs index 9954325..6546f6f 100644 --- a/Scripts/Editor/NodeEditorGUI.cs +++ b/Scripts/Editor/NodeEditorGUI.cs @@ -24,9 +24,9 @@ namespace XNodeEditor { Controls(); DrawGrid(position, zoom, panOffset); - DrawConnections(); DrawDraggedConnection(); DrawNodes(); + DrawConnections(); DrawSelectionBox(); DrawTooltip(); graphEditor.OnGUI(); From 574e3457f639c20044ac23ec972738e89a251d3a Mon Sep 17 00:00:00 2001 From: Icarus <1375400884@qq.com> Date: Sun, 22 Sep 2019 02:43:22 +0800 Subject: [PATCH 03/65] =?UTF-8?q?!B=20=E6=B2=A1=E6=9C=89=E8=BF=87=E6=BB=A4?= =?UTF-8?q?=E4=BF=9D=E6=8A=A4=E5=92=8C=E5=86=85=E9=83=A8=E7=AD=89=E5=85=B6?= =?UTF-8?q?=E4=BB=96=E7=B1=BB=E5=9E=8B=E5=AD=97=E6=AE=B5,=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=E5=87=BA=E7=8E=B0=E5=A4=9A=E6=AC=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Scripts/NodeDataCache.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Scripts/NodeDataCache.cs b/Scripts/NodeDataCache.cs index 02e35a1..886f128 100644 --- a/Scripts/NodeDataCache.cs +++ b/Scripts/NodeDataCache.cs @@ -98,8 +98,12 @@ namespace XNode { // GetFields doesnt return inherited private fields, so walk through base types and pick those up System.Type tempType = nodeType; - while ((tempType = tempType.BaseType) != typeof(XNode.Node)) { - fieldInfo.AddRange(tempType.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)); + while ((tempType = tempType.BaseType) != typeof(XNode.Node)) + { + //只返回私有的,保护等其他的不需要 + var fieldInfos = tempType.GetFields(BindingFlags.NonPublic | BindingFlags.Instance).Where(x=>x.IsPrivate); + + fieldInfo.AddRange(fieldInfos); } return fieldInfo; } From d6e64f82f6fff04365f725e5a615771f428de7f9 Mon Sep 17 00:00:00 2001 From: Icarus <1375400884@qq.com> Date: Sun, 22 Sep 2019 02:53:18 +0800 Subject: [PATCH 04/65] =?UTF-8?q?!T=20=E5=BF=BD=E7=95=A5meta?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 64ab4c0..a4ed8fc 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,5 @@ sysinfo.txt .git.meta .gitignore.meta .gitattributes.meta + +*.meta From ee68490c9b5b92b48f8aebd6b31b85fce6dd1006 Mon Sep 17 00:00:00 2001 From: Icarus <1375400884@qq.com> Date: Sun, 22 Sep 2019 02:53:49 +0800 Subject: [PATCH 05/65] !D meta --- CONTRIBUTING.md.meta | 7 -- LICENSE.md.meta | 7 -- README.md.meta | 7 -- Scripts.meta | 9 -- Scripts/Attributes.meta | 10 -- Scripts/Attributes/NodeEnum.cs.meta | 13 --- Scripts/Editor.meta | 9 -- Scripts/Editor/Drawers.meta | 10 -- Scripts/Editor/Drawers/NodeEnumDrawer.cs.meta | 13 --- Scripts/Editor/Drawers/Odin.meta | 8 -- .../InNodeEditorAttributeProcessor.cs.meta | 11 --- .../Drawers/Odin/InputAttributeDrawer.cs.meta | 11 --- .../Odin/OutputAttributeDrawer.cs.meta | 11 --- Scripts/Editor/Internal.meta | 8 -- .../Editor/Internal/RerouteReference.cs.meta | 11 --- Scripts/Editor/NodeEditor.cs.meta | 12 --- Scripts/Editor/NodeEditorAction.cs.meta | 12 --- .../NodeEditorAssetModProcessor.cs.meta | 12 --- Scripts/Editor/NodeEditorBase.cs.meta | 13 --- Scripts/Editor/NodeEditorGUI.cs.meta | 11 --- Scripts/Editor/NodeEditorGUILayout.cs.meta | 12 --- Scripts/Editor/NodeEditorPreferences.cs.meta | 12 --- Scripts/Editor/NodeEditorReflection.cs.meta | 12 --- Scripts/Editor/NodeEditorResources.cs.meta | 12 --- Scripts/Editor/NodeEditorUtilities.cs.meta | 12 --- Scripts/Editor/NodeEditorWindow.cs.meta | 12 --- Scripts/Editor/NodeGraphEditor.cs.meta | 12 --- Scripts/Editor/RenamePopup.cs.meta | 13 --- Scripts/Editor/Resources.meta | 9 -- Scripts/Editor/Resources/ScriptTemplates.meta | 10 -- .../xNode_NodeGraphTemplate.cs.txt.meta | 9 -- .../xNode_NodeTemplate.cs.txt.meta | 9 -- Scripts/Editor/Resources/xnode_dot.png.meta | 98 ------------------- .../Editor/Resources/xnode_dot_outer.png.meta | 98 ------------------- Scripts/Editor/Resources/xnode_node.png.meta | 98 ------------------- .../Resources/xnode_node_highlight.png.meta | 87 ---------------- .../Resources/xnode_node_workfile.psd.meta | 98 ------------------- Scripts/Editor/XNodeEditor.asmdef.meta | 7 -- Scripts/Node.cs.meta | 12 --- Scripts/NodeDataCache.cs.meta | 12 --- Scripts/NodeGraph.cs.meta | 12 --- Scripts/NodePort.cs.meta | 12 --- Scripts/XNode.asmdef.meta | 7 -- package.json.meta | 7 -- 44 files changed, 887 deletions(-) delete mode 100644 CONTRIBUTING.md.meta delete mode 100644 LICENSE.md.meta delete mode 100644 README.md.meta delete mode 100644 Scripts.meta delete mode 100644 Scripts/Attributes.meta delete mode 100644 Scripts/Attributes/NodeEnum.cs.meta delete mode 100644 Scripts/Editor.meta delete mode 100644 Scripts/Editor/Drawers.meta delete mode 100644 Scripts/Editor/Drawers/NodeEnumDrawer.cs.meta delete mode 100644 Scripts/Editor/Drawers/Odin.meta delete mode 100644 Scripts/Editor/Drawers/Odin/InNodeEditorAttributeProcessor.cs.meta delete mode 100644 Scripts/Editor/Drawers/Odin/InputAttributeDrawer.cs.meta delete mode 100644 Scripts/Editor/Drawers/Odin/OutputAttributeDrawer.cs.meta delete mode 100644 Scripts/Editor/Internal.meta delete mode 100644 Scripts/Editor/Internal/RerouteReference.cs.meta delete mode 100644 Scripts/Editor/NodeEditor.cs.meta delete mode 100644 Scripts/Editor/NodeEditorAction.cs.meta delete mode 100644 Scripts/Editor/NodeEditorAssetModProcessor.cs.meta delete mode 100644 Scripts/Editor/NodeEditorBase.cs.meta delete mode 100644 Scripts/Editor/NodeEditorGUI.cs.meta delete mode 100644 Scripts/Editor/NodeEditorGUILayout.cs.meta delete mode 100644 Scripts/Editor/NodeEditorPreferences.cs.meta delete mode 100644 Scripts/Editor/NodeEditorReflection.cs.meta delete mode 100644 Scripts/Editor/NodeEditorResources.cs.meta delete mode 100644 Scripts/Editor/NodeEditorUtilities.cs.meta delete mode 100644 Scripts/Editor/NodeEditorWindow.cs.meta delete mode 100644 Scripts/Editor/NodeGraphEditor.cs.meta delete mode 100644 Scripts/Editor/RenamePopup.cs.meta delete mode 100644 Scripts/Editor/Resources.meta delete mode 100644 Scripts/Editor/Resources/ScriptTemplates.meta delete mode 100644 Scripts/Editor/Resources/ScriptTemplates/xNode_NodeGraphTemplate.cs.txt.meta delete mode 100644 Scripts/Editor/Resources/ScriptTemplates/xNode_NodeTemplate.cs.txt.meta delete mode 100644 Scripts/Editor/Resources/xnode_dot.png.meta delete mode 100644 Scripts/Editor/Resources/xnode_dot_outer.png.meta delete mode 100644 Scripts/Editor/Resources/xnode_node.png.meta delete mode 100644 Scripts/Editor/Resources/xnode_node_highlight.png.meta delete mode 100644 Scripts/Editor/Resources/xnode_node_workfile.psd.meta delete mode 100644 Scripts/Editor/XNodeEditor.asmdef.meta delete mode 100644 Scripts/Node.cs.meta delete mode 100644 Scripts/NodeDataCache.cs.meta delete mode 100644 Scripts/NodeGraph.cs.meta delete mode 100644 Scripts/NodePort.cs.meta delete mode 100644 Scripts/XNode.asmdef.meta delete mode 100644 package.json.meta diff --git a/CONTRIBUTING.md.meta b/CONTRIBUTING.md.meta deleted file mode 100644 index 5d7c128..0000000 --- a/CONTRIBUTING.md.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: bc1db8b29c76d44648c9c86c2dfade6d -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/LICENSE.md.meta b/LICENSE.md.meta deleted file mode 100644 index 5f0a7c7..0000000 --- a/LICENSE.md.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 77523c356ccf04f56b53e6527c6b12fd -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/README.md.meta b/README.md.meta deleted file mode 100644 index dd3ed6f..0000000 --- a/README.md.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 243efae3a6b7941ad8f8e54dcf38ce8c -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Scripts.meta b/Scripts.meta deleted file mode 100644 index ab712b6..0000000 --- a/Scripts.meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: 657b15cb3ec32a24ca80faebf094d0f4 -folderAsset: yes -timeCreated: 1505418321 -licenseType: Free -DefaultImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Scripts/Attributes.meta b/Scripts/Attributes.meta deleted file mode 100644 index c0be849..0000000 --- a/Scripts/Attributes.meta +++ /dev/null @@ -1,10 +0,0 @@ -fileFormatVersion: 2 -guid: 5644dfc7eed151045af664a9d4fd1906 -folderAsset: yes -timeCreated: 1541633926 -licenseType: Free -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Scripts/Attributes/NodeEnum.cs.meta b/Scripts/Attributes/NodeEnum.cs.meta deleted file mode 100644 index 813a80b..0000000 --- a/Scripts/Attributes/NodeEnum.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: 10a8338f6c985854697b35459181af0a -timeCreated: 1541633942 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Scripts/Editor.meta b/Scripts/Editor.meta deleted file mode 100644 index b0ba142..0000000 --- a/Scripts/Editor.meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: 94d4fd78d9120634ebe0e8717610c412 -folderAsset: yes -timeCreated: 1505418345 -licenseType: Free -DefaultImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Scripts/Editor/Drawers.meta b/Scripts/Editor/Drawers.meta deleted file mode 100644 index b69e0ac..0000000 --- a/Scripts/Editor/Drawers.meta +++ /dev/null @@ -1,10 +0,0 @@ -fileFormatVersion: 2 -guid: 7adf21edfb51f514fa991d7556ecd0ef -folderAsset: yes -timeCreated: 1541971984 -licenseType: Free -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Scripts/Editor/Drawers/NodeEnumDrawer.cs.meta b/Scripts/Editor/Drawers/NodeEnumDrawer.cs.meta deleted file mode 100644 index beacf6b..0000000 --- a/Scripts/Editor/Drawers/NodeEnumDrawer.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: 83db81f92abadca439507e25d517cabe -timeCreated: 1541633798 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Scripts/Editor/Drawers/Odin.meta b/Scripts/Editor/Drawers/Odin.meta deleted file mode 100644 index c2b0ac9..0000000 --- a/Scripts/Editor/Drawers/Odin.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 327994a52f523b641898a39ff7500a02 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Scripts/Editor/Drawers/Odin/InNodeEditorAttributeProcessor.cs.meta b/Scripts/Editor/Drawers/Odin/InNodeEditorAttributeProcessor.cs.meta deleted file mode 100644 index 15f6990..0000000 --- a/Scripts/Editor/Drawers/Odin/InNodeEditorAttributeProcessor.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 3cf2561fbfea9a041ac81efbbb5b3e0d -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Scripts/Editor/Drawers/Odin/InputAttributeDrawer.cs.meta b/Scripts/Editor/Drawers/Odin/InputAttributeDrawer.cs.meta deleted file mode 100644 index 12b7615..0000000 --- a/Scripts/Editor/Drawers/Odin/InputAttributeDrawer.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 2fd590b2e9ea0bd49b6986a2ca9010ab -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Scripts/Editor/Drawers/Odin/OutputAttributeDrawer.cs.meta b/Scripts/Editor/Drawers/Odin/OutputAttributeDrawer.cs.meta deleted file mode 100644 index aa22218..0000000 --- a/Scripts/Editor/Drawers/Odin/OutputAttributeDrawer.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: e7ebd8f2b42e2384aa109551dc46af88 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Scripts/Editor/Internal.meta b/Scripts/Editor/Internal.meta deleted file mode 100644 index 600ad29..0000000 --- a/Scripts/Editor/Internal.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: a6a1bbc054e282346a02e7bbddde3206 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Scripts/Editor/Internal/RerouteReference.cs.meta b/Scripts/Editor/Internal/RerouteReference.cs.meta deleted file mode 100644 index 9a2f9cb..0000000 --- a/Scripts/Editor/Internal/RerouteReference.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 399f3c5fb717b2c458c3e9746f8959a3 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Scripts/Editor/NodeEditor.cs.meta b/Scripts/Editor/NodeEditor.cs.meta deleted file mode 100644 index db8651d..0000000 --- a/Scripts/Editor/NodeEditor.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 712c3fc5d9eeb4c45b1e23918df6018f -timeCreated: 1505462176 -licenseType: Free -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Scripts/Editor/NodeEditorAction.cs.meta b/Scripts/Editor/NodeEditorAction.cs.meta deleted file mode 100644 index a081bf7..0000000 --- a/Scripts/Editor/NodeEditorAction.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: aa7d4286bf0ad2e4086252f2893d2cf5 -timeCreated: 1505426655 -licenseType: Free -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Scripts/Editor/NodeEditorAssetModProcessor.cs.meta b/Scripts/Editor/NodeEditorAssetModProcessor.cs.meta deleted file mode 100644 index 057198b..0000000 --- a/Scripts/Editor/NodeEditorAssetModProcessor.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: e515e86efe8160243a68b7c06d730c9c -timeCreated: 1507982232 -licenseType: Free -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Scripts/Editor/NodeEditorBase.cs.meta b/Scripts/Editor/NodeEditorBase.cs.meta deleted file mode 100644 index 4ded02a..0000000 --- a/Scripts/Editor/NodeEditorBase.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: e85122ded59aceb4eb4b1bd9d9202642 -timeCreated: 1511353946 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Scripts/Editor/NodeEditorGUI.cs.meta b/Scripts/Editor/NodeEditorGUI.cs.meta deleted file mode 100644 index 543878b..0000000 --- a/Scripts/Editor/NodeEditorGUI.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 756276bfe9a0c2f4da3930ba1964f58d -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Scripts/Editor/NodeEditorGUILayout.cs.meta b/Scripts/Editor/NodeEditorGUILayout.cs.meta deleted file mode 100644 index 89596e2..0000000 --- a/Scripts/Editor/NodeEditorGUILayout.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 1d6c2d118d1c77948a23f2f4a34d1f64 -timeCreated: 1507966608 -licenseType: Free -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Scripts/Editor/NodeEditorPreferences.cs.meta b/Scripts/Editor/NodeEditorPreferences.cs.meta deleted file mode 100644 index 156543b..0000000 --- a/Scripts/Editor/NodeEditorPreferences.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 6b1f47e387a6f714c9f2ff82a6888c85 -timeCreated: 1507920216 -licenseType: Free -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Scripts/Editor/NodeEditorReflection.cs.meta b/Scripts/Editor/NodeEditorReflection.cs.meta deleted file mode 100644 index fe4ba9b..0000000 --- a/Scripts/Editor/NodeEditorReflection.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: c78a0fa4a13abcd408ebe73006b7b1bb -timeCreated: 1505419458 -licenseType: Free -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Scripts/Editor/NodeEditorResources.cs.meta b/Scripts/Editor/NodeEditorResources.cs.meta deleted file mode 100644 index 5e85895..0000000 --- a/Scripts/Editor/NodeEditorResources.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 69f55d341299026489b29443c3dd13d1 -timeCreated: 1505418919 -licenseType: Free -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Scripts/Editor/NodeEditorUtilities.cs.meta b/Scripts/Editor/NodeEditorUtilities.cs.meta deleted file mode 100644 index a8988ef..0000000 --- a/Scripts/Editor/NodeEditorUtilities.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 120960fe5b50aba418a8e8ad3c4c4bc8 -timeCreated: 1506073499 -licenseType: Free -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Scripts/Editor/NodeEditorWindow.cs.meta b/Scripts/Editor/NodeEditorWindow.cs.meta deleted file mode 100644 index 541b5c7..0000000 --- a/Scripts/Editor/NodeEditorWindow.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 5ce2bf59ec7a25c4ba691cad7819bf38 -timeCreated: 1505418450 -licenseType: Free -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Scripts/Editor/NodeGraphEditor.cs.meta b/Scripts/Editor/NodeGraphEditor.cs.meta deleted file mode 100644 index bc1c153..0000000 --- a/Scripts/Editor/NodeGraphEditor.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: ddcbb5432255d3247a0718b15a9c193c -timeCreated: 1505462176 -licenseType: Free -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Scripts/Editor/RenamePopup.cs.meta b/Scripts/Editor/RenamePopup.cs.meta deleted file mode 100644 index 5c40a02..0000000 --- a/Scripts/Editor/RenamePopup.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: 4ef3ddc25518318469bce838980c64be -timeCreated: 1552067957 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Scripts/Editor/Resources.meta b/Scripts/Editor/Resources.meta deleted file mode 100644 index 786ef41..0000000 --- a/Scripts/Editor/Resources.meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: 964fc201163fe884ca6a20094b6f3b49 -folderAsset: yes -timeCreated: 1506110871 -licenseType: Free -DefaultImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Scripts/Editor/Resources/ScriptTemplates.meta b/Scripts/Editor/Resources/ScriptTemplates.meta deleted file mode 100644 index b2435e8..0000000 --- a/Scripts/Editor/Resources/ScriptTemplates.meta +++ /dev/null @@ -1,10 +0,0 @@ -fileFormatVersion: 2 -guid: 86b677955452bb5449f9f4dd47b6ddfe -folderAsset: yes -timeCreated: 1519049391 -licenseType: Free -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Scripts/Editor/Resources/ScriptTemplates/xNode_NodeGraphTemplate.cs.txt.meta b/Scripts/Editor/Resources/ScriptTemplates/xNode_NodeGraphTemplate.cs.txt.meta deleted file mode 100644 index b55bd75..0000000 --- a/Scripts/Editor/Resources/ScriptTemplates/xNode_NodeGraphTemplate.cs.txt.meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: 8165767f64da7d94e925f61a38da668c -timeCreated: 1519049802 -licenseType: Free -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Scripts/Editor/Resources/ScriptTemplates/xNode_NodeTemplate.cs.txt.meta b/Scripts/Editor/Resources/ScriptTemplates/xNode_NodeTemplate.cs.txt.meta deleted file mode 100644 index 455420a..0000000 --- a/Scripts/Editor/Resources/ScriptTemplates/xNode_NodeTemplate.cs.txt.meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: 85f6f570600a1a44d8e734cb111a8b89 -timeCreated: 1519049802 -licenseType: Free -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Scripts/Editor/Resources/xnode_dot.png.meta b/Scripts/Editor/Resources/xnode_dot.png.meta deleted file mode 100644 index 00c23bc..0000000 --- a/Scripts/Editor/Resources/xnode_dot.png.meta +++ /dev/null @@ -1,98 +0,0 @@ -fileFormatVersion: 2 -guid: 75a1fe0b102226a418486ed823c9a7fb -timeCreated: 1506110357 -licenseType: Free -TextureImporter: - fileIDToRecycleName: {} - serializedVersion: 4 - mipmaps: - mipMapMode: 0 - enableMipMap: 0 - sRGBTexture: 0 - linearTexture: 0 - fadeOut: 0 - borderMipMap: 0 - mipMapsPreserveCoverage: 0 - alphaTestReferenceValue: 0.5 - mipMapFadeDistanceStart: 1 - mipMapFadeDistanceEnd: 3 - bumpmap: - convertToNormalMap: 0 - externalNormalMap: 0 - heightScale: 0.25 - normalMapFilter: 0 - isReadable: 0 - grayScaleToAlpha: 0 - generateCubemap: 6 - cubemapConvolution: 0 - seamlessCubemap: 0 - textureFormat: 1 - maxTextureSize: 2048 - textureSettings: - serializedVersion: 2 - filterMode: -1 - aniso: 1 - mipBias: -1 - wrapU: 1 - wrapV: -1 - wrapW: -1 - nPOTScale: 0 - lightmap: 0 - compressionQuality: 50 - spriteMode: 0 - spriteExtrude: 1 - spriteMeshType: 1 - alignment: 0 - spritePivot: {x: 0.5, y: 0.5} - spriteBorder: {x: 0, y: 0, z: 0, w: 0} - spritePixelsToUnits: 100 - alphaUsage: 1 - alphaIsTransparency: 1 - spriteTessellationDetail: -1 - textureType: 2 - textureShape: 1 - maxTextureSizeSet: 0 - compressionQualitySet: 0 - textureFormatSet: 0 - platformSettings: - - buildTarget: DefaultTexturePlatform - maxTextureSize: 2048 - textureFormat: -1 - textureCompression: 1 - compressionQuality: 50 - crunchedCompression: 0 - allowsAlphaSplitting: 0 - overridden: 0 - - buildTarget: Standalone - maxTextureSize: 2048 - textureFormat: -1 - textureCompression: 1 - compressionQuality: 50 - crunchedCompression: 0 - allowsAlphaSplitting: 0 - overridden: 0 - - buildTarget: Android - maxTextureSize: 2048 - textureFormat: -1 - textureCompression: 1 - compressionQuality: 50 - crunchedCompression: 0 - allowsAlphaSplitting: 0 - overridden: 0 - - buildTarget: WebGL - maxTextureSize: 2048 - textureFormat: -1 - textureCompression: 1 - compressionQuality: 50 - crunchedCompression: 0 - allowsAlphaSplitting: 0 - overridden: 0 - spriteSheet: - serializedVersion: 2 - sprites: [] - outline: [] - physicsShape: [] - spritePackingTag: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Scripts/Editor/Resources/xnode_dot_outer.png.meta b/Scripts/Editor/Resources/xnode_dot_outer.png.meta deleted file mode 100644 index 0781a52..0000000 --- a/Scripts/Editor/Resources/xnode_dot_outer.png.meta +++ /dev/null @@ -1,98 +0,0 @@ -fileFormatVersion: 2 -guid: 434ca8b4bdfa5574abb0002bbc9b65ad -timeCreated: 1506110357 -licenseType: Free -TextureImporter: - fileIDToRecycleName: {} - serializedVersion: 4 - mipmaps: - mipMapMode: 0 - enableMipMap: 0 - sRGBTexture: 0 - linearTexture: 0 - fadeOut: 0 - borderMipMap: 0 - mipMapsPreserveCoverage: 0 - alphaTestReferenceValue: 0.5 - mipMapFadeDistanceStart: 1 - mipMapFadeDistanceEnd: 3 - bumpmap: - convertToNormalMap: 0 - externalNormalMap: 0 - heightScale: 0.25 - normalMapFilter: 0 - isReadable: 0 - grayScaleToAlpha: 0 - generateCubemap: 6 - cubemapConvolution: 0 - seamlessCubemap: 0 - textureFormat: 1 - maxTextureSize: 2048 - textureSettings: - serializedVersion: 2 - filterMode: -1 - aniso: 1 - mipBias: -1 - wrapU: 1 - wrapV: -1 - wrapW: -1 - nPOTScale: 0 - lightmap: 0 - compressionQuality: 50 - spriteMode: 0 - spriteExtrude: 1 - spriteMeshType: 1 - alignment: 0 - spritePivot: {x: 0.5, y: 0.5} - spriteBorder: {x: 0, y: 0, z: 0, w: 0} - spritePixelsToUnits: 100 - alphaUsage: 1 - alphaIsTransparency: 1 - spriteTessellationDetail: -1 - textureType: 2 - textureShape: 1 - maxTextureSizeSet: 0 - compressionQualitySet: 0 - textureFormatSet: 0 - platformSettings: - - buildTarget: DefaultTexturePlatform - maxTextureSize: 2048 - textureFormat: -1 - textureCompression: 1 - compressionQuality: 50 - crunchedCompression: 0 - allowsAlphaSplitting: 0 - overridden: 0 - - buildTarget: Standalone - maxTextureSize: 2048 - textureFormat: -1 - textureCompression: 1 - compressionQuality: 50 - crunchedCompression: 0 - allowsAlphaSplitting: 0 - overridden: 0 - - buildTarget: Android - maxTextureSize: 2048 - textureFormat: -1 - textureCompression: 1 - compressionQuality: 50 - crunchedCompression: 0 - allowsAlphaSplitting: 0 - overridden: 0 - - buildTarget: WebGL - maxTextureSize: 2048 - textureFormat: -1 - textureCompression: 1 - compressionQuality: 50 - crunchedCompression: 0 - allowsAlphaSplitting: 0 - overridden: 0 - spriteSheet: - serializedVersion: 2 - sprites: [] - outline: [] - physicsShape: [] - spritePackingTag: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Scripts/Editor/Resources/xnode_node.png.meta b/Scripts/Editor/Resources/xnode_node.png.meta deleted file mode 100644 index 979e6f9..0000000 --- a/Scripts/Editor/Resources/xnode_node.png.meta +++ /dev/null @@ -1,98 +0,0 @@ -fileFormatVersion: 2 -guid: 2fea1dcb24935ef4ca514d534eb6aa3d -timeCreated: 1507454532 -licenseType: Free -TextureImporter: - fileIDToRecycleName: {} - serializedVersion: 4 - mipmaps: - mipMapMode: 0 - enableMipMap: 0 - sRGBTexture: 0 - linearTexture: 0 - fadeOut: 0 - borderMipMap: 0 - mipMapsPreserveCoverage: 0 - alphaTestReferenceValue: 0.5 - mipMapFadeDistanceStart: 1 - mipMapFadeDistanceEnd: 3 - bumpmap: - convertToNormalMap: 0 - externalNormalMap: 0 - heightScale: 0.25 - normalMapFilter: 0 - isReadable: 0 - grayScaleToAlpha: 0 - generateCubemap: 6 - cubemapConvolution: 0 - seamlessCubemap: 0 - textureFormat: 1 - maxTextureSize: 2048 - textureSettings: - serializedVersion: 2 - filterMode: -1 - aniso: 1 - mipBias: -1 - wrapU: 1 - wrapV: 1 - wrapW: 1 - nPOTScale: 0 - lightmap: 0 - compressionQuality: 50 - spriteMode: 0 - spriteExtrude: 1 - spriteMeshType: 1 - alignment: 0 - spritePivot: {x: 0.5, y: 0.5} - spriteBorder: {x: 0, y: 0, z: 0, w: 0} - spritePixelsToUnits: 100 - alphaUsage: 1 - alphaIsTransparency: 1 - spriteTessellationDetail: -1 - textureType: 2 - textureShape: 1 - maxTextureSizeSet: 0 - compressionQualitySet: 0 - textureFormatSet: 0 - platformSettings: - - buildTarget: DefaultTexturePlatform - maxTextureSize: 2048 - textureFormat: -1 - textureCompression: 1 - compressionQuality: 50 - crunchedCompression: 0 - allowsAlphaSplitting: 0 - overridden: 0 - - buildTarget: Standalone - maxTextureSize: 2048 - textureFormat: -1 - textureCompression: 1 - compressionQuality: 50 - crunchedCompression: 0 - allowsAlphaSplitting: 0 - overridden: 0 - - buildTarget: Android - maxTextureSize: 2048 - textureFormat: -1 - textureCompression: 1 - compressionQuality: 50 - crunchedCompression: 0 - allowsAlphaSplitting: 0 - overridden: 0 - - buildTarget: WebGL - maxTextureSize: 2048 - textureFormat: -1 - textureCompression: 1 - compressionQuality: 50 - crunchedCompression: 0 - allowsAlphaSplitting: 0 - overridden: 0 - spriteSheet: - serializedVersion: 2 - sprites: [] - outline: [] - physicsShape: [] - spritePackingTag: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Scripts/Editor/Resources/xnode_node_highlight.png.meta b/Scripts/Editor/Resources/xnode_node_highlight.png.meta deleted file mode 100644 index 21b6034..0000000 --- a/Scripts/Editor/Resources/xnode_node_highlight.png.meta +++ /dev/null @@ -1,87 +0,0 @@ -fileFormatVersion: 2 -guid: 2ab2b92d7e1771b47bba0a46a6f0f6d5 -timeCreated: 1516610730 -licenseType: Free -TextureImporter: - fileIDToRecycleName: {} - externalObjects: {} - serializedVersion: 4 - mipmaps: - mipMapMode: 0 - enableMipMap: 0 - sRGBTexture: 0 - linearTexture: 0 - fadeOut: 0 - borderMipMap: 0 - mipMapsPreserveCoverage: 0 - alphaTestReferenceValue: 0.5 - mipMapFadeDistanceStart: 1 - mipMapFadeDistanceEnd: 3 - bumpmap: - convertToNormalMap: 0 - externalNormalMap: 0 - heightScale: 0.25 - normalMapFilter: 0 - isReadable: 0 - grayScaleToAlpha: 0 - generateCubemap: 6 - cubemapConvolution: 0 - seamlessCubemap: 0 - textureFormat: 1 - maxTextureSize: 2048 - textureSettings: - serializedVersion: 2 - filterMode: -1 - aniso: 1 - mipBias: -1 - wrapU: 1 - wrapV: 1 - wrapW: -1 - nPOTScale: 0 - lightmap: 0 - compressionQuality: 50 - spriteMode: 0 - spriteExtrude: 1 - spriteMeshType: 1 - alignment: 0 - spritePivot: {x: 0.5, y: 0.5} - spriteBorder: {x: 0, y: 0, z: 0, w: 0} - spritePixelsToUnits: 100 - alphaUsage: 1 - alphaIsTransparency: 1 - spriteTessellationDetail: -1 - textureType: 2 - textureShape: 1 - maxTextureSizeSet: 0 - compressionQualitySet: 0 - textureFormatSet: 0 - platformSettings: - - buildTarget: DefaultTexturePlatform - maxTextureSize: 2048 - resizeAlgorithm: 0 - textureFormat: -1 - textureCompression: 1 - compressionQuality: 50 - crunchedCompression: 0 - allowsAlphaSplitting: 0 - overridden: 0 - androidETC2FallbackOverride: 0 - - buildTarget: Standalone - maxTextureSize: 2048 - resizeAlgorithm: 0 - textureFormat: -1 - textureCompression: 1 - compressionQuality: 50 - crunchedCompression: 0 - allowsAlphaSplitting: 0 - overridden: 0 - androidETC2FallbackOverride: 0 - spriteSheet: - serializedVersion: 2 - sprites: [] - outline: [] - physicsShape: [] - spritePackingTag: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Scripts/Editor/Resources/xnode_node_workfile.psd.meta b/Scripts/Editor/Resources/xnode_node_workfile.psd.meta deleted file mode 100644 index 3ca0437..0000000 --- a/Scripts/Editor/Resources/xnode_node_workfile.psd.meta +++ /dev/null @@ -1,98 +0,0 @@ -fileFormatVersion: 2 -guid: 2267efa6e1e349348ae0b28fb659a6e2 -timeCreated: 1507454532 -licenseType: Free -TextureImporter: - fileIDToRecycleName: {} - serializedVersion: 4 - mipmaps: - mipMapMode: 0 - enableMipMap: 0 - sRGBTexture: 0 - linearTexture: 0 - fadeOut: 0 - borderMipMap: 0 - mipMapsPreserveCoverage: 0 - alphaTestReferenceValue: 0.5 - mipMapFadeDistanceStart: 1 - mipMapFadeDistanceEnd: 3 - bumpmap: - convertToNormalMap: 0 - externalNormalMap: 0 - heightScale: 0.25 - normalMapFilter: 0 - isReadable: 0 - grayScaleToAlpha: 0 - generateCubemap: 6 - cubemapConvolution: 0 - seamlessCubemap: 0 - textureFormat: 1 - maxTextureSize: 2048 - textureSettings: - serializedVersion: 2 - filterMode: -1 - aniso: 1 - mipBias: -1 - wrapU: 1 - wrapV: -1 - wrapW: -1 - nPOTScale: 0 - lightmap: 0 - compressionQuality: 50 - spriteMode: 0 - spriteExtrude: 1 - spriteMeshType: 1 - alignment: 0 - spritePivot: {x: 0.5, y: 0.5} - spriteBorder: {x: 0, y: 0, z: 0, w: 0} - spritePixelsToUnits: 100 - alphaUsage: 1 - alphaIsTransparency: 1 - spriteTessellationDetail: -1 - textureType: 2 - textureShape: 1 - maxTextureSizeSet: 0 - compressionQualitySet: 0 - textureFormatSet: 0 - platformSettings: - - buildTarget: DefaultTexturePlatform - maxTextureSize: 2048 - textureFormat: -1 - textureCompression: 1 - compressionQuality: 50 - crunchedCompression: 0 - allowsAlphaSplitting: 0 - overridden: 0 - - buildTarget: Standalone - maxTextureSize: 2048 - textureFormat: -1 - textureCompression: 1 - compressionQuality: 50 - crunchedCompression: 0 - allowsAlphaSplitting: 0 - overridden: 0 - - buildTarget: Android - maxTextureSize: 2048 - textureFormat: -1 - textureCompression: 1 - compressionQuality: 50 - crunchedCompression: 0 - allowsAlphaSplitting: 0 - overridden: 0 - - buildTarget: WebGL - maxTextureSize: 2048 - textureFormat: -1 - textureCompression: 1 - compressionQuality: 50 - crunchedCompression: 0 - allowsAlphaSplitting: 0 - overridden: 0 - spriteSheet: - serializedVersion: 2 - sprites: [] - outline: [] - physicsShape: [] - spritePackingTag: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Scripts/Editor/XNodeEditor.asmdef.meta b/Scripts/Editor/XNodeEditor.asmdef.meta deleted file mode 100644 index 7bff074..0000000 --- a/Scripts/Editor/XNodeEditor.asmdef.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 002c1bbed08fa44d282ef34fd5edb138 -AssemblyDefinitionImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Scripts/Node.cs.meta b/Scripts/Node.cs.meta deleted file mode 100644 index a267e40..0000000 --- a/Scripts/Node.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: f26231e5ab9368746948d0ea49e8178a -timeCreated: 1505419984 -licenseType: Free -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Scripts/NodeDataCache.cs.meta b/Scripts/NodeDataCache.cs.meta deleted file mode 100644 index 34482f2..0000000 --- a/Scripts/NodeDataCache.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 64ea6af1e195d024d8df0ead1921e517 -timeCreated: 1507566823 -licenseType: Free -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Scripts/NodeGraph.cs.meta b/Scripts/NodeGraph.cs.meta deleted file mode 100644 index b2e1264..0000000 --- a/Scripts/NodeGraph.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 093f68ef2455d544fa2d14b80c811322 -timeCreated: 1505461376 -licenseType: Free -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Scripts/NodePort.cs.meta b/Scripts/NodePort.cs.meta deleted file mode 100644 index 3863705..0000000 --- a/Scripts/NodePort.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 7dd2f76ac25c6f44c9426dff3e7491a3 -timeCreated: 1505734054 -licenseType: Free -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Scripts/XNode.asmdef.meta b/Scripts/XNode.asmdef.meta deleted file mode 100644 index 8479d75..0000000 --- a/Scripts/XNode.asmdef.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: b8e24fd1eb19b4226afebb2810e3c19b -AssemblyDefinitionImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/package.json.meta b/package.json.meta deleted file mode 100644 index c8f1dc4..0000000 --- a/package.json.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: e9869d68f06b74538a01e9b8e406159e -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: From 3a1b59480fd1d9296f448ac7600a0da9f4c34d10 Mon Sep 17 00:00:00 2001 From: Icarus <1375400884@qq.com> Date: Sun, 22 Sep 2019 17:35:17 +0800 Subject: [PATCH 06/65] =?UTF-8?q?!W=20Input=E6=96=B0=E5=A2=9E=E4=BA=86?= =?UTF-8?q?=E4=B8=80=E4=B8=AABaseType=E5=BE=97=E6=8C=87=E5=AE=9A,=E5=BD=93?= =?UTF-8?q?`TypeConstraint`=E4=B8=BATypeConstraint.Inherited=E6=97=B6?= =?UTF-8?q?=E5=8F=AF=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Scripts/Editor/NodeEditorGUILayout.cs | 17 ++++++------ Scripts/Node.cs | 17 +++++++----- Scripts/NodeDataCache.cs | 7 ++++- Scripts/NodePort.cs | 38 ++++++++++++++++++++++++--- 4 files changed, 60 insertions(+), 19 deletions(-) diff --git a/Scripts/Editor/NodeEditorGUILayout.cs b/Scripts/Editor/NodeEditorGUILayout.cs index ec93cc1..6648c2d 100644 --- a/Scripts/Editor/NodeEditorGUILayout.cs +++ b/Scripts/Editor/NodeEditorGUILayout.cs @@ -254,8 +254,8 @@ namespace XNodeEditor { } [Obsolete("Use DynamicPortList instead")] - public static void InstancePortList(string fieldName, Type type, SerializedObject serializedObject, XNode.NodePort.IO io, XNode.Node.ConnectionType connectionType = XNode.Node.ConnectionType.Multiple, XNode.Node.TypeConstraint typeConstraint = XNode.Node.TypeConstraint.None, Action onCreation = null) { - DynamicPortList(fieldName, type, serializedObject, io, connectionType, typeConstraint, onCreation); + public static void InstancePortList(string fieldName, Type type, SerializedObject serializedObject, XNode.NodePort.IO io, XNode.Node.ConnectionType connectionType = XNode.Node.ConnectionType.Multiple, XNode.Node.TypeConstraint typeConstraint = XNode.Node.TypeConstraint.None,Type inputTypeConstraintBaseType = null, Action onCreation = null) { + DynamicPortList(fieldName, type, serializedObject, io, connectionType, typeConstraint, inputTypeConstraintBaseType,onCreation); } #endregion @@ -276,8 +276,9 @@ namespace XNodeEditor { /// Value type of added dynamic ports /// The serializedObject of the node /// Connection type of added dynamic ports + /// 并且时可用 /// Called on the list on creation. Use this if you want to customize the created ReorderableList - public static void DynamicPortList(string fieldName, Type type, SerializedObject serializedObject, XNode.NodePort.IO io, XNode.Node.ConnectionType connectionType = XNode.Node.ConnectionType.Multiple, XNode.Node.TypeConstraint typeConstraint = XNode.Node.TypeConstraint.None, Action onCreation = null) { + public static void DynamicPortList(string fieldName, Type type, SerializedObject serializedObject, XNode.NodePort.IO io, XNode.Node.ConnectionType connectionType = XNode.Node.ConnectionType.Multiple, XNode.Node.TypeConstraint typeConstraint = XNode.Node.TypeConstraint.None,Type inputTypeConstraintBaseType = null, Action onCreation = null) { XNode.Node node = serializedObject.targetObject as XNode.Node; var indexedPorts = node.DynamicPorts.Select(x => { @@ -300,7 +301,7 @@ namespace XNodeEditor { // If a ReorderableList isn't cached for this array, do so. if (list == null) { SerializedProperty arrayData = serializedObject.FindProperty(fieldName); - list = CreateReorderableList(fieldName, dynamicPorts, arrayData, type, serializedObject, io, connectionType, typeConstraint, onCreation); + list = CreateReorderableList(fieldName, dynamicPorts, arrayData, type, serializedObject, io, connectionType, typeConstraint, inputTypeConstraintBaseType,onCreation); if (reorderableListCache.TryGetValue(serializedObject.targetObject, out rlc)) rlc.Add(fieldName, list); else reorderableListCache.Add(serializedObject.targetObject, new Dictionary() { { fieldName, list } }); } @@ -308,7 +309,7 @@ namespace XNodeEditor { list.DoLayoutList(); } - private static ReorderableList CreateReorderableList(string fieldName, List dynamicPorts, SerializedProperty arrayData, Type type, SerializedObject serializedObject, XNode.NodePort.IO io, XNode.Node.ConnectionType connectionType, XNode.Node.TypeConstraint typeConstraint, Action onCreation) { + private static ReorderableList CreateReorderableList(string fieldName, List dynamicPorts, SerializedProperty arrayData, Type type, SerializedObject serializedObject, XNode.NodePort.IO io, XNode.Node.ConnectionType connectionType, XNode.Node.TypeConstraint typeConstraint,Type inputTypeConstraintBaseType, Action onCreation) { bool hasArrayData = arrayData != null && arrayData.isArray; XNode.Node node = serializedObject.targetObject as XNode.Node; ReorderableList list = new ReorderableList(dynamicPorts, null, true, true, true, true); @@ -398,7 +399,7 @@ namespace XNodeEditor { while (node.HasPort(newName)) newName = fieldName + " " + (++i); if (io == XNode.NodePort.IO.Output) node.AddDynamicOutput(type, connectionType, XNode.Node.TypeConstraint.None, newName); - else node.AddDynamicInput(type, connectionType, typeConstraint, newName); + else node.AddDynamicInput(type, connectionType, typeConstraint,inputTypeConstraintBaseType, newName); serializedObject.Update(); EditorUtility.SetDirty(node); if (hasArrayData) { @@ -471,8 +472,8 @@ namespace XNodeEditor { string newName = arrayData.name + " 0"; int i = 0; while (node.HasPort(newName)) newName = arrayData.name + " " + (++i); - if (io == XNode.NodePort.IO.Output) node.AddDynamicOutput(type, connectionType, typeConstraint, newName); - else node.AddDynamicInput(type, connectionType, typeConstraint, newName); + if (io == XNode.NodePort.IO.Output) node.AddDynamicOutput(type, connectionType, typeConstraint,newName); + else node.AddDynamicInput(type, connectionType, typeConstraint, inputTypeConstraintBaseType,newName); EditorUtility.SetDirty(node); dynamicPortCount++; } diff --git a/Scripts/Node.cs b/Scripts/Node.cs index 27e32c7..7fbf4c1 100644 --- a/Scripts/Node.cs +++ b/Scripts/Node.cs @@ -73,7 +73,7 @@ namespace XNode { [Obsolete("Use AddDynamicPort instead")] private NodePort AddInstancePort(Type type, NodePort.IO direction, Node.ConnectionType connectionType = Node.ConnectionType.Multiple, Node.TypeConstraint typeConstraint = TypeConstraint.None, string fieldName = null) { - return AddDynamicPort(type, direction, connectionType, typeConstraint, fieldName); + return AddDynamicPort(type, direction, connectionType, typeConstraint, null,fieldName); } [Obsolete("Use RemoveDynamicPort instead")] @@ -138,21 +138,21 @@ namespace XNode { /// Convenience function. /// /// - public NodePort AddDynamicInput(Type type, Node.ConnectionType connectionType = Node.ConnectionType.Multiple, Node.TypeConstraint typeConstraint = TypeConstraint.None, string fieldName = null) { - return AddDynamicPort(type, NodePort.IO.Input, connectionType, typeConstraint, fieldName); + public NodePort AddDynamicInput(Type type, Node.ConnectionType connectionType = Node.ConnectionType.Multiple, Node.TypeConstraint typeConstraint = TypeConstraint.None,Type baseType = null, string fieldName = null) { + return AddDynamicPort(type, NodePort.IO.Input, connectionType, typeConstraint,baseType, fieldName); } /// Convenience function. /// /// public NodePort AddDynamicOutput(Type type, Node.ConnectionType connectionType = Node.ConnectionType.Multiple, Node.TypeConstraint typeConstraint = TypeConstraint.None, string fieldName = null) { - return AddDynamicPort(type, NodePort.IO.Output, connectionType, typeConstraint, fieldName); + return AddDynamicPort(type, NodePort.IO.Output, connectionType, typeConstraint, null,fieldName); } /// Add a dynamic, serialized port to this node. /// /// - private NodePort AddDynamicPort(Type type, NodePort.IO direction, Node.ConnectionType connectionType = Node.ConnectionType.Multiple, Node.TypeConstraint typeConstraint = TypeConstraint.None, string fieldName = null) { + private NodePort AddDynamicPort(Type type, NodePort.IO direction, Node.ConnectionType connectionType = Node.ConnectionType.Multiple, Node.TypeConstraint typeConstraint = TypeConstraint.None,Type baseType = null, string fieldName = null) { if (fieldName == null) { fieldName = "dynamicInput_0"; int i = 0; @@ -161,7 +161,7 @@ namespace XNode { Debug.LogWarning("Port '" + fieldName + "' already exists in " + name, this); return ports[fieldName]; } - NodePort port = new NodePort(fieldName, type, direction, connectionType, typeConstraint, this); + NodePort port = new NodePort(fieldName, type, direction, connectionType, typeConstraint,baseType, this); ports.Add(fieldName, port); return port; } @@ -268,17 +268,20 @@ namespace XNode { public bool instancePortList { get { return dynamicPortList; } set { dynamicPortList = value; } } public bool dynamicPortList; public TypeConstraint typeConstraint; + public Type BaseType { get; } /// Mark a serializable field as an input port. You can access this through + /// 指定更准确的父类类型,只有当参数为才可用 /// Should we display the backing value for this port as an editor field? /// Should we allow multiple connections? /// Constrains which input connections can be made to this port /// If true, will display a reorderable list of inputs instead of a single port. Will automatically add and display values for lists and arrays - public InputAttribute(ShowBackingValue backingValue = ShowBackingValue.Unconnected, ConnectionType connectionType = ConnectionType.Multiple, TypeConstraint typeConstraint = TypeConstraint.None, bool dynamicPortList = false) { + public InputAttribute(ShowBackingValue backingValue = ShowBackingValue.Unconnected, ConnectionType connectionType = ConnectionType.Multiple, TypeConstraint typeConstraint = TypeConstraint.None,Type baseType = null, bool dynamicPortList = false) { this.backingValue = backingValue; this.connectionType = connectionType; this.dynamicPortList = dynamicPortList; this.typeConstraint = typeConstraint; + BaseType = baseType; } } diff --git a/Scripts/NodeDataCache.cs b/Scripts/NodeDataCache.cs index 886f128..5ea5c5a 100644 --- a/Scripts/NodeDataCache.cs +++ b/Scripts/NodeDataCache.cs @@ -36,7 +36,12 @@ namespace XNode { if (!port.IsDynamic && port.direction == staticPort.direction) removedPorts.Add(port.fieldName, port.GetConnections()); port.ClearConnections(); ports.Remove(port.fieldName); - } else port.ValueType = staticPort.ValueType; + } + else + { + port.ValueType = staticPort.ValueType; + port.TypeConstraintBaseType = staticPort.TypeConstraintBaseType; + } } // If port doesn't exist anymore, remove it else if (port.IsStatic) { diff --git a/Scripts/NodePort.cs b/Scripts/NodePort.cs index 1000b23..5b62296 100644 --- a/Scripts/NodePort.cs +++ b/Scripts/NodePort.cs @@ -42,11 +42,28 @@ namespace XNode { if (value != null) _typeQualifiedName = value.AssemblyQualifiedName; } } + + public Type TypeConstraintBaseType { + get { + if (_typeConstraintBaseType == null && !string.IsNullOrEmpty(_typeConstraintBaseTypeQualifiedName)) + _typeConstraintBaseType = Type.GetType(_typeConstraintBaseTypeQualifiedName, false); + return _typeConstraintBaseType; + } + set { + _typeConstraintBaseType = value; + if (value != null) + { + _typeConstraintBaseTypeQualifiedName = value.AssemblyQualifiedName; + } + } + } + private Type valueType; - + private Type _typeConstraintBaseType; [SerializeField] private string _fieldName; [SerializeField] private Node _node; [SerializeField] private string _typeQualifiedName; + [SerializeField] private string _typeConstraintBaseTypeQualifiedName; [SerializeField] private List connections = new List(); [SerializeField] private IO _direction; [SerializeField] private Node.ConnectionType _connectionType; @@ -64,6 +81,7 @@ namespace XNode { _direction = IO.Input; _connectionType = (attribs[i] as Node.InputAttribute).connectionType; _typeConstraint = (attribs[i] as Node.InputAttribute).typeConstraint; + TypeConstraintBaseType = (attribs[i] as Node.InputAttribute).BaseType; } else if (attribs[i] is Node.OutputAttribute) { _direction = IO.Output; _connectionType = (attribs[i] as Node.OutputAttribute).connectionType; @@ -84,9 +102,10 @@ namespace XNode { } /// Construct a dynamic port. Dynamic ports are not forgotten on reimport, and is ideal for runtime-created ports. - public NodePort(string fieldName, Type type, IO direction, Node.ConnectionType connectionType, Node.TypeConstraint typeConstraint, Node node) { + public NodePort(string fieldName, Type type, IO direction, Node.ConnectionType connectionType, Node.TypeConstraint typeConstraint,Type baseType, Node node) { _fieldName = fieldName; this.ValueType = type; + TypeConstraintBaseType = baseType; _direction = direction; _node = node; _dynamic = true; @@ -257,7 +276,20 @@ namespace XNode { // If there isn't one of each, they can't connect if (input == null || output == null) return false; // Check input type constraints - if (input.typeConstraint == XNode.Node.TypeConstraint.Inherited && !input.ValueType.IsAssignableFrom(output.ValueType)) return false; + if (input.typeConstraint == XNode.Node.TypeConstraint.Inherited) + { + //无法分配,失败 + if (!input.ValueType.IsAssignableFrom(output.ValueType)) + { + return false; + } + + //如果存在指定基类,同时无法分配,失败 + if (input.TypeConstraintBaseType != null && !input.TypeConstraintBaseType.IsAssignableFrom(output.ValueType)) + { + return false; + } + } if (input.typeConstraint == XNode.Node.TypeConstraint.Strict && input.ValueType != output.ValueType) return false; // Check output type constraints if (output.typeConstraint == XNode.Node.TypeConstraint.Inherited && !output.ValueType.IsAssignableFrom(input.ValueType)) return false; From 3134dc12d8c9b0e2ffd6c4c14bbf22a7a95277c0 Mon Sep 17 00:00:00 2001 From: Icarus <1375400884@qq.com> Date: Mon, 23 Sep 2019 01:13:56 +0800 Subject: [PATCH 07/65] =?UTF-8?q?!B=20=E8=8A=82=E7=82=B9=E5=88=9B=E5=BB=BA?= =?UTF-8?q?=E6=97=B6=E6=B2=A1=E6=9C=89=E8=AE=BE=E7=BD=AEInput=E7=9A=84Type?= =?UTF-8?q?ConstraintBaseType?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Scripts/NodePort.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Scripts/NodePort.cs b/Scripts/NodePort.cs index 5b62296..dc69313 100644 --- a/Scripts/NodePort.cs +++ b/Scripts/NodePort.cs @@ -94,6 +94,7 @@ namespace XNode { public NodePort(NodePort nodePort, Node node) { _fieldName = nodePort._fieldName; ValueType = nodePort.valueType; + TypeConstraintBaseType = nodePort.TypeConstraintBaseType; _direction = nodePort.direction; _dynamic = nodePort._dynamic; _connectionType = nodePort._connectionType; From 354f7d10d8f484d3e74308eda32a1a9ac90fe3e2 Mon Sep 17 00:00:00 2001 From: Icarus <1375400884@qq.com> Date: Tue, 24 Sep 2019 13:49:26 +0800 Subject: [PATCH 08/65] =?UTF-8?q?!W=20=E6=96=B0=E5=A2=9E=E4=BA=86=E4=B8=80?= =?UTF-8?q?=E4=B8=AA=E8=8E=B7=E5=8F=96=E5=BD=93=E5=89=8D=E8=8A=82=E7=82=B9?= =?UTF-8?q?=E9=BC=A0=E6=A0=87=E5=9C=A8Group=E4=B8=AD=E7=9A=84=E5=9D=90?= =?UTF-8?q?=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Scripts/Editor/NodeEditor.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Scripts/Editor/NodeEditor.cs b/Scripts/Editor/NodeEditor.cs index 8d293ab..c923984 100644 --- a/Scripts/Editor/NodeEditor.cs +++ b/Scripts/Editor/NodeEditor.cs @@ -89,6 +89,13 @@ namespace XNodeEditor { else return 208; } + public Vector2 GetCurrentMousePosition() + { + var pos = this.target.position + Event.current.mousePosition; + pos.x = pos.x - target.position.x; + return pos; + } + /// Returns color for target node public virtual Color GetTint() { // Try get color from [NodeTint] attribute From 38df17b58b29e33e9d1d06156bcd0784bd22024d Mon Sep 17 00:00:00 2001 From: Icarus <1375400884@qq.com> Date: Tue, 24 Sep 2019 13:50:04 +0800 Subject: [PATCH 09/65] =?UTF-8?q?!W=20=E7=BB=98=E5=88=B6=E4=B8=8D=E5=8F=AF?= =?UTF-8?q?=E8=A2=ABunity=E5=BA=8F=E5=88=97=E5=8C=96=E7=9A=84=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E7=AB=AF=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Scripts/Editor/NodeEditor.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Scripts/Editor/NodeEditor.cs b/Scripts/Editor/NodeEditor.cs index c923984..71529ff 100644 --- a/Scripts/Editor/NodeEditor.cs +++ b/Scripts/Editor/NodeEditor.cs @@ -52,10 +52,28 @@ namespace XNodeEditor { SerializedProperty iterator = serializedObject.GetIterator(); bool enterChildren = true; EditorGUIUtility.labelWidth = 84; + List _names = new List(); while (iterator.NextVisible(enterChildren)) { enterChildren = false; if (excludes.Contains(iterator.name)) continue; NodeEditorGUILayout.PropertyField(iterator, true); + _names.Add(iterator.name); + } + + //处理一下没被绘制的端口 + foreach (var port in target.Ports) + { + //动态的跳过 + if (port.IsDynamic) + { + continue; + } + + //不受unity序列化支持,但是被标记为了输入或输出 + if (!_names.Contains(port.fieldName)) + { + NodeEditorGUILayout.PortField(port); + } } #endif From 0602d3fccf206cc60b9244894b5e76f7744b67fa Mon Sep 17 00:00:00 2001 From: Icarus <1375400884@qq.com> Date: Tue, 24 Sep 2019 18:16:02 +0800 Subject: [PATCH 10/65] =?UTF-8?q?!W=20=E5=8A=A8=E6=80=81Port=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E4=BA=86=E4=B8=80=E4=B8=AA=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Scripts/Editor/NodeEditorGUI.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Scripts/Editor/NodeEditorGUI.cs b/Scripts/Editor/NodeEditorGUI.cs index 6546f6f..29df4cd 100644 --- a/Scripts/Editor/NodeEditorGUI.cs +++ b/Scripts/Editor/NodeEditorGUI.cs @@ -112,6 +112,10 @@ namespace XNodeEditor { void ShowPortContextMenu(XNode.NodePort hoveredPort) { GenericMenu contextMenu = new GenericMenu(); contextMenu.AddItem(new GUIContent("Clear Connections"), false, () => hoveredPort.ClearConnections()); + if (hoveredPort.IsDynamic) + { + contextMenu.AddItem(new GUIContent("Remove"), false, () => hoveredPort.node.RemoveDynamicPort(hoveredPort)); + } contextMenu.DropDown(new Rect(Event.current.mousePosition, Vector2.zero)); if (NodeEditorPreferences.GetSettings().autoSave) AssetDatabase.SaveAssets(); } 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 11/65] =?UTF-8?q?!OW=20=E8=AE=A9=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E8=80=85=E5=8F=AF=E4=BB=A5=E8=87=AA=E5=AE=9A=E4=B9=89=E4=B8=8D?= =?UTF-8?q?=E9=9C=80=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); } From 25514fce96811b217e7306b37e841c7d4f8d14aa Mon Sep 17 00:00:00 2001 From: Icarus <1375400884@qq.com> Date: Wed, 25 Sep 2019 16:58:59 +0800 Subject: [PATCH 12/65] =?UTF-8?q?!B=20Group=20=E7=A9=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Scripts/Editor/NodeEditorAssetModProcessor.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Scripts/Editor/NodeEditorAssetModProcessor.cs b/Scripts/Editor/NodeEditorAssetModProcessor.cs index edaebaa..9482bb5 100644 --- a/Scripts/Editor/NodeEditorAssetModProcessor.cs +++ b/Scripts/Editor/NodeEditorAssetModProcessor.cs @@ -48,7 +48,11 @@ namespace XNodeEditor { for (int i = 0; i < guids.Length; i++) { string assetpath = AssetDatabase.GUIDToAssetPath (guids[i]); XNode.NodeGraph graph = AssetDatabase.LoadAssetAtPath (assetpath, typeof (XNode.NodeGraph)) as XNode.NodeGraph; - graph.nodes.RemoveAll(x => x == null); //Remove null items + if (!graph) + { + return; + } + graph.nodes.RemoveAll(x => !x); //Remove null items Object[] objs = AssetDatabase.LoadAllAssetRepresentationsAtPath (assetpath); // Ensure that all sub node assets are present in the graph node list for (int u = 0; u < objs.Length; u++) { From 7c3c106eeb964df7a10b59b1fb97a464ede5dd5f Mon Sep 17 00:00:00 2001 From: Icarus <1375400884@qq.com> Date: Wed, 25 Sep 2019 16:59:43 +0800 Subject: [PATCH 13/65] =?UTF-8?q?!W=20=E5=8A=A0=E4=BA=86=E4=B8=80=E4=B8=AA?= =?UTF-8?q?=E5=88=9B=E5=BB=BA=E5=BD=93=E5=89=8DGroup=E6=89=80=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E7=9A=84=E6=89=80=E6=9C=89=E8=8A=82=E7=82=B9=E5=8A=9F?= =?UTF-8?q?=E8=83=BD,=E7=94=A8=E4=BA=8E=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Scripts/Editor/NodeGraphEditor.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Scripts/Editor/NodeGraphEditor.cs b/Scripts/Editor/NodeGraphEditor.cs index bdd4fa0..7b706fa 100644 --- a/Scripts/Editor/NodeGraphEditor.cs +++ b/Scripts/Editor/NodeGraphEditor.cs @@ -60,6 +60,24 @@ namespace XNodeEditor { if (NodeEditorWindow.copyBuffer != null && NodeEditorWindow.copyBuffer.Length > 0) menu.AddItem(new GUIContent("Paste"), false, () => NodeEditorWindow.current.PasteNodes(pos)); else menu.AddDisabledItem(new GUIContent("Paste")); menu.AddItem(new GUIContent("Preferences"), false, () => NodeEditorReflection.OpenPreferences()); + menu.AddItem(new GUIContent("创建所有的节点 ---> 测试用"), false, () => + { + for (int i = 0; i < NodeEditorReflection.nodeTypes.Length; i++) + { + Type type = NodeEditorReflection.nodeTypes[i]; + + //Get node context menu path + string path = GetNodeMenuName(type); + //当前Group 不支持该节点跳过 + if (string.IsNullOrEmpty(path)) + { + continue; + } + + XNode.Node node = CreateNode(type, pos); + NodeEditorWindow.current.AutoConnect(node); + } + }); menu.AddCustomContextMenuItems(target); } From 9be869f3b2519beea86719291d12756a95193c6c Mon Sep 17 00:00:00 2001 From: Icarus <1375400884@qq.com> Date: Wed, 25 Sep 2019 18:22:12 +0800 Subject: [PATCH 14/65] =?UTF-8?q?!B=20=E5=9D=90=E6=A0=87=E8=AE=A1=E7=AE=97?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Scripts/Editor/NodeEditor.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Scripts/Editor/NodeEditor.cs b/Scripts/Editor/NodeEditor.cs index efa0fcc..bdbbb86 100644 --- a/Scripts/Editor/NodeEditor.cs +++ b/Scripts/Editor/NodeEditor.cs @@ -129,11 +129,9 @@ namespace XNodeEditor { else return 208; } - public Vector2 GetCurrentMousePosition() + public Vector2 GetCurrentMousePosition(float yOffset = 10) { - var pos = this.target.position + Event.current.mousePosition; - pos.x = pos.x - target.position.x; - return pos; + return new Vector2(Event.current.mousePosition.x,Event.current.mousePosition.y + yOffset); } /// Returns color for target node From 40db69af1ec2a37f04fc12ab54c04779a8d07bed Mon Sep 17 00:00:00 2001 From: Icarus <1375400884@qq.com> Date: Wed, 25 Sep 2019 20:26:15 +0800 Subject: [PATCH 15/65] =?UTF-8?q?!T=20=E5=9B=9E=E6=BB=9A=E7=BB=98=E5=88=B6?= =?UTF-8?q?=E9=A1=BA=E5=BA=8F,=E5=A4=AA=E9=9A=BE=E7=9C=8B=E4=BA=86,?= =?UTF-8?q?=E5=93=88=E5=93=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Scripts/Editor/NodeEditorGUI.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Scripts/Editor/NodeEditorGUI.cs b/Scripts/Editor/NodeEditorGUI.cs index 29df4cd..3555023 100644 --- a/Scripts/Editor/NodeEditorGUI.cs +++ b/Scripts/Editor/NodeEditorGUI.cs @@ -25,8 +25,8 @@ namespace XNodeEditor { DrawGrid(position, zoom, panOffset); DrawDraggedConnection(); - DrawNodes(); DrawConnections(); + DrawNodes(); DrawSelectionBox(); DrawTooltip(); graphEditor.OnGUI(); From fdd42a827482f967fd93c716fae883328c517321 Mon Sep 17 00:00:00 2001 From: Icarus <1375400884@qq.com> Date: Wed, 25 Sep 2019 23:45:57 +0800 Subject: [PATCH 16/65] =?UTF-8?q?!W=20=E8=BE=93=E5=87=BA=E7=AB=AF=E5=8F=A3?= =?UTF-8?q?=E7=B4=A2=E5=BC=95=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Scripts/Editor/NodeEditorGUILayout.cs | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/Scripts/Editor/NodeEditorGUILayout.cs b/Scripts/Editor/NodeEditorGUILayout.cs index 6648c2d..770282e 100644 --- a/Scripts/Editor/NodeEditorGUILayout.cs +++ b/Scripts/Editor/NodeEditorGUILayout.cs @@ -197,7 +197,31 @@ namespace XNodeEditor { Color backgroundColor = editor.GetTint(); Color col = NodeEditorWindow.current.graphEditor.GetPortColor(port); DrawPortHandle(rect, backgroundColor, col); - + + //当选择节点时显示所有的输入点索引 + if (port.direction == XNode.NodePort.IO.Output) + { + if (port.Connection != null) + { + if (port.Connection.node == Selection.activeObject) + { + var dCol = GUI.color; + var fontStyle = EditorStyles.label.fontStyle; + var textCol = Color.white - col; + textCol.a = 1; + var index = port.Connection.GetConnectionIndex(port); + EditorStyles.label.fontStyle = FontStyle.Bold; + GUI.contentColor = textCol; + { + EditorGUI.LabelField(new Rect( rect.position + new Vector2(rect.size.x / 4 - 0.5f,0), rect.size), + index.ToString()); + } + GUI.contentColor = dCol; + EditorStyles.label.fontStyle = fontStyle; + } + } + } + // Register the handle position Vector2 portPos = rect.center; NodeEditor.portPositions[port] = portPos; From 46d093339c8141bec892747edf2dc0292a0e8161 Mon Sep 17 00:00:00 2001 From: Icarus <1375400884@qq.com> Date: Fri, 27 Sep 2019 00:48:34 +0800 Subject: [PATCH 17/65] =?UTF-8?q?!W=20=E7=BB=98=E5=88=B6GroupName?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Scripts/Editor/NodeEditorGUI.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Scripts/Editor/NodeEditorGUI.cs b/Scripts/Editor/NodeEditorGUI.cs index 3555023..1bc7fa9 100644 --- a/Scripts/Editor/NodeEditorGUI.cs +++ b/Scripts/Editor/NodeEditorGUI.cs @@ -24,6 +24,7 @@ namespace XNodeEditor { Controls(); DrawGrid(position, zoom, panOffset); + _drawGroupName(); DrawDraggedConnection(); DrawConnections(); DrawNodes(); @@ -40,6 +41,19 @@ namespace XNodeEditor { GUI.matrix = m; } + private void _drawGroupName() + { + var guiContent = new GUIContent(this.graph.name); + var col = EditorStyles.label.normal.textColor; + var fontSize = EditorStyles.label.fontSize; + EditorStyles.label.fontSize = 48; + var size = GUILayoutUtility.GetRect(guiContent, EditorStyles.label); + EditorStyles.label.normal.textColor = new Color(175 / 255f, 185 / 255f, 185 / 255f); + EditorGUI.LabelField(new Rect(new Vector2(5, 5), size.size), guiContent); + EditorStyles.label.fontSize = fontSize; + EditorStyles.label.normal.textColor = col; + } + public static void BeginZoomed(Rect rect, float zoom, float topPadding) { GUI.EndClip(); From 2248e0fa9fd3a1541973ff71fb717d91e456e1f8 Mon Sep 17 00:00:00 2001 From: Icarus <1375400884@qq.com> Date: Fri, 27 Sep 2019 16:36:11 +0800 Subject: [PATCH 18/65] =?UTF-8?q?!O=20=E8=B0=83=E6=95=B4=E4=BA=86GroupName?= =?UTF-8?q?=20=E7=BB=98=E5=88=B6=E5=BE=97=E9=A1=BA=E5=BA=8F,=E5=A6=82?= =?UTF-8?q?=E6=9E=9C=E8=BF=9E=E6=8E=A5=E6=95=B0=E5=8F=AA=E6=9C=89=E4=B8=80?= =?UTF-8?q?=E4=B8=AA=E4=B8=8D=E6=98=BE=E7=A4=BA=E7=B4=A2=E5=BC=95,?= =?UTF-8?q?=E7=B4=A2=E5=BC=95=E6=95=B0+1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Scripts/Editor/NodeEditorGUI.cs | 2 +- Scripts/Editor/NodeEditorGUILayout.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Scripts/Editor/NodeEditorGUI.cs b/Scripts/Editor/NodeEditorGUI.cs index 1bc7fa9..a734bd8 100644 --- a/Scripts/Editor/NodeEditorGUI.cs +++ b/Scripts/Editor/NodeEditorGUI.cs @@ -24,11 +24,11 @@ namespace XNodeEditor { Controls(); DrawGrid(position, zoom, panOffset); - _drawGroupName(); DrawDraggedConnection(); DrawConnections(); DrawNodes(); DrawSelectionBox(); + _drawGroupName(); DrawTooltip(); graphEditor.OnGUI(); diff --git a/Scripts/Editor/NodeEditorGUILayout.cs b/Scripts/Editor/NodeEditorGUILayout.cs index 770282e..295caa1 100644 --- a/Scripts/Editor/NodeEditorGUILayout.cs +++ b/Scripts/Editor/NodeEditorGUILayout.cs @@ -201,7 +201,7 @@ namespace XNodeEditor { //当选择节点时显示所有的输入点索引 if (port.direction == XNode.NodePort.IO.Output) { - if (port.Connection != null) + if (port.Connection != null && port.Connection.ConnectionCount > 1) { if (port.Connection.node == Selection.activeObject) { @@ -214,7 +214,7 @@ namespace XNodeEditor { GUI.contentColor = textCol; { EditorGUI.LabelField(new Rect( rect.position + new Vector2(rect.size.x / 4 - 0.5f,0), rect.size), - index.ToString()); + (index + 1).ToString()); } GUI.contentColor = dCol; EditorStyles.label.fontStyle = fontStyle; From eb3d24ff1d2999e8183498bfd11c724738892ac8 Mon Sep 17 00:00:00 2001 From: Icarus <1375400884@qq.com> Date: Sun, 24 Nov 2019 04:56:46 +0800 Subject: [PATCH 19/65] =?UTF-8?q?!W=20=E5=8F=B3=E9=94=AE=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E8=8A=82=E7=82=B9=E7=9A=84=E6=96=B9=E5=BC=8F=E4=BB=8E`GenericM?= =?UTF-8?q?enu`=E6=94=B9=E4=B8=BA`PopupWindow`,=E7=9B=AE=E5=89=8D=E6=9C=89?= =?UTF-8?q?=E4=B8=AA=E5=B0=8Fbug,=E7=82=B9=E5=87=BA=E7=BA=BF=E5=90=8E,?= =?UTF-8?q?=E5=8F=B3=E9=94=AE=E6=9C=AC=E6=9D=A5=E5=BA=94=E8=AF=A5=E6=98=AF?= =?UTF-8?q?=E5=8F=96=E6=B6=88=E7=BA=BF=E7=9A=84=E9=80=89=E6=8B=A9=E7=8A=B6?= =?UTF-8?q?=E6=80=81,=E4=BD=86=E7=9B=AE=E5=89=8D=E6=97=A0=E6=B3=95,?= =?UTF-8?q?=E5=90=8E=E7=BB=AD=E5=9C=A8=E8=A7=A3=E5=86=B3,=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E4=B8=8D=E5=A4=A7=3D-=3D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Scripts/Editor/NodeEditorAction.cs | 8 +- Scripts/Editor/NodeEditorReflection.cs | 17 ++ Scripts/Editor/NodeGraphEditor.cs | 210 ++++++++++++++++++++++++- 3 files changed, 224 insertions(+), 11 deletions(-) diff --git a/Scripts/Editor/NodeEditorAction.cs b/Scripts/Editor/NodeEditorAction.cs index 35fbdd1..6894c88 100644 --- a/Scripts/Editor/NodeEditorAction.cs +++ b/Scripts/Editor/NodeEditorAction.cs @@ -219,9 +219,9 @@ namespace XNodeEditor { } // Open context menu for auto-connection else if (NodeEditorPreferences.GetSettings().dragToCreate && autoConnectOutput != null) { - GenericMenu menu = new GenericMenu(); + MenuPopupWindow menu = new MenuPopupWindow(); graphEditor.AddContextMenuItems(menu); - menu.DropDown(new Rect(Event.current.mousePosition, Vector2.zero)); + PopupWindow.Show(new Rect(Event.current.mousePosition, Vector2.zero),menu); } //Release dragged connection draggedOutput = null; @@ -281,9 +281,9 @@ namespace XNodeEditor { e.Use(); // Fixes copy/paste context menu appearing in Unity 5.6.6f2 - doesn't occur in 2018.3.2f1 Probably needs to be used in other places. } else if (!IsHoveringNode) { autoConnectOutput = null; - GenericMenu menu = new GenericMenu(); + MenuPopupWindow menu = new MenuPopupWindow(); graphEditor.AddContextMenuItems(menu); - menu.DropDown(new Rect(Event.current.mousePosition, Vector2.zero)); + PopupWindow.Show(new Rect(Event.current.mousePosition, Vector2.zero),menu); } } isPanning = false; diff --git a/Scripts/Editor/NodeEditorReflection.cs b/Scripts/Editor/NodeEditorReflection.cs index 0a0a36a..27136e0 100644 --- a/Scripts/Editor/NodeEditorReflection.cs +++ b/Scripts/Editor/NodeEditorReflection.cs @@ -74,6 +74,23 @@ namespace XNodeEditor { } return types.ToArray(); } + + /// Find methods marked with the [ContextMenu] attribute and add them to the context menu + public static void AddCustomContextMenuItems(this MenuPopupWindow contextMenu, object obj) { + KeyValuePair[] items = GetContextMenuMethods(obj); + if (items.Length != 0) { + List invalidatedEntries = new List(); + foreach (KeyValuePair checkValidate in items) { + if (checkValidate.Key.validate && !(bool) checkValidate.Value.Invoke(obj, null)) { + invalidatedEntries.Add(checkValidate.Key.menuItem); + } + } + for (int i = 0; i < items.Length; i++) { + KeyValuePair kvp = items[i]; + contextMenu.AddItem(kvp.Key.menuItem, () => kvp.Value.Invoke(obj, null)); + } + } + } /// Find methods marked with the [ContextMenu] attribute and add them to the context menu public static void AddCustomContextMenuItems(this GenericMenu contextMenu, object obj) { diff --git a/Scripts/Editor/NodeGraphEditor.cs b/Scripts/Editor/NodeGraphEditor.cs index 7b706fa..a17c1c4 100644 --- a/Scripts/Editor/NodeGraphEditor.cs +++ b/Scripts/Editor/NodeGraphEditor.cs @@ -2,9 +2,199 @@ using System.Collections.Generic; using System.Linq; using UnityEditor; +using UnityEditor.IMGUI.Controls; using UnityEngine; namespace XNodeEditor { + public class MenuPopupWindow : PopupWindowContent + { + private SearchField _search; + private MenuTreeView _menuTree; + public MenuPopupWindow() + { + _search = new SearchField(); + _menuTree = new MenuTreeView(); + } + + private bool _isInit; + + public void AddItem(string menuPath, Action onClick, char symbol = '/',bool autoClose = true) + { + _menuTree.AddItem(menuPath, () => + { + onClick?.Invoke(); + if (autoClose) + { + editorWindow.Close(); + } + },symbol); + } + + public void Init() + { + _menuTree.Reload(); + _isInit = true; + } + + public override void OnOpen() + { + _search.SetFocus(); + } + + private string _str; + public override void OnGUI(Rect rect) + { + if (!_isInit) + { + Init(); + } + + EditorGUI.BeginChangeCheck(); + { + _str = _search.OnGUI(new Rect(rect.position, new Vector2(rect.width, 20)),_str); + } + if (EditorGUI.EndChangeCheck()) + { + _menuTree.searchString = _str; + } + + _menuTree.OnGUI(new Rect(new Vector2(0,25),rect.size - new Vector2(0,20))); + } + } + public class MenuTreeView:TreeView + { + class MenuItem:TreeViewItem + { + public readonly Action OnClick; + + public MenuItem(int id, int depth, string displayName, Action onClick) : base(id, depth, displayName) + { + OnClick = onClick; + } + } + + public TreeViewItem Root { get; } + + public MenuTreeView():this(new TreeViewState()) + { + } + + public MenuTreeView(TreeViewState state, MultiColumnHeader multiColumnHeader = null) : base(state, multiColumnHeader) + { + Root = new TreeViewItem(_id++,-1,nameof(Root)); + } + + private int _id = -1; + + private Dictionary> _menuCache = new Dictionary>(); + + /// + /// + /// + /// + /// + /// + public void AddItem(string menuPath,Action onClick,char symbol = '/') + { + var paths = menuPath.Split(symbol); + + int depth = 0; + + TreeViewItem last = Root; + + if (paths.Length > 1) + { + for (var i = 0; i < paths.Length - 1; i++) + { + var path = paths[i]; + + if (!_menuCache.TryGetValue(depth, out var caches)) + { + caches = new List(); + _menuCache.Add(depth, caches); + } + + while (true) + { + if (last.hasChildren) + { + foreach (var item in last.children) + { + if (item.displayName == path) + { + last = item; + depth++; + goto end; + } + } + } + + break; + } + + var temp = new TreeViewItem(_id++,depth++,path); + + last.AddChild(temp); + + last = temp; + + end: ; + } + } + + last.AddChild(new MenuItem(_id++,depth,paths.Last(),onClick)); + } + + protected override bool DoesItemMatchSearch(TreeViewItem item, string search) + { + if (item.parent != null && item.parent.displayName.IndexOf(search, StringComparison.OrdinalIgnoreCase) >= 0) + { + return true; + } + + return base.DoesItemMatchSearch(item, search); + } + + List _ids = new List(); + protected override void DoubleClickedItem(int id) + { + var item = FindItem(id,Root); + if (item.hasChildren) + { + if (hasSearch) + { + searchString = ""; + + _ids.Clear(); + + while (item != null) + { + _ids.Add(item.id); + item = item.parent; + } + + SetExpanded(_ids); + } + else + { + SetExpanded(id, !IsExpanded(id)); + } + } + else + { + if (item is MenuItem menuItem) + { + menuItem.OnClick?.Invoke(); + } + } + } + + protected override TreeViewItem BuildRoot() + { + return Root; + } + } + /// Base class to derive custom Node Graph editors from. Use this to override how graphs are drawn in the editor. [CustomNodeGraphEditor(typeof(XNode.NodeGraph))] public class NodeGraphEditor : XNodeEditor.Internal.NodeEditorBase { @@ -42,7 +232,7 @@ namespace XNodeEditor { } /// Add items for the context menu when right-clicking this node. Override to add custom menu items. - public virtual void AddContextMenuItems(GenericMenu menu) { + public virtual void AddContextMenuItems(MenuPopupWindow menu) { Vector2 pos = NodeEditorWindow.current.WindowToGridPosition(Event.current.mousePosition); for (int i = 0; i < NodeEditorReflection.nodeTypes.Length; i++) { Type type = NodeEditorReflection.nodeTypes[i]; @@ -51,17 +241,23 @@ namespace XNodeEditor { string path = GetNodeMenuName(type); if (string.IsNullOrEmpty(path)) continue; - menu.AddItem(new GUIContent(path), false, () => { + menu.AddItem(path, () => { XNode.Node node = CreateNode(type, pos); NodeEditorWindow.current.AutoConnect(node); }); } - menu.AddSeparator(""); - if (NodeEditorWindow.copyBuffer != null && NodeEditorWindow.copyBuffer.Length > 0) menu.AddItem(new GUIContent("Paste"), false, () => NodeEditorWindow.current.PasteNodes(pos)); - else menu.AddDisabledItem(new GUIContent("Paste")); - menu.AddItem(new GUIContent("Preferences"), false, () => NodeEditorReflection.OpenPreferences()); - menu.AddItem(new GUIContent("创建所有的节点 ---> 测试用"), false, () => +// menu.AddSeparator(""); + if (NodeEditorWindow.copyBuffer != null && NodeEditorWindow.copyBuffer.Length > 0) + menu.AddItem("Paste", () => NodeEditorWindow.current.PasteNodes(pos)); +// else menu.AddDisabledItem(new GUIContent("Paste")); + menu.AddItem("Preferences", () => NodeEditorReflection.OpenPreferences()); + menu.AddItem("创建所有的节点 ---> 测试用", () => { + if (!EditorUtility.DisplayDialog("warning","Are you sure you want to create all the nodes?","ok","no")) + { + return; + } + for (int i = 0; i < NodeEditorReflection.nodeTypes.Length; i++) { Type type = NodeEditorReflection.nodeTypes[i]; From 07217505e67dccdd0cb91ad3b8cca5116460b362 Mon Sep 17 00:00:00 2001 From: Icarus <1375400884@qq.com> Date: Tue, 26 Nov 2019 17:42:30 +0800 Subject: [PATCH 20/65] =?UTF-8?q?!W=20=E6=90=9C=E7=B4=A2=E6=97=B6=E6=8C=89?= =?UTF-8?q?=E4=B8=8B`=E2=86=93`=E9=94=AE=E5=88=87=E6=8D=A2=E7=84=A6?= =?UTF-8?q?=E7=82=B9=E5=88=B0`TreeView`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Scripts/Editor/NodeGraphEditor.cs | 56 +++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/Scripts/Editor/NodeGraphEditor.cs b/Scripts/Editor/NodeGraphEditor.cs index a17c1c4..2dc444b 100644 --- a/Scripts/Editor/NodeGraphEditor.cs +++ b/Scripts/Editor/NodeGraphEditor.cs @@ -10,6 +10,7 @@ namespace XNodeEditor { { private SearchField _search; private MenuTreeView _menuTree; + public Action OnCloseA; public MenuPopupWindow() { _search = new SearchField(); @@ -41,6 +42,11 @@ namespace XNodeEditor { _search.SetFocus(); } + public override void OnClose() + { + OnCloseA?.Invoke(); + } + private string _str; public override void OnGUI(Rect rect) { @@ -49,6 +55,8 @@ namespace XNodeEditor { Init(); } + _action(); + EditorGUI.BeginChangeCheck(); { _str = _search.OnGUI(new Rect(rect.position, new Vector2(rect.width, 20)),_str); @@ -60,6 +68,22 @@ namespace XNodeEditor { _menuTree.OnGUI(new Rect(new Vector2(0,25),rect.size - new Vector2(0,20))); } + + private void _action() + { + Event e = Event.current; + switch (e.type) + { + case EventType.KeyDown: + + if (e.keyCode == KeyCode.DownArrow && !_menuTree.HasFocus()) + { + _menuTree.SetFocusAndEnsureSelectedItem(); + e.Use(); + } + break; + } + } } public class MenuTreeView:TreeView { @@ -193,6 +217,38 @@ namespace XNodeEditor { { return Root; } + + protected override void KeyEvent() + { + Event e = Event.current; + switch (e.type) + { + case EventType.KeyDown: + + if (e.keyCode == KeyCode.Return || e.keyCode == KeyCode.KeypadEnter) + { + DoubleClickedItem(GetSelection()[0]); + e.Use(); + } + break; + } + } + + private void _action() + { + Event e = Event.current; + switch (e.type) + { + case EventType.KeyDown: + + if (e.keyCode == KeyCode.DownArrow && !HasFocus()) + { + this.SetFocusAndEnsureSelectedItem(); + e.Use(); + } + break; + } + } } /// Base class to derive custom Node Graph editors from. Use this to override how graphs are drawn in the editor. From 284ecddc507ca8dfe412a8e12ad6be7fd4f1e33c Mon Sep 17 00:00:00 2001 From: Icarus <1375400884@qq.com> Date: Tue, 26 Nov 2019 17:42:57 +0800 Subject: [PATCH 21/65] =?UTF-8?q?!T=20=E5=8A=A0=E4=B8=80=E4=B8=AA=E6=9C=80?= =?UTF-8?q?=E5=B0=8F=E5=B0=BA=E5=AF=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Scripts/Editor/NodeEditorWindow.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Scripts/Editor/NodeEditorWindow.cs b/Scripts/Editor/NodeEditorWindow.cs index a063410..439f9df 100644 --- a/Scripts/Editor/NodeEditorWindow.cs +++ b/Scripts/Editor/NodeEditorWindow.cs @@ -100,6 +100,7 @@ namespace XNodeEditor { if (this.graphEditor != graphEditor) { this.graphEditor = graphEditor; graphEditor.OnOpen(); + this.graphEditor.window.minSize = new Vector2(300,300); } } From 02f59984a02ed381a9eaa2a312082b6934841463 Mon Sep 17 00:00:00 2001 From: Icarus <1375400884@qq.com> Date: Tue, 26 Nov 2019 17:43:54 +0800 Subject: [PATCH 22/65] =?UTF-8?q?!B=20=E8=8A=82=E7=82=B9=E9=80=89=E6=8B=A9?= =?UTF-8?q?=E7=AA=97=E5=8F=A3=E6=97=A0=E6=B3=95=E5=85=B3=E9=97=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Scripts/Editor/NodeEditorAction.cs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Scripts/Editor/NodeEditorAction.cs b/Scripts/Editor/NodeEditorAction.cs index 6894c88..dbe0e1b 100644 --- a/Scripts/Editor/NodeEditorAction.cs +++ b/Scripts/Editor/NodeEditorAction.cs @@ -221,13 +221,18 @@ namespace XNodeEditor { else if (NodeEditorPreferences.GetSettings().dragToCreate && autoConnectOutput != null) { MenuPopupWindow menu = new MenuPopupWindow(); graphEditor.AddContextMenuItems(menu); + + menu.OnCloseA += () => + { + //Release dragged connection + draggedOutput = null; + draggedOutputTarget = null; + EditorUtility.SetDirty(graph); + if (NodeEditorPreferences.GetSettings().autoSave) AssetDatabase.SaveAssets(); + }; + PopupWindow.Show(new Rect(Event.current.mousePosition, Vector2.zero),menu); } - //Release dragged connection - draggedOutput = null; - draggedOutputTarget = null; - EditorUtility.SetDirty(graph); - if (NodeEditorPreferences.GetSettings().autoSave) AssetDatabase.SaveAssets(); } else if (currentActivity == NodeActivity.DragNode) { IEnumerable nodes = Selection.objects.Where(x => x is XNode.Node).Select(x => x as XNode.Node); foreach (XNode.Node node in nodes) EditorUtility.SetDirty(node); From cfb4d2cb54c314d5631969e0324cdc8535ea6b99 Mon Sep 17 00:00:00 2001 From: Icarus <1375400884@qq.com> Date: Tue, 26 Nov 2019 17:44:48 +0800 Subject: [PATCH 23/65] =?UTF-8?q?!W=20`GenericMenu`=E6=94=B9=E4=B8=BA`Menu?= =?UTF-8?q?PopupWindow`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Scripts/Editor/NodeEditorAction.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Scripts/Editor/NodeEditorAction.cs b/Scripts/Editor/NodeEditorAction.cs index dbe0e1b..49be164 100644 --- a/Scripts/Editor/NodeEditorAction.cs +++ b/Scripts/Editor/NodeEditorAction.cs @@ -280,9 +280,9 @@ namespace XNodeEditor { } else if (IsHoveringNode && IsHoveringTitle(hoveredNode)) { if (!Selection.Contains(hoveredNode)) SelectNode(hoveredNode, false); autoConnectOutput = null; - GenericMenu menu = new GenericMenu(); + MenuPopupWindow menu = new MenuPopupWindow(); NodeEditor.GetEditor(hoveredNode, this).AddContextMenuItems(menu); - menu.DropDown(new Rect(Event.current.mousePosition, Vector2.zero)); + PopupWindow.Show(new Rect(Event.current.mousePosition, Vector2.zero),menu); e.Use(); // Fixes copy/paste context menu appearing in Unity 5.6.6f2 - doesn't occur in 2018.3.2f1 Probably needs to be used in other places. } else if (!IsHoveringNode) { autoConnectOutput = null; From 1691e4ce2130622a6b0047c967e2bb08b42c77ec Mon Sep 17 00:00:00 2001 From: Icarus <1375400884@qq.com> Date: Tue, 26 Nov 2019 17:45:34 +0800 Subject: [PATCH 24/65] !W --- Scripts/Editor/NodeEditor.cs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Scripts/Editor/NodeEditor.cs b/Scripts/Editor/NodeEditor.cs index bdbbb86..ea07d45 100644 --- a/Scripts/Editor/NodeEditor.cs +++ b/Scripts/Editor/NodeEditor.cs @@ -148,6 +148,27 @@ namespace XNodeEditor { return NodeEditorResources.styles.nodeBody; } + /// Add items for the context menu when right-clicking this node. Override to add custom menu items. + public virtual void AddContextMenuItems(MenuPopupWindow menu) { + // Actions if only one node is selected + if (Selection.objects.Length == 1 && Selection.activeObject is XNode.Node) { + XNode.Node node = Selection.activeObject as XNode.Node; + menu.AddItem("Move To Top", () => NodeEditorWindow.current.MoveNodeToTop(node)); + menu.AddItem("Rename", NodeEditorWindow.current.RenameSelectedNode); + } + + // Add actions to any number of selected nodes + menu.AddItem("Copy", NodeEditorWindow.current.CopySelectedNodes); + menu.AddItem("Duplicate", NodeEditorWindow.current.DuplicateSelectedNodes); + menu.AddItem("Remove", NodeEditorWindow.current.RemoveSelectedNodes); + + // Custom sctions if only one node is selected + if (Selection.objects.Length == 1 && Selection.activeObject is XNode.Node) { + XNode.Node node = Selection.activeObject as XNode.Node; + menu.AddCustomContextMenuItems(node); + } + } + /// Add items for the context menu when right-clicking this node. Override to add custom menu items. public virtual void AddContextMenuItems(GenericMenu menu) { // Actions if only one node is selected From 2b21b0ddc677f4b7bf5aa0c39ac7d24bb06ba842 Mon Sep 17 00:00:00 2001 From: Icarus <1375400884@qq.com> Date: Tue, 26 Nov 2019 18:53:25 +0800 Subject: [PATCH 25/65] =?UTF-8?q?!B=20=E7=AB=AF=E5=8F=A3=E8=BF=9E=E6=8E=A5?= =?UTF-8?q?=E5=90=8E,=E6=B2=A1=E6=9C=89=E9=87=8A=E6=94=BE=E8=BF=9E?= =?UTF-8?q?=E6=8E=A5=E7=BA=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Scripts/Editor/NodeEditorAction.cs | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/Scripts/Editor/NodeEditorAction.cs b/Scripts/Editor/NodeEditorAction.cs index 49be164..c66287a 100644 --- a/Scripts/Editor/NodeEditorAction.cs +++ b/Scripts/Editor/NodeEditorAction.cs @@ -222,17 +222,13 @@ namespace XNodeEditor { MenuPopupWindow menu = new MenuPopupWindow(); graphEditor.AddContextMenuItems(menu); - menu.OnCloseA += () => - { - //Release dragged connection - draggedOutput = null; - draggedOutputTarget = null; - EditorUtility.SetDirty(graph); - if (NodeEditorPreferences.GetSettings().autoSave) AssetDatabase.SaveAssets(); - }; + menu.OnCloseA += _releaseDraggedConnection; PopupWindow.Show(new Rect(Event.current.mousePosition, Vector2.zero),menu); } + + _releaseDraggedConnection(); + } else if (currentActivity == NodeActivity.DragNode) { IEnumerable nodes = Selection.objects.Where(x => x is XNode.Node).Select(x => x as XNode.Node); foreach (XNode.Node node in nodes) EditorUtility.SetDirty(node); @@ -346,6 +342,15 @@ namespace XNodeEditor { } } + private void _releaseDraggedConnection() + { +//Release dragged connection + draggedOutput = null; + draggedOutputTarget = null; + EditorUtility.SetDirty(graph); + if (NodeEditorPreferences.GetSettings().autoSave) AssetDatabase.SaveAssets(); + } + private void RecalculateDragOffsets(Event current) { dragOffset = new Vector2[Selection.objects.Length + selectedReroutes.Count]; // Selected nodes From 0893d3b310d1c03956cc86b811c213802648d2cb Mon Sep 17 00:00:00 2001 From: Icarus <1375400884@qq.com> Date: Wed, 27 Nov 2019 10:31:03 +0800 Subject: [PATCH 26/65] =?UTF-8?q?!W=20=E4=B8=80=E4=B8=AA=E5=85=B3=E9=97=AD?= =?UTF-8?q?=E6=89=80=E6=9C=89`Node=20Editor=20Window`=E7=AA=97=E5=8F=A3?= =?UTF-8?q?=E7=9A=84=E8=8F=9C=E5=8D=95=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Scripts/Editor/NodeEditorWindow.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Scripts/Editor/NodeEditorWindow.cs b/Scripts/Editor/NodeEditorWindow.cs index 439f9df..53699b0 100644 --- a/Scripts/Editor/NodeEditorWindow.cs +++ b/Scripts/Editor/NodeEditorWindow.cs @@ -8,6 +8,18 @@ using Object = UnityEngine.Object; namespace XNodeEditor { [InitializeOnLoad] public partial class NodeEditorWindow : EditorWindow { + + [MenuItem("Icarus/Node Editor/Close All Editor Window")] + static void CloseAllNodeEditorWindow() + { + var windows = Resources.FindObjectsOfTypeAll(); + + foreach (var window in windows) + { + window.Close(); + } + } + public static NodeEditorWindow current; /// Stores node positions for all nodePorts. From 1fece9c7c52ceb087af6ec5b5865dd19fba4a21e Mon Sep 17 00:00:00 2001 From: Icarus <1375400884@qq.com> Date: Thu, 28 Nov 2019 03:45:36 +0800 Subject: [PATCH 27/65] =?UTF-8?q?!T(Node=20Editor=20Window=20=20Action)=20?= =?UTF-8?q?=E5=8F=B3=E9=94=AENode=E6=81=A2=E5=A4=8D=E4=B8=BA`GenericMenu`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Scripts/Editor/NodeEditorAction.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Scripts/Editor/NodeEditorAction.cs b/Scripts/Editor/NodeEditorAction.cs index c66287a..c919c9b 100644 --- a/Scripts/Editor/NodeEditorAction.cs +++ b/Scripts/Editor/NodeEditorAction.cs @@ -276,9 +276,9 @@ namespace XNodeEditor { } else if (IsHoveringNode && IsHoveringTitle(hoveredNode)) { if (!Selection.Contains(hoveredNode)) SelectNode(hoveredNode, false); autoConnectOutput = null; - MenuPopupWindow menu = new MenuPopupWindow(); + GenericMenu menu = new GenericMenu(); NodeEditor.GetEditor(hoveredNode, this).AddContextMenuItems(menu); - PopupWindow.Show(new Rect(Event.current.mousePosition, Vector2.zero),menu); + menu.DropDown(new Rect(Event.current.mousePosition, Vector2.zero)); e.Use(); // Fixes copy/paste context menu appearing in Unity 5.6.6f2 - doesn't occur in 2018.3.2f1 Probably needs to be used in other places. } else if (!IsHoveringNode) { autoConnectOutput = null; From 413f4e2f52d89baccc11e4f0d46781373cc371b5 Mon Sep 17 00:00:00 2001 From: Icarus <1375400884@qq.com> Date: Thu, 28 Nov 2019 03:48:25 +0800 Subject: [PATCH 28/65] =?UTF-8?q?!O(Dynamic=20Port=20List)=20=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E5=AE=9E=E7=8E=B0=E5=AD=98=E5=9C=A8=E6=BD=9C=E8=A7=84?= =?UTF-8?q?=E5=88=99,=E5=88=A0=E9=99=A4=E4=BA=86=E6=BD=9C=E8=A7=84?= =?UTF-8?q?=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Scripts/Editor/NodeEditorGUILayout.cs | 118 +++++++++++--------------- Scripts/Node.cs | 11 +++ 2 files changed, 60 insertions(+), 69 deletions(-) diff --git a/Scripts/Editor/NodeEditorGUILayout.cs b/Scripts/Editor/NodeEditorGUILayout.cs index 295caa1..9e715ad 100644 --- a/Scripts/Editor/NodeEditorGUILayout.cs +++ b/Scripts/Editor/NodeEditorGUILayout.cs @@ -6,6 +6,7 @@ using System.Reflection; using UnityEditor; using UnityEditorInternal; using UnityEngine; +using XNode; namespace XNodeEditor { /// xNode-specific version of @@ -302,23 +303,19 @@ namespace XNodeEditor { /// Connection type of added dynamic ports /// 并且时可用 /// Called on the list on creation. Use this if you want to customize the created ReorderableList - public static void DynamicPortList(string fieldName, Type type, SerializedObject serializedObject, XNode.NodePort.IO io, XNode.Node.ConnectionType connectionType = XNode.Node.ConnectionType.Multiple, XNode.Node.TypeConstraint typeConstraint = XNode.Node.TypeConstraint.None,Type inputTypeConstraintBaseType = null, Action onCreation = null) { + public static void DynamicPortList(string fieldName, Type type, SerializedObject serializedObject, XNode.NodePort.IO io, + XNode.Node.ConnectionType connectionType = XNode.Node.ConnectionType.Multiple, + XNode.Node.TypeConstraint typeConstraint = XNode.Node.TypeConstraint.None,Type inputTypeConstraintBaseType = null, + Action onCreation = null) { XNode.Node node = serializedObject.targetObject as XNode.Node; - var indexedPorts = node.DynamicPorts.Select(x => { - string[] split = x.fieldName.Split(' '); - if (split != null && split.Length == 2 && split[0] == fieldName) { - int i = -1; - if (int.TryParse(split[1], out i)) { - return new { index = i, port = x }; - } - } - return new { index = -1, port = (XNode.NodePort) null }; - }).Where(x => x.port != null); - List dynamicPorts = indexedPorts.OrderBy(x => x.index).Select(x => x.port).ToList(); + var indexedPorts = node.DynamicPorts; + + List dynamicPorts = indexedPorts.ToList(); ReorderableList list = null; Dictionary rlc; + //todo rename no update cache -- 2019年11月28日03点00分 if (reorderableListCache.TryGetValue(serializedObject.targetObject, out rlc)) { if (!rlc.TryGetValue(fieldName, out list)) list = null; } @@ -340,16 +337,22 @@ namespace XNodeEditor { string label = arrayData != null ? arrayData.displayName : ObjectNames.NicifyVariableName(fieldName); list.drawElementCallback = - (Rect rect, int index, bool isActive, bool isFocused) => { - XNode.NodePort port = node.GetPort(fieldName + " " + index); - if (hasArrayData) { + (Rect rect, int index, bool isActive, bool isFocused) => + { + XNode.NodePort port = (NodePort) list.list[index]; + + if (hasArrayData) + { if (arrayData.arraySize <= index) { EditorGUI.LabelField(rect, "Array[" + index + "] data out of range"); return; } SerializedProperty itemData = arrayData.GetArrayElementAtIndex(index); EditorGUI.PropertyField(rect, itemData, true); - } else EditorGUI.LabelField(rect, port != null ? port.fieldName : ""); + } + else + EditorGUI.LabelField(rect, port != null ? port.fieldName : ""); + if (port != null) { Vector2 pos = rect.position + (port.IsOutput?new Vector2(rect.width + 6, 0) : new Vector2(-36, 0)); NodeEditorGUILayout.PortField(pos, port); @@ -363,58 +366,43 @@ namespace XNodeEditor { return EditorGUI.GetPropertyHeight(itemData); } else return EditorGUIUtility.singleLineHeight; }; + list.drawHeaderCallback = (Rect rect) => { EditorGUI.LabelField(rect, label); }; + list.onSelectCallback = (ReorderableList rl) => { reorderableListIndex = rl.index; }; - list.onReorderCallback = - (ReorderableList rl) => { - // Move up - if (rl.index > reorderableListIndex) { - for (int i = reorderableListIndex; i < rl.index; ++i) { - XNode.NodePort port = node.GetPort(fieldName + " " + i); - XNode.NodePort nextPort = node.GetPort(fieldName + " " + (i + 1)); - port.SwapConnections(nextPort); - - // Swap cached positions to mitigate twitching - Rect rect = NodeEditorWindow.current.portConnectionPoints[port]; - NodeEditorWindow.current.portConnectionPoints[port] = NodeEditorWindow.current.portConnectionPoints[nextPort]; - NodeEditorWindow.current.portConnectionPoints[nextPort] = rect; - } + list.onReorderCallbackWithDetails = (reorderableList, index, newIndex) => + { + var port = serializedObject.FindProperty(Node.PortFieldName); + SerializedProperty keys = port.FindPropertyRelative(Node.KeysFieldName); + SerializedProperty values = port.FindPropertyRelative(Node.ValuesFieldName); + var count = 0; + + foreach (var nodePort in node.Ports) + { + if (!reorderableList.list.Contains(nodePort)) + { + count++; + + continue; } - // Move down - else { - for (int i = reorderableListIndex; i > rl.index; --i) { - XNode.NodePort port = node.GetPort(fieldName + " " + i); - XNode.NodePort nextPort = node.GetPort(fieldName + " " + (i - 1)); - port.SwapConnections(nextPort); + + //list after May exist dynamic node so break + break; + } + + index += count; + newIndex += count; + keys.MoveArrayElement(index, newIndex); + values.MoveArrayElement(index, newIndex); + }; - // Swap cached positions to mitigate twitching - Rect rect = NodeEditorWindow.current.portConnectionPoints[port]; - NodeEditorWindow.current.portConnectionPoints[port] = NodeEditorWindow.current.portConnectionPoints[nextPort]; - NodeEditorWindow.current.portConnectionPoints[nextPort] = rect; - } - } - // Apply changes - serializedObject.ApplyModifiedProperties(); - serializedObject.Update(); - - // Move array data if there is any - if (hasArrayData) { - arrayData.MoveArrayElement(reorderableListIndex, rl.index); - } - - // Apply changes - serializedObject.ApplyModifiedProperties(); - serializedObject.Update(); - NodeEditorWindow.current.Repaint(); - EditorApplication.delayCall += NodeEditorWindow.current.Repaint; - }; list.onAddCallback = (ReorderableList rl) => { // Add dynamic port postfixed with an index number @@ -432,19 +420,11 @@ namespace XNodeEditor { serializedObject.ApplyModifiedProperties(); }; list.onRemoveCallback = - (ReorderableList rl) => { + (ReorderableList rl) => + { - var indexedPorts = node.DynamicPorts.Select(x => { - string[] split = x.fieldName.Split(' '); - if (split != null && split.Length == 2 && split[0] == fieldName) { - int i = -1; - if (int.TryParse(split[1], out i)) { - return new { index = i, port = x }; - } - } - return new { index = -1, port = (XNode.NodePort) null }; - }).Where(x => x.port != null); - dynamicPorts = indexedPorts.OrderBy(x => x.index).Select(x => x.port).ToList(); + var indexedPorts = node.DynamicPorts; + dynamicPorts = indexedPorts.ToList(); int index = rl.index; diff --git a/Scripts/Node.cs b/Scripts/Node.cs index 7fbf4c1..9996e73 100644 --- a/Scripts/Node.cs +++ b/Scripts/Node.cs @@ -111,6 +111,12 @@ namespace XNode { /// It is recommended not to modify these at hand. Instead, see and [SerializeField] private NodePortDictionary ports = new NodePortDictionary(); +#if UNITY_EDITOR + public const string PortFieldName = nameof(ports); + public const string KeysFieldName = NodePortDictionary.KeyFieldName; + public const string ValuesFieldName = NodePortDictionary.ValueFieldName; +#endif + /// Used during node instantiation to fix null/misconfigured graph during OnEnable/Init. Set it before instantiating a node. Will automatically be unset during OnEnable public static NodeGraph graphHotfix; @@ -366,6 +372,11 @@ namespace XNode { [SerializeField] private List keys = new List(); [SerializeField] private List values = new List(); +#if UNITY_EDITOR + public const string KeyFieldName = nameof(keys); + public const string ValueFieldName = nameof(values); +#endif + public void OnBeforeSerialize() { keys.Clear(); values.Clear(); From 2c45dd4d667e3ece6815f3b36a4a03a260424ee3 Mon Sep 17 00:00:00 2001 From: Icarus <1375400884@qq.com> Date: Fri, 29 Nov 2019 18:18:50 +0800 Subject: [PATCH 29/65] !O(NodeEditorGUILayout) DynamicPortList --- Scripts/Editor/NodeEditorGUILayout.cs | 61 ++++++--------------------- 1 file changed, 13 insertions(+), 48 deletions(-) diff --git a/Scripts/Editor/NodeEditorGUILayout.cs b/Scripts/Editor/NodeEditorGUILayout.cs index 9e715ad..c52a128 100644 --- a/Scripts/Editor/NodeEditorGUILayout.cs +++ b/Scripts/Editor/NodeEditorGUILayout.cs @@ -309,7 +309,7 @@ namespace XNodeEditor { Action onCreation = null) { XNode.Node node = serializedObject.targetObject as XNode.Node; - var indexedPorts = node.DynamicPorts; + var indexedPorts = io == NodePort.IO.Input ? node.DynamicInputs : node.DynamicOutputs; List dynamicPorts = indexedPorts.ToList(); @@ -322,7 +322,9 @@ namespace XNodeEditor { // If a ReorderableList isn't cached for this array, do so. if (list == null) { SerializedProperty arrayData = serializedObject.FindProperty(fieldName); - list = CreateReorderableList(fieldName, dynamicPorts, arrayData, type, serializedObject, io, connectionType, typeConstraint, inputTypeConstraintBaseType,onCreation); + list = CreateReorderableList(fieldName, dynamicPorts, arrayData, type, serializedObject, + io, connectionType, typeConstraint, inputTypeConstraintBaseType); + onCreation?.Invoke(list); if (reorderableListCache.TryGetValue(serializedObject.targetObject, out rlc)) rlc.Add(fieldName, list); else reorderableListCache.Add(serializedObject.targetObject, new Dictionary() { { fieldName, list } }); } @@ -330,7 +332,9 @@ namespace XNodeEditor { list.DoLayoutList(); } - private static ReorderableList CreateReorderableList(string fieldName, List dynamicPorts, SerializedProperty arrayData, Type type, SerializedObject serializedObject, XNode.NodePort.IO io, XNode.Node.ConnectionType connectionType, XNode.Node.TypeConstraint typeConstraint,Type inputTypeConstraintBaseType, Action onCreation) { + private static ReorderableList CreateReorderableList(string fieldName, List dynamicPorts, SerializedProperty arrayData, Type type, + SerializedObject serializedObject, XNode.NodePort.IO io, XNode.Node.ConnectionType connectionType, XNode.Node.TypeConstraint typeConstraint, + Type inputTypeConstraintBaseType) { bool hasArrayData = arrayData != null && arrayData.isArray; XNode.Node node = serializedObject.targetObject as XNode.Node; ReorderableList list = new ReorderableList(dynamicPorts, null, true, true, true, true); @@ -340,7 +344,6 @@ namespace XNodeEditor { (Rect rect, int index, bool isActive, bool isFocused) => { XNode.NodePort port = (NodePort) list.list[index]; - if (hasArrayData) { if (arrayData.arraySize <= index) { @@ -422,51 +425,13 @@ namespace XNodeEditor { list.onRemoveCallback = (ReorderableList rl) => { - - var indexedPorts = node.DynamicPorts; - dynamicPorts = indexedPorts.ToList(); - int index = rl.index; - if (dynamicPorts[index] == null) { - Debug.LogWarning("No port found at index " + index + " - Skipped"); - } else if (dynamicPorts.Count <= index) { - Debug.LogWarning("DynamicPorts[" + index + "] out of range. Length was " + dynamicPorts.Count + " - Skipped"); - } else { - - // Clear the removed ports connections - dynamicPorts[index].ClearConnections(); - // Move following connections one step up to replace the missing connection - for (int k = index + 1; k < dynamicPorts.Count(); k++) { - for (int j = 0; j < dynamicPorts[k].ConnectionCount; j++) { - XNode.NodePort other = dynamicPorts[k].GetConnection(j); - dynamicPorts[k].Disconnect(other); - dynamicPorts[k - 1].Connect(other); - } - } - // Remove the last dynamic port, to avoid messing up the indexing - node.RemoveDynamicPort(dynamicPorts[dynamicPorts.Count() - 1].fieldName); - serializedObject.Update(); - EditorUtility.SetDirty(node); - } - - if (hasArrayData) { - if (arrayData.arraySize <= index) { - Debug.LogWarning("Attempted to remove array index " + index + " where only " + arrayData.arraySize + " exist - Skipped"); - Debug.Log(rl.list[0]); - return; - } - arrayData.DeleteArrayElementAtIndex(index); - // Error handling. If the following happens too often, file a bug report at https://github.com/Siccity/xNode/issues - if (dynamicPorts.Count <= arrayData.arraySize) { - while (dynamicPorts.Count <= arrayData.arraySize) { - arrayData.DeleteArrayElementAtIndex(arrayData.arraySize - 1); - } - UnityEngine.Debug.LogWarning("Array size exceeded dynamic ports size. Excess items removed."); - } - serializedObject.ApplyModifiedProperties(); - serializedObject.Update(); - } + NodePort o = (NodePort) rl.list[index]; + + node.RemoveDynamicPort(o); + + EditorUtility.SetDirty(node); }; if (hasArrayData) { @@ -487,7 +452,7 @@ namespace XNodeEditor { serializedObject.ApplyModifiedProperties(); serializedObject.Update(); } - if (onCreation != null) onCreation(list); + return list; } } From 25053eaa2cee53d3ee02dde5901ff337dd2c34c8 Mon Sep 17 00:00:00 2001 From: Icarus <1375400884@qq.com> Date: Fri, 29 Nov 2019 18:19:55 +0800 Subject: [PATCH 30/65] !WO(Node Editor Window) Multi Open Support --- Scripts/Editor/NodeEditorWindow.cs | 49 ++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/Scripts/Editor/NodeEditorWindow.cs b/Scripts/Editor/NodeEditorWindow.cs index 53699b0..c5126e5 100644 --- a/Scripts/Editor/NodeEditorWindow.cs +++ b/Scripts/Editor/NodeEditorWindow.cs @@ -7,7 +7,29 @@ using Object = UnityEngine.Object; namespace XNodeEditor { [InitializeOnLoad] - public partial class NodeEditorWindow : EditorWindow { + public partial class NodeEditorWindow : EditorWindow,IHasCustomMenu { + + public bool Lock { get; private set; } + + [System.NonSerialized] + GUIStyle lockButtonStyle; + + /// + /// Magic method which Unity detects automatically. + /// + /// Position of button. + void ShowButton(Rect position) { + if (lockButtonStyle == null) + lockButtonStyle = "IN LockButton"; + Lock = GUI.Toggle(position, Lock, GUIContent.none, lockButtonStyle); + } + + public void AddItemsToMenu(GenericMenu menu) + { + menu.AddItem(new GUIContent("Lock"), Lock, () => { + Lock = !Lock; + }); + } [MenuItem("Icarus/Node Editor/Close All Editor Window")] static void CloseAllNodeEditorWindow() @@ -203,7 +225,30 @@ namespace XNodeEditor { public static void Open(XNode.NodeGraph graph) { if (!graph) return; - NodeEditorWindow w = GetWindow(typeof(NodeEditorWindow), false, "xNode", true) as NodeEditorWindow; + var windows = Resources.FindObjectsOfTypeAll(); + NodeEditorWindow w = null; + foreach (var window in windows) + { + if (window.Lock) + { + if (window.graph == graph) + { + w = window; + } + } + else + { + w = window; + } + } + + if (!w) + { + w = CreateWindow("xNode"); + } + + w.Show(true); + w.Focus(); w.wantsMouseMove = true; w.graph = graph; } From ae9429fa3e3a11b41d3372f1ad3eabd0b3eba98c Mon Sep 17 00:00:00 2001 From: Icarus <1375400884@qq.com> Date: Fri, 29 Nov 2019 18:28:25 +0800 Subject: [PATCH 31/65] !TX --- Scripts/Editor/NodeEditorWindow.cs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/Scripts/Editor/NodeEditorWindow.cs b/Scripts/Editor/NodeEditorWindow.cs index c5126e5..a1b222d 100644 --- a/Scripts/Editor/NodeEditorWindow.cs +++ b/Scripts/Editor/NodeEditorWindow.cs @@ -11,17 +11,12 @@ namespace XNodeEditor { public bool Lock { get; private set; } - [System.NonSerialized] - GUIStyle lockButtonStyle; - /// /// Magic method which Unity detects automatically. /// /// Position of button. void ShowButton(Rect position) { - if (lockButtonStyle == null) - lockButtonStyle = "IN LockButton"; - Lock = GUI.Toggle(position, Lock, GUIContent.none, lockButtonStyle); + Lock = GUI.Toggle(position, Lock, GUIContent.none, "IN LockButton"); } public void AddItemsToMenu(GenericMenu menu) From efbab70191c0d424c14141271198e87f5e20a529 Mon Sep 17 00:00:00 2001 From: Icarus <1375400884@qq.com> Date: Sun, 1 Dec 2019 21:09:58 +0800 Subject: [PATCH 32/65] !WF(Node Editor) OnFocus Trigger OnInit --- Scripts/Editor/NodeEditor.cs | 8 +------- Scripts/Editor/NodeEditorBase.cs | 6 ++++++ Scripts/Editor/NodeEditorWindow.cs | 1 + Scripts/Editor/NodeGraphEditor.cs | 9 +++++++++ 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/Scripts/Editor/NodeEditor.cs b/Scripts/Editor/NodeEditor.cs index ea07d45..0bd667a 100644 --- a/Scripts/Editor/NodeEditor.cs +++ b/Scripts/Editor/NodeEditor.cs @@ -24,7 +24,7 @@ namespace XNodeEditor { internal static bool inNodeEditor = false; #endif private List _excludesField; - public sealed override void OnCreate() + public override void OnCreate() { _excludesField = new List { "m_Script", "graph", "position", "ports" }; @@ -34,12 +34,6 @@ namespace XNodeEditor { { _excludesField.AddRange(fields); } - - Init(); - } - - protected virtual void Init() - { } public virtual void OnHeaderGUI() { diff --git a/Scripts/Editor/NodeEditorBase.cs b/Scripts/Editor/NodeEditorBase.cs index 1fc28c7..8133d66 100644 --- a/Scripts/Editor/NodeEditorBase.cs +++ b/Scripts/Editor/NodeEditorBase.cs @@ -50,6 +50,7 @@ namespace XNodeEditor.Internal { editor.serializedObject = new SerializedObject(target); editor.window = window; editor.OnCreate(); + editor.OnInit(); editors.Add(target, editor); } if (editor.target == null) editor.target = target; @@ -84,6 +85,11 @@ namespace XNodeEditor.Internal { /// Called on creation, after references have been set public virtual void OnCreate() { } + /// + /// node editor window OnFocus call + /// + public virtual void OnInit() { } + public interface INodeEditorAttrib { Type GetInspectedType(); } diff --git a/Scripts/Editor/NodeEditorWindow.cs b/Scripts/Editor/NodeEditorWindow.cs index a1b222d..8c8f8bb 100644 --- a/Scripts/Editor/NodeEditorWindow.cs +++ b/Scripts/Editor/NodeEditorWindow.cs @@ -106,6 +106,7 @@ namespace XNodeEditor { void OnFocus() { current = this; ValidateGraphEditor(); + graphEditor?.OnFocus(); if (graphEditor != null && NodeEditorPreferences.GetSettings().autoSave) AssetDatabase.SaveAssets(); } diff --git a/Scripts/Editor/NodeGraphEditor.cs b/Scripts/Editor/NodeGraphEditor.cs index 2dc444b..95a7cdd 100644 --- a/Scripts/Editor/NodeGraphEditor.cs +++ b/Scripts/Editor/NodeGraphEditor.cs @@ -264,6 +264,15 @@ namespace XNodeEditor { /// Called when opened by NodeEditorWindow public virtual void OnOpen() { } + public virtual void OnFocus() + { + foreach (var targetNode in target.nodes) + { + var editor = NodeEditor.GetEditor(targetNode, window); + editor.OnInit(); + } + } + public virtual Texture2D GetGridTexture() { return NodeEditorPreferences.GetSettings().gridTexture; } From e04b4fc9894c8a3a077c6fd42a9b39a4914c5f02 Mon Sep 17 00:00:00 2001 From: Icarus <1375400884@qq.com> Date: Sun, 1 Dec 2019 21:11:11 +0800 Subject: [PATCH 33/65] !W(Node Editor GUILayout) DynamicPortList Add `OnAdd` Action --- Scripts/Editor/NodeEditorGUILayout.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Scripts/Editor/NodeEditorGUILayout.cs b/Scripts/Editor/NodeEditorGUILayout.cs index c52a128..0a09cc4 100644 --- a/Scripts/Editor/NodeEditorGUILayout.cs +++ b/Scripts/Editor/NodeEditorGUILayout.cs @@ -306,7 +306,7 @@ namespace XNodeEditor { public static void DynamicPortList(string fieldName, Type type, SerializedObject serializedObject, XNode.NodePort.IO io, XNode.Node.ConnectionType connectionType = XNode.Node.ConnectionType.Multiple, XNode.Node.TypeConstraint typeConstraint = XNode.Node.TypeConstraint.None,Type inputTypeConstraintBaseType = null, - Action onCreation = null) { + Action onCreation = null,Action onAdd = null) { XNode.Node node = serializedObject.targetObject as XNode.Node; var indexedPorts = io == NodePort.IO.Input ? node.DynamicInputs : node.DynamicOutputs; @@ -323,7 +323,7 @@ namespace XNodeEditor { if (list == null) { SerializedProperty arrayData = serializedObject.FindProperty(fieldName); list = CreateReorderableList(fieldName, dynamicPorts, arrayData, type, serializedObject, - io, connectionType, typeConstraint, inputTypeConstraintBaseType); + io, connectionType, typeConstraint, inputTypeConstraintBaseType,onAdd); onCreation?.Invoke(list); if (reorderableListCache.TryGetValue(serializedObject.targetObject, out rlc)) rlc.Add(fieldName, list); else reorderableListCache.Add(serializedObject.targetObject, new Dictionary() { { fieldName, list } }); @@ -334,7 +334,7 @@ namespace XNodeEditor { private static ReorderableList CreateReorderableList(string fieldName, List dynamicPorts, SerializedProperty arrayData, Type type, SerializedObject serializedObject, XNode.NodePort.IO io, XNode.Node.ConnectionType connectionType, XNode.Node.TypeConstraint typeConstraint, - Type inputTypeConstraintBaseType) { + Type inputTypeConstraintBaseType,Action onAdd) { bool hasArrayData = arrayData != null && arrayData.isArray; XNode.Node node = serializedObject.targetObject as XNode.Node; ReorderableList list = new ReorderableList(dynamicPorts, null, true, true, true, true); @@ -421,6 +421,8 @@ namespace XNodeEditor { arrayData.InsertArrayElementAtIndex(arrayData.arraySize); } serializedObject.ApplyModifiedProperties(); + + onAdd?.Invoke(newName); }; list.onRemoveCallback = (ReorderableList rl) => From ecb863630c1f212c1f086ae29ace20b662fec3fe Mon Sep 17 00:00:00 2001 From: Icarus <1375400884@qq.com> Date: Mon, 2 Dec 2019 17:57:35 +0800 Subject: [PATCH 34/65] !W(Node) one new Attribute `LabelAttribute` --- Scripts/Node.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Scripts/Node.cs b/Scripts/Node.cs index 9996e73..27f208d 100644 --- a/Scripts/Node.cs +++ b/Scripts/Node.cs @@ -366,6 +366,19 @@ namespace XNode { this.width = width; } } + + /// Custom Port Label + [AttributeUsage(AttributeTargets.Field, AllowMultiple = true)] + public class LabelAttribute : Attribute + { + public string Label { get; } + + public LabelAttribute(string label) + { + Label = label; + } + } + #endregion [Serializable] private class NodePortDictionary : Dictionary, ISerializationCallbackReceiver { From 32e375e3da1b185b3103258c9a9172aa0aaa66d1 Mon Sep 17 00:00:00 2001 From: Icarus <1375400884@qq.com> Date: Mon, 2 Dec 2019 17:59:42 +0800 Subject: [PATCH 35/65] !W(Node Editor GUI Layout) `LabelAttribute` logic --- Scripts/Editor/NodeEditorGUILayout.cs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/Scripts/Editor/NodeEditorGUILayout.cs b/Scripts/Editor/NodeEditorGUILayout.cs index 0a09cc4..857672a 100644 --- a/Scripts/Editor/NodeEditorGUILayout.cs +++ b/Scripts/Editor/NodeEditorGUILayout.cs @@ -36,10 +36,25 @@ namespace XNodeEditor { /// Make a field for a serialized property. Manual node port override. public static void PropertyField(SerializedProperty property, GUIContent label, XNode.NodePort port, bool includeChildren = true, params GUILayoutOption[] options) { if (property == null) throw new NullReferenceException(); - + // If property is not a port, display a regular property field if (port == null) EditorGUILayout.PropertyField(property, label, includeChildren, GUILayout.MinWidth(30)); else { + + Node.LabelAttribute labelAttribute; + + if (NodeEditorUtilities.GetCachedAttrib(port.node.GetType(), property.name, out labelAttribute)) + { + if (label != null) + { + label.text = labelAttribute.Label; + } + else + { + label = new GUIContent(labelAttribute.Label); + } + } + Rect rect = new Rect(); float spacePadding = 0; From 84c1e9e14dfd50eda17a4b0a8ca0ab34d2dccc5a Mon Sep 17 00:00:00 2001 From: Icarus <1375400884@qq.com> Date: Tue, 3 Dec 2019 18:42:38 +0800 Subject: [PATCH 36/65] !TX todo --- Scripts/Editor/NodeEditorAction.cs | 6 +++++- Scripts/Editor/NodeEditorGUI.cs | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Scripts/Editor/NodeEditorAction.cs b/Scripts/Editor/NodeEditorAction.cs index c919c9b..47a6a7f 100644 --- a/Scripts/Editor/NodeEditorAction.cs +++ b/Scripts/Editor/NodeEditorAction.cs @@ -207,7 +207,11 @@ namespace XNodeEditor { //If connection is valid, save it if (draggedOutputTarget != null) { XNode.Node node = draggedOutputTarget.node; - if (graph.nodes.Count != 0) draggedOutput.Connect(draggedOutputTarget); + if (graph.nodes.Count != 0) + { + //todo Connect Callback 2019.12.3 18点38分 + draggedOutput.Connect(draggedOutputTarget); + } // ConnectionIndex can be -1 if the connection is removed instantly after creation int connectionIndex = draggedOutput.GetConnectionIndex(draggedOutputTarget); diff --git a/Scripts/Editor/NodeEditorGUI.cs b/Scripts/Editor/NodeEditorGUI.cs index a734bd8..e6359c7 100644 --- a/Scripts/Editor/NodeEditorGUI.cs +++ b/Scripts/Editor/NodeEditorGUI.cs @@ -125,7 +125,11 @@ namespace XNodeEditor { /// Show right-click context menu for hovered port void ShowPortContextMenu(XNode.NodePort hoveredPort) { GenericMenu contextMenu = new GenericMenu(); - contextMenu.AddItem(new GUIContent("Clear Connections"), false, () => hoveredPort.ClearConnections()); + contextMenu.AddItem(new GUIContent("Clear Connections"), false, () => + { + //todo Remove Connect Callback 2019.12.3 18点41分 + hoveredPort.ClearConnections(); + }); if (hoveredPort.IsDynamic) { contextMenu.AddItem(new GUIContent("Remove"), false, () => hoveredPort.node.RemoveDynamicPort(hoveredPort)); From 62133630de7308d40b354a16524f94e393d66d0c Mon Sep 17 00:00:00 2001 From: Icarus <1375400884@qq.com> Date: Tue, 3 Dec 2019 20:57:00 +0800 Subject: [PATCH 37/65] !TX remove todo --- Scripts/Editor/NodeEditorAction.cs | 6 +----- Scripts/Editor/NodeEditorGUI.cs | 6 +----- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/Scripts/Editor/NodeEditorAction.cs b/Scripts/Editor/NodeEditorAction.cs index 47a6a7f..c919c9b 100644 --- a/Scripts/Editor/NodeEditorAction.cs +++ b/Scripts/Editor/NodeEditorAction.cs @@ -207,11 +207,7 @@ namespace XNodeEditor { //If connection is valid, save it if (draggedOutputTarget != null) { XNode.Node node = draggedOutputTarget.node; - if (graph.nodes.Count != 0) - { - //todo Connect Callback 2019.12.3 18点38分 - draggedOutput.Connect(draggedOutputTarget); - } + if (graph.nodes.Count != 0) draggedOutput.Connect(draggedOutputTarget); // ConnectionIndex can be -1 if the connection is removed instantly after creation int connectionIndex = draggedOutput.GetConnectionIndex(draggedOutputTarget); diff --git a/Scripts/Editor/NodeEditorGUI.cs b/Scripts/Editor/NodeEditorGUI.cs index e6359c7..8a3e076 100644 --- a/Scripts/Editor/NodeEditorGUI.cs +++ b/Scripts/Editor/NodeEditorGUI.cs @@ -125,11 +125,7 @@ namespace XNodeEditor { /// Show right-click context menu for hovered port void ShowPortContextMenu(XNode.NodePort hoveredPort) { GenericMenu contextMenu = new GenericMenu(); - contextMenu.AddItem(new GUIContent("Clear Connections"), false, () => - { - //todo Remove Connect Callback 2019.12.3 18点41分 - hoveredPort.ClearConnections(); - }); + contextMenu.AddItem(new GUIContent("Clear Connections"), false, hoveredPort.ClearConnections); if (hoveredPort.IsDynamic) { contextMenu.AddItem(new GUIContent("Remove"), false, () => hoveredPort.node.RemoveDynamicPort(hoveredPort)); From 15ef25888cb7f0a6cbf6252e7df2d5d21e191e85 Mon Sep 17 00:00:00 2001 From: Icarus <1375400884@qq.com> Date: Tue, 3 Dec 2019 22:30:35 +0800 Subject: [PATCH 38/65] !TX --- Scripts/Editor/NodeGraphEditor.cs | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/Scripts/Editor/NodeGraphEditor.cs b/Scripts/Editor/NodeGraphEditor.cs index 95a7cdd..a16ca83 100644 --- a/Scripts/Editor/NodeGraphEditor.cs +++ b/Scripts/Editor/NodeGraphEditor.cs @@ -233,22 +233,6 @@ namespace XNodeEditor { break; } } - - private void _action() - { - Event e = Event.current; - switch (e.type) - { - case EventType.KeyDown: - - if (e.keyCode == KeyCode.DownArrow && !HasFocus()) - { - this.SetFocusAndEnsureSelectedItem(); - e.Use(); - } - break; - } - } } /// Base class to derive custom Node Graph editors from. Use this to override how graphs are drawn in the editor. From fe313be5ee0612132e37077162528d251957157a Mon Sep 17 00:00:00 2001 From: Icarus <1375400884@qq.com> Date: Wed, 4 Dec 2019 10:33:49 +0800 Subject: [PATCH 39/65] !B NullReferenceException --- Scripts/Editor/NodeGraphEditor.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Scripts/Editor/NodeGraphEditor.cs b/Scripts/Editor/NodeGraphEditor.cs index a16ca83..b7f2077 100644 --- a/Scripts/Editor/NodeGraphEditor.cs +++ b/Scripts/Editor/NodeGraphEditor.cs @@ -253,7 +253,7 @@ namespace XNodeEditor { foreach (var targetNode in target.nodes) { var editor = NodeEditor.GetEditor(targetNode, window); - editor.OnInit(); + editor?.OnInit(); } } From 17eb6cdae19b9e64b4b91249d7b6528485f0c7bb Mon Sep 17 00:00:00 2001 From: Icarus <1375400884@qq.com> Date: Sun, 8 Dec 2019 17:28:47 +0800 Subject: [PATCH 40/65] =?UTF-8?q?!W(Node=20Port)=20`=5FfieldName`=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E5=A2=9E=E5=8A=A0=E4=B8=80=E4=B8=AA=E5=B8=B8=E9=87=8F?= =?UTF-8?q?=E6=8F=90=E4=BE=9B=E7=BB=99Editor=E4=BD=BF=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Scripts/NodePort.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Scripts/NodePort.cs b/Scripts/NodePort.cs index dc69313..d8a36b6 100644 --- a/Scripts/NodePort.cs +++ b/Scripts/NodePort.cs @@ -60,6 +60,9 @@ namespace XNode { private Type valueType; private Type _typeConstraintBaseType; +#if UNITY_EDITOR + public const string FieldNameEditor = nameof(_fieldName); +#endif [SerializeField] private string _fieldName; [SerializeField] private Node _node; [SerializeField] private string _typeQualifiedName; From ec7133d862bf21e6fde29988fba1b3c1a66227fd Mon Sep 17 00:00:00 2001 From: Icarus <1375400884@qq.com> Date: Sun, 8 Dec 2019 21:00:06 +0800 Subject: [PATCH 41/65] =?UTF-8?q?!W(Node)=20`output`=E5=8A=A8=E6=80=81?= =?UTF-8?q?=E7=AB=AF=E5=8F=A3=E6=B0=B8=E8=BF=9C=E5=9C=A8=E6=9C=80=E5=90=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Scripts/Node.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Scripts/Node.cs b/Scripts/Node.cs index 27f208d..66906b5 100644 --- a/Scripts/Node.cs +++ b/Scripts/Node.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using UnityEngine; namespace XNode { @@ -168,7 +169,9 @@ namespace XNode { return ports[fieldName]; } NodePort port = new NodePort(fieldName, type, direction, connectionType, typeConstraint,baseType, this); + ports.Add(fieldName, port); + return port; } @@ -394,6 +397,19 @@ namespace XNode { keys.Clear(); values.Clear(); foreach (KeyValuePair pair in this) { + + if (pair.Value.direction == NodePort.IO.Input) + { + var firstOutIndex = values.FindIndex(x => x.direction == NodePort.IO.Output); + + if (firstOutIndex > -1) + { + keys.Insert(firstOutIndex,pair.Key); + values.Insert(firstOutIndex,pair.Value); + continue; + } + } + keys.Add(pair.Key); values.Add(pair.Value); } From 2bcfbc85a4c61c89aa737b480d4e6cd2ad9dfa13 Mon Sep 17 00:00:00 2001 From: Icarus <1375400884@qq.com> Date: Sun, 8 Dec 2019 21:03:02 +0800 Subject: [PATCH 42/65] =?UTF-8?q?!W(NodePort)=20=E5=88=B7=E6=96=B0ValueTyp?= =?UTF-8?q?e,=E5=A4=96=E9=83=A8=E9=80=9A=E8=BF=87`SerializedProperty`?= =?UTF-8?q?=E6=94=B9=E5=8F=98=E4=BA=86port=E7=9A=84=E9=A1=BA=E5=BA=8F,?= =?UTF-8?q?=E4=BD=86=E6=98=AF=E5=AE=9E=E4=BE=8B=E7=9A=84valueType=E8=BF=98?= =?UTF-8?q?=E6=98=AF=E8=80=81=E7=9A=84,=E6=89=80=E4=BB=A5=E5=88=B6?= =?UTF-8?q?=E7=A9=BA=E4=B8=80=E4=B8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Scripts/NodePort.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Scripts/NodePort.cs b/Scripts/NodePort.cs index d8a36b6..b6fadb4 100644 --- a/Scripts/NodePort.cs +++ b/Scripts/NodePort.cs @@ -32,6 +32,14 @@ namespace XNode { public Node node { get { return _node; } } public bool IsDynamic { get { return _dynamic; } } public bool IsStatic { get { return !_dynamic; } } + +#if UNITY_EDITOR + public void RefreshValueType() + { + valueType = null; + } +#endif + public Type ValueType { get { if (valueType == null && !string.IsNullOrEmpty(_typeQualifiedName)) valueType = Type.GetType(_typeQualifiedName, false); From eb7c9098e9fc045b9fee507e794f255e5baf051c Mon Sep 17 00:00:00 2001 From: Icarus <1375400884@qq.com> Date: Sun, 8 Dec 2019 21:04:50 +0800 Subject: [PATCH 43/65] =?UTF-8?q?!R(Dynamic=20Port=20List)=20=E9=A1=BA?= =?UTF-8?q?=E5=BA=8F=E6=94=B9=E5=8F=98,=E8=BF=99=E6=AC=A1=E9=87=8D?= =?UTF-8?q?=E5=86=99=E5=BA=94=E8=AF=A5=E5=86=8D=E4=B9=9F=E4=B8=8D=E4=BC=9A?= =?UTF-8?q?=E5=87=BA=E7=8E=B0=E6=9C=AA=E7=9F=A5=E7=9A=84=E9=94=99=E8=AF=AF?= =?UTF-8?q?=3D-=3D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Scripts/Editor/NodeEditorGUILayout.cs | 46 +++++++++++++++++---------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/Scripts/Editor/NodeEditorGUILayout.cs b/Scripts/Editor/NodeEditorGUILayout.cs index 857672a..bd9e71d 100644 --- a/Scripts/Editor/NodeEditorGUILayout.cs +++ b/Scripts/Editor/NodeEditorGUILayout.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections; using System.Collections.Generic; using System.Linq; @@ -397,28 +397,42 @@ namespace XNodeEditor { list.onReorderCallbackWithDetails = (reorderableList, index, newIndex) => { - var port = serializedObject.FindProperty(Node.PortFieldName); - SerializedProperty keys = port.FindPropertyRelative(Node.KeysFieldName); - SerializedProperty values = port.FindPropertyRelative(Node.ValuesFieldName); - var count = 0; - - foreach (var nodePort in node.Ports) + var portSer = serializedObject.FindProperty(Node.PortFieldName); + SerializedProperty keys = portSer.FindPropertyRelative(Node.KeysFieldName); + SerializedProperty values = portSer.FindPropertyRelative(Node.ValuesFieldName); + + var baseIndex = 0; + + if (io == NodePort.IO.Output) { - if (!reorderableList.list.Contains(nodePort)) + foreach (var nodePort in node.Ports) { - count++; + if (nodePort.direction == NodePort.IO.Input) + { + baseIndex++; - continue; - } + continue; + } - //list after May exist dynamic node so break - break; + break; + } + + baseIndex++; } - - index += count; - newIndex += count; + + index += baseIndex; + newIndex += baseIndex; keys.MoveArrayElement(index, newIndex); values.MoveArrayElement(index, newIndex); + serializedObject.ApplyModifiedProperties(); + EditorUtility.SetDirty(node); + serializedObject.Update(); + NodeEditorWindow.current.Repaint(); + EditorApplication.delayCall += NodeEditorWindow.current.Repaint; + foreach (NodePort port in reorderableList.list) + { + port.RefreshValueType(); + } }; list.onAddCallback = From 259a70d8125a3c7ba3231fcabdcf7983a7e7a853 Mon Sep 17 00:00:00 2001 From: Icarus <1375400884@qq.com> Date: Sun, 8 Dec 2019 22:15:07 +0800 Subject: [PATCH 44/65] =?UTF-8?q?!B(Node=20Port)=20=E7=9B=B8=E5=90=8C?= =?UTF-8?q?=E8=8A=82=E7=82=B9,=E7=9B=B8=E5=90=8C=E7=AB=AF=E5=8F=A3?= =?UTF-8?q?=E8=BF=9E=E6=8E=A5=E4=B8=8D=E6=96=AD=E5=BC=80=E9=93=BE=E6=8E=A5?= =?UTF-8?q?=E5=90=8C=E6=97=B6=E4=B9=9F=E4=B8=8D=E8=BF=9B=E8=A1=8C=E8=BF=9E?= =?UTF-8?q?=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Scripts/NodePort.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Scripts/NodePort.cs b/Scripts/NodePort.cs index b6fadb4..c186810 100644 --- a/Scripts/NodePort.cs +++ b/Scripts/NodePort.cs @@ -231,7 +231,17 @@ namespace XNode { if (IsConnectedTo(port)) { Debug.LogWarning("Port already connected. "); return; } if (direction == port.direction) { Debug.LogWarning("Cannot connect two " + (direction == IO.Input ? "input" : "output") + " connections"); return; } if (port.connectionType == Node.ConnectionType.Override && port.ConnectionCount != 0) { port.ClearConnections(); } - if (connectionType == Node.ConnectionType.Override && ConnectionCount != 0) { ClearConnections(); } + + if (connectionType == Node.ConnectionType.Override && ConnectionCount != 0) + { + var conPort = GetConnection(0); + + if(conPort.node != port.node || conPort != port) + { + ClearConnections(); + } + return; + } connections.Add(new PortConnection(port)); if (port.connections == null) port.connections = new List(); if (!port.IsConnectedTo(this)) port.connections.Add(new PortConnection(this)); From a749defa2445a32e4fb3e910197abd875177105f Mon Sep 17 00:00:00 2001 From: Icarus <1375400884@qq.com> Date: Sun, 8 Dec 2019 22:15:34 +0800 Subject: [PATCH 45/65] !TX --- Scripts/Editor/NodeEditorGUILayout.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Scripts/Editor/NodeEditorGUILayout.cs b/Scripts/Editor/NodeEditorGUILayout.cs index bd9e71d..08423e1 100644 --- a/Scripts/Editor/NodeEditorGUILayout.cs +++ b/Scripts/Editor/NodeEditorGUILayout.cs @@ -427,12 +427,14 @@ namespace XNodeEditor { serializedObject.ApplyModifiedProperties(); EditorUtility.SetDirty(node); serializedObject.Update(); - NodeEditorWindow.current.Repaint(); - EditorApplication.delayCall += NodeEditorWindow.current.Repaint; + foreach (NodePort port in reorderableList.list) { port.RefreshValueType(); } + + NodeEditorWindow.current.Repaint(); + EditorApplication.delayCall += NodeEditorWindow.current.Repaint; }; list.onAddCallback = From cf6cddeae5ce6595ee1811a30b71b8b07cebc649 Mon Sep 17 00:00:00 2001 From: Icarus <1375400884@qq.com> Date: Mon, 9 Dec 2019 11:10:25 +0800 Subject: [PATCH 46/65] =?UTF-8?q?!BO(Menu=20Tree=20View)=20=E5=8F=AF?= =?UTF-8?q?=E8=83=BD=E4=BC=9A=E5=87=BA=E7=8E=B0=E5=A4=9A=E4=B8=AA=E7=9B=B8?= =?UTF-8?q?=E5=90=8C=E8=8F=9C=E5=8D=95,=E5=88=A0=E9=99=A4=E4=BA=86`OnFocus?= =?UTF-8?q?`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Scripts/Editor/NodeGraphEditor.cs | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/Scripts/Editor/NodeGraphEditor.cs b/Scripts/Editor/NodeGraphEditor.cs index b7f2077..99986fd 100644 --- a/Scripts/Editor/NodeGraphEditor.cs +++ b/Scripts/Editor/NodeGraphEditor.cs @@ -156,6 +156,17 @@ namespace XNodeEditor { break; } + if (last.hasChildren) + { + foreach (var child in last.children) + { + if (child.displayName == path) + { + return; + } + } + } + var temp = new TreeViewItem(_id++,depth++,path); last.AddChild(temp); @@ -248,15 +259,6 @@ namespace XNodeEditor { /// Called when opened by NodeEditorWindow public virtual void OnOpen() { } - public virtual void OnFocus() - { - foreach (var targetNode in target.nodes) - { - var editor = NodeEditor.GetEditor(targetNode, window); - editor?.OnInit(); - } - } - public virtual Texture2D GetGridTexture() { return NodeEditorPreferences.GetSettings().gridTexture; } From cf59838dd0be5ec3a89631609e388d6a77839225 Mon Sep 17 00:00:00 2001 From: Icarus <1375400884@qq.com> Date: Mon, 9 Dec 2019 11:11:47 +0800 Subject: [PATCH 47/65] !O --- Scripts/Editor/NodeEditorAction.cs | 19 ++++++++++--------- Scripts/Editor/NodeEditorWindow.cs | 1 - 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Scripts/Editor/NodeEditorAction.cs b/Scripts/Editor/NodeEditorAction.cs index c919c9b..63e1439 100644 --- a/Scripts/Editor/NodeEditorAction.cs +++ b/Scripts/Editor/NodeEditorAction.cs @@ -32,8 +32,14 @@ namespace XNodeEditor { private Rect selectionBox; private bool isDoubleClick = false; private Vector2 lastMousePosition; + private MenuPopupWindow _menuPopupWindow; public void Controls() { + if (_menuPopupWindow == null) + { + _menuPopupWindow = new MenuPopupWindow(); + graphEditor.AddContextMenuItems(_menuPopupWindow); + } wantsMouseMove = true; Event e = Event.current; switch (e.type) { @@ -219,12 +225,9 @@ namespace XNodeEditor { } // Open context menu for auto-connection else if (NodeEditorPreferences.GetSettings().dragToCreate && autoConnectOutput != null) { - MenuPopupWindow menu = new MenuPopupWindow(); - graphEditor.AddContextMenuItems(menu); + _menuPopupWindow.OnCloseA = _releaseDraggedConnection; - menu.OnCloseA += _releaseDraggedConnection; - - PopupWindow.Show(new Rect(Event.current.mousePosition, Vector2.zero),menu); + PopupWindow.Show(new Rect(Event.current.mousePosition, Vector2.zero),_menuPopupWindow); } _releaseDraggedConnection(); @@ -281,10 +284,8 @@ namespace XNodeEditor { menu.DropDown(new Rect(Event.current.mousePosition, Vector2.zero)); e.Use(); // Fixes copy/paste context menu appearing in Unity 5.6.6f2 - doesn't occur in 2018.3.2f1 Probably needs to be used in other places. } else if (!IsHoveringNode) { - autoConnectOutput = null; - MenuPopupWindow menu = new MenuPopupWindow(); - graphEditor.AddContextMenuItems(menu); - PopupWindow.Show(new Rect(Event.current.mousePosition, Vector2.zero),menu); + autoConnectOutput = null; + PopupWindow.Show(new Rect(Event.current.mousePosition, Vector2.zero),_menuPopupWindow); } } isPanning = false; diff --git a/Scripts/Editor/NodeEditorWindow.cs b/Scripts/Editor/NodeEditorWindow.cs index 8c8f8bb..a1b222d 100644 --- a/Scripts/Editor/NodeEditorWindow.cs +++ b/Scripts/Editor/NodeEditorWindow.cs @@ -106,7 +106,6 @@ namespace XNodeEditor { void OnFocus() { current = this; ValidateGraphEditor(); - graphEditor?.OnFocus(); if (graphEditor != null && NodeEditorPreferences.GetSettings().autoSave) AssetDatabase.SaveAssets(); } From 210cb331053e811be7df2f8ccca94a01058b6e55 Mon Sep 17 00:00:00 2001 From: Icarus <1375400884@qq.com> Date: Mon, 9 Dec 2019 13:42:02 +0800 Subject: [PATCH 48/65] !B(Node Editor Window) multi open NullPointerException --- Scripts/Editor/NodeEditorWindow.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Scripts/Editor/NodeEditorWindow.cs b/Scripts/Editor/NodeEditorWindow.cs index a1b222d..201a26d 100644 --- a/Scripts/Editor/NodeEditorWindow.cs +++ b/Scripts/Editor/NodeEditorWindow.cs @@ -241,11 +241,13 @@ namespace XNodeEditor { { w = CreateWindow("xNode"); } - + w.Show(true); w.Focus(); w.wantsMouseMove = true; w.graph = graph; + NodeGraphEditor graphEditor = NodeGraphEditor.GetEditor(graph, w); + NodeEditorWindow.current.graphEditor = graphEditor; } /// Repaint all open NodeEditorWindows. From 7e4e4b6f8ec9b95868a42f385ecf58e5f9c50d21 Mon Sep 17 00:00:00 2001 From: Icarus <1375400884@qq.com> Date: Mon, 9 Dec 2019 14:06:55 +0800 Subject: [PATCH 49/65] !TX --- Scripts/Editor/NodeEditorPreferences.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Scripts/Editor/NodeEditorPreferences.cs b/Scripts/Editor/NodeEditorPreferences.cs index 2bc42f7..4020850 100644 --- a/Scripts/Editor/NodeEditorPreferences.cs +++ b/Scripts/Editor/NodeEditorPreferences.cs @@ -120,11 +120,6 @@ namespace XNodeEditor { if (GUILayout.Button(new GUIContent("XNode Documentation", "https://github.com/Siccity/xNode/wiki"), GUILayout.Width(180))) Application.OpenURL("https://github.com/Siccity/xNode/wiki"); - - if (GUILayout.Button( - new GUIContent("IcSkill Documentation", "https://github.com/yika-aixi/IcSkillSystem"), - GUILayout.Width(180))) - Application.OpenURL("https://github.com/yika-aixi/IcSkillSystem"); } EditorGUILayout.Space(); } From c0b80b59da0ea2d0ec1071d8c05e44ca892c31a0 Mon Sep 17 00:00:00 2001 From: Icarus <1375400884@qq.com> Date: Mon, 9 Dec 2019 15:51:47 +0800 Subject: [PATCH 50/65] !B(Create Node) pos error --- Scripts/Editor/NodeEditorAction.cs | 3 ++- Scripts/Editor/NodeGraphEditor.cs | 12 ++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Scripts/Editor/NodeEditorAction.cs b/Scripts/Editor/NodeEditorAction.cs index 920c1dc..40bea2f 100644 --- a/Scripts/Editor/NodeEditorAction.cs +++ b/Scripts/Editor/NodeEditorAction.cs @@ -227,7 +227,7 @@ namespace XNodeEditor { // Open context menu for auto-connection else if (NodeEditorPreferences.GetSettings().dragToCreate && autoConnectOutput != null) { _menuPopupWindow.OnCloseA = _releaseDraggedConnection; - + _menuPopupWindow.OpenBeforeMousePos = e.mousePosition; PopupWindow.Show(new Rect(Event.current.mousePosition, Vector2.zero),_menuPopupWindow); } @@ -286,6 +286,7 @@ namespace XNodeEditor { e.Use(); // Fixes copy/paste context menu appearing in Unity 5.6.6f2 - doesn't occur in 2018.3.2f1 Probably needs to be used in other places. } else if (!IsHoveringNode) { autoConnectOutput = null; + _menuPopupWindow.OpenBeforeMousePos = e.mousePosition; PopupWindow.Show(new Rect(Event.current.mousePosition, Vector2.zero),_menuPopupWindow); } } diff --git a/Scripts/Editor/NodeGraphEditor.cs b/Scripts/Editor/NodeGraphEditor.cs index 92e13e6..a7adf05 100644 --- a/Scripts/Editor/NodeGraphEditor.cs +++ b/Scripts/Editor/NodeGraphEditor.cs @@ -8,6 +8,7 @@ using UnityEngine; namespace XNodeEditor { public class MenuPopupWindow : PopupWindowContent { + public Vector2 OpenBeforeMousePos; private SearchField _search; private MenuTreeView _menuTree; public Action OnCloseA; @@ -293,13 +294,18 @@ namespace XNodeEditor { if (string.IsNullOrEmpty(path)) continue; menu.AddItem(path, () => { + pos = NodeEditorWindow.current.WindowToGridPosition(menu.OpenBeforeMousePos); XNode.Node node = CreateNode(type, pos); NodeEditorWindow.current.AutoConnect(node); }); } // menu.AddSeparator(""); if (NodeEditorWindow.copyBuffer != null && NodeEditorWindow.copyBuffer.Length > 0) - menu.AddItem("Paste", () => NodeEditorWindow.current.PasteNodes(pos)); + menu.AddItem("Paste", () => + { + pos = NodeEditorWindow.current.WindowToGridPosition(menu.OpenBeforeMousePos); + NodeEditorWindow.current.PasteNodes(pos); + }); // else menu.AddDisabledItem(new GUIContent("Paste")); menu.AddItem("Preferences", () => NodeEditorReflection.OpenPreferences()); menu.AddItem("创建所有的节点 ---> 测试用", () => @@ -308,7 +314,9 @@ namespace XNodeEditor { { return; } - + + pos = NodeEditorWindow.current.WindowToGridPosition(menu.OpenBeforeMousePos); + for (int i = 0; i < NodeEditorReflection.nodeTypes.Length; i++) { Type type = NodeEditorReflection.nodeTypes[i]; From 7624d4ad1fe5ac8cb465674d82c89be8f87a8b81 Mon Sep 17 00:00:00 2001 From: Icarus <1375400884@qq.com> Date: Sat, 21 Dec 2019 20:47:18 +0800 Subject: [PATCH 51/65] !OA(Menu Popup Window) Move to MenuPopup folder --- Scripts/Editor/MenuPopup/MenuPopupWindow.cs | 101 ++++++++ Scripts/Editor/MenuPopup/MenuTreeView.cs | 169 +++++++++++++ Scripts/Editor/NodeGraphEditor.cs | 252 +------------------- 3 files changed, 274 insertions(+), 248 deletions(-) create mode 100644 Scripts/Editor/MenuPopup/MenuPopupWindow.cs create mode 100644 Scripts/Editor/MenuPopup/MenuTreeView.cs diff --git a/Scripts/Editor/MenuPopup/MenuPopupWindow.cs b/Scripts/Editor/MenuPopup/MenuPopupWindow.cs new file mode 100644 index 0000000..ef9c61b --- /dev/null +++ b/Scripts/Editor/MenuPopup/MenuPopupWindow.cs @@ -0,0 +1,101 @@ +using System; +using UnityEditor; +using UnityEditor.IMGUI.Controls; +using UnityEngine; + +namespace XNodeEditor +{ + /// + /// Menu Popup Window + /// + public class MenuPopupWindow : PopupWindowContent + { + public Vector2 OpenBeforeMousePos; + private SearchField _search; + private MenuTreeView _menuTree; + public Action OnCloseA; + public MenuPopupWindow() + { + _search = new SearchField(); + _menuTree = new MenuTreeView(); + } + + private bool _isInit; + + /// + /// Add Item + /// + /// Item Path + /// + /// Path separator + /// Automatically close window after selecting an item + public void AddItem(string menuPath, Action onClick, char symbol = '/',bool autoClose = true) + { + _menuTree.AddItem(menuPath, () => + { + onClick?.Invoke(); + if (autoClose) + { + editorWindow.Close(); + } + },symbol); + } + + /// + /// Init or Reload Tree + /// + public void Init() + { + _menuTree.Reload(); + _isInit = true; + } + + public override void OnOpen() + { + _search.SetFocus(); + } + + public override void OnClose() + { + OnCloseA?.Invoke(); + } + + private string _str; + public override void OnGUI(Rect rect) + { + if (!_isInit) + { + Init(); + } + + _action(); + + EditorGUI.BeginChangeCheck(); + { + _str = _search.OnGUI(new Rect(rect.position, new Vector2(rect.width, 20)),_str); + } + if (EditorGUI.EndChangeCheck()) + { + _menuTree.searchString = _str; + } + + _menuTree.OnGUI(new Rect(new Vector2(0,25),rect.size - new Vector2(0,20))); + } + + private void _action() + { + Event e = Event.current; + switch (e.type) + { + case EventType.KeyDown: + + if (e.keyCode == KeyCode.DownArrow && !_menuTree.HasFocus()) + { + _menuTree.SetFocusAndEnsureSelectedItem(); + e.Use(); + } + break; + } + } + } +} \ No newline at end of file diff --git a/Scripts/Editor/MenuPopup/MenuTreeView.cs b/Scripts/Editor/MenuPopup/MenuTreeView.cs new file mode 100644 index 0000000..79c880c --- /dev/null +++ b/Scripts/Editor/MenuPopup/MenuTreeView.cs @@ -0,0 +1,169 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using UnityEditor.IMGUI.Controls; +using UnityEngine; + +namespace XNodeEditor +{ + public class MenuTreeView:TreeView + { + class MenuItem:TreeViewItem + { + public readonly Action OnClick; + + public MenuItem(int id, int depth, string displayName, Action onClick) : base(id, depth, displayName) + { + OnClick = onClick; + } + } + + public TreeViewItem Root { get; } + + public MenuTreeView():this(new TreeViewState()) + { + } + + public MenuTreeView(TreeViewState state, MultiColumnHeader multiColumnHeader = null) : base(state, multiColumnHeader) + { + Root = new TreeViewItem(_id++,-1,nameof(Root)); + } + + private int _id = -1; + + private Dictionary> _menuCache = new Dictionary>(); + + /// + /// + /// + /// + /// + /// + public void AddItem(string menuPath,Action onClick,char symbol = '/') + { + var paths = menuPath.Split(symbol); + + int depth = 0; + + TreeViewItem last = Root; + + if (paths.Length > 1) + { + for (var i = 0; i < paths.Length - 1; i++) + { + var path = paths[i]; + + if (!_menuCache.TryGetValue(depth, out var caches)) + { + caches = new List(); + _menuCache.Add(depth, caches); + } + + while (true) + { + if (last.hasChildren) + { + foreach (var item in last.children) + { + if (item.displayName == path) + { + last = item; + depth++; + goto end; + } + } + } + + break; + } + + if (last.hasChildren) + { + foreach (var child in last.children) + { + if (child.displayName == path) + { + return; + } + } + } + + var temp = new TreeViewItem(_id++,depth++,path); + + last.AddChild(temp); + + last = temp; + + end: ; + } + } + + last.AddChild(new MenuItem(_id++,depth,paths.Last(),onClick)); + } + + protected override bool DoesItemMatchSearch(TreeViewItem item, string search) + { + if (item.parent != null && item.parent.displayName.IndexOf(search, StringComparison.OrdinalIgnoreCase) >= 0) + { + return true; + } + + return base.DoesItemMatchSearch(item, search); + } + + List _ids = new List(); + protected override void DoubleClickedItem(int id) + { + var item = FindItem(id,Root); + if (item.hasChildren) + { + if (hasSearch) + { + searchString = ""; + + _ids.Clear(); + + while (item != null) + { + _ids.Add(item.id); + item = item.parent; + } + + SetExpanded(_ids); + } + else + { + SetExpanded(id, !IsExpanded(id)); + } + } + else + { + if (item is MenuItem menuItem) + { + menuItem.OnClick?.Invoke(); + } + } + } + + protected override TreeViewItem BuildRoot() + { + return Root; + } + + protected override void KeyEvent() + { + Event e = Event.current; + switch (e.type) + { + case EventType.KeyDown: + + if (e.keyCode == KeyCode.Return || e.keyCode == KeyCode.KeypadEnter) + { + DoubleClickedItem(GetSelection()[0]); + e.Use(); + } + break; + } + } + } +} \ No newline at end of file diff --git a/Scripts/Editor/NodeGraphEditor.cs b/Scripts/Editor/NodeGraphEditor.cs index a7adf05..0eb2a62 100644 --- a/Scripts/Editor/NodeGraphEditor.cs +++ b/Scripts/Editor/NodeGraphEditor.cs @@ -1,252 +1,8 @@ using System; -using System.Collections.Generic; -using System.Linq; using UnityEditor; -using UnityEditor.IMGUI.Controls; using UnityEngine; namespace XNodeEditor { - public class MenuPopupWindow : PopupWindowContent - { - public Vector2 OpenBeforeMousePos; - private SearchField _search; - private MenuTreeView _menuTree; - public Action OnCloseA; - public MenuPopupWindow() - { - _search = new SearchField(); - _menuTree = new MenuTreeView(); - } - - private bool _isInit; - - public void AddItem(string menuPath, Action onClick, char symbol = '/',bool autoClose = true) - { - _menuTree.AddItem(menuPath, () => - { - onClick?.Invoke(); - if (autoClose) - { - editorWindow.Close(); - } - },symbol); - } - - public void Init() - { - _menuTree.Reload(); - _isInit = true; - } - - public override void OnOpen() - { - _search.SetFocus(); - } - - public override void OnClose() - { - OnCloseA?.Invoke(); - } - - private string _str; - public override void OnGUI(Rect rect) - { - if (!_isInit) - { - Init(); - } - - _action(); - - EditorGUI.BeginChangeCheck(); - { - _str = _search.OnGUI(new Rect(rect.position, new Vector2(rect.width, 20)),_str); - } - if (EditorGUI.EndChangeCheck()) - { - _menuTree.searchString = _str; - } - - _menuTree.OnGUI(new Rect(new Vector2(0,25),rect.size - new Vector2(0,20))); - } - - private void _action() - { - Event e = Event.current; - switch (e.type) - { - case EventType.KeyDown: - - if (e.keyCode == KeyCode.DownArrow && !_menuTree.HasFocus()) - { - _menuTree.SetFocusAndEnsureSelectedItem(); - e.Use(); - } - break; - } - } - } - public class MenuTreeView:TreeView - { - class MenuItem:TreeViewItem - { - public readonly Action OnClick; - - public MenuItem(int id, int depth, string displayName, Action onClick) : base(id, depth, displayName) - { - OnClick = onClick; - } - } - - public TreeViewItem Root { get; } - - public MenuTreeView():this(new TreeViewState()) - { - } - - public MenuTreeView(TreeViewState state, MultiColumnHeader multiColumnHeader = null) : base(state, multiColumnHeader) - { - Root = new TreeViewItem(_id++,-1,nameof(Root)); - } - - private int _id = -1; - - private Dictionary> _menuCache = new Dictionary>(); - - /// - /// - /// - /// - /// - /// - public void AddItem(string menuPath,Action onClick,char symbol = '/') - { - var paths = menuPath.Split(symbol); - - int depth = 0; - - TreeViewItem last = Root; - - if (paths.Length > 1) - { - for (var i = 0; i < paths.Length - 1; i++) - { - var path = paths[i]; - - if (!_menuCache.TryGetValue(depth, out var caches)) - { - caches = new List(); - _menuCache.Add(depth, caches); - } - - while (true) - { - if (last.hasChildren) - { - foreach (var item in last.children) - { - if (item.displayName == path) - { - last = item; - depth++; - goto end; - } - } - } - - break; - } - - if (last.hasChildren) - { - foreach (var child in last.children) - { - if (child.displayName == path) - { - return; - } - } - } - - var temp = new TreeViewItem(_id++,depth++,path); - - last.AddChild(temp); - - last = temp; - - end: ; - } - } - - last.AddChild(new MenuItem(_id++,depth,paths.Last(),onClick)); - } - - protected override bool DoesItemMatchSearch(TreeViewItem item, string search) - { - if (item.parent != null && item.parent.displayName.IndexOf(search, StringComparison.OrdinalIgnoreCase) >= 0) - { - return true; - } - - return base.DoesItemMatchSearch(item, search); - } - - List _ids = new List(); - protected override void DoubleClickedItem(int id) - { - var item = FindItem(id,Root); - if (item.hasChildren) - { - if (hasSearch) - { - searchString = ""; - - _ids.Clear(); - - while (item != null) - { - _ids.Add(item.id); - item = item.parent; - } - - SetExpanded(_ids); - } - else - { - SetExpanded(id, !IsExpanded(id)); - } - } - else - { - if (item is MenuItem menuItem) - { - menuItem.OnClick?.Invoke(); - } - } - } - - protected override TreeViewItem BuildRoot() - { - return Root; - } - - protected override void KeyEvent() - { - Event e = Event.current; - switch (e.type) - { - case EventType.KeyDown: - - if (e.keyCode == KeyCode.Return || e.keyCode == KeyCode.KeypadEnter) - { - DoubleClickedItem(GetSelection()[0]); - e.Use(); - } - break; - } - } - } - /// Base class to derive custom Node Graph editors from. Use this to override how graphs are drawn in the editor. [CustomNodeGraphEditor(typeof(XNode.NodeGraph))] public class NodeGraphEditor : XNodeEditor.Internal.NodeEditorBase { @@ -299,16 +55,16 @@ namespace XNodeEditor { NodeEditorWindow.current.AutoConnect(node); }); } -// menu.AddSeparator(""); if (NodeEditorWindow.copyBuffer != null && NodeEditorWindow.copyBuffer.Length > 0) menu.AddItem("Paste", () => { pos = NodeEditorWindow.current.WindowToGridPosition(menu.OpenBeforeMousePos); NodeEditorWindow.current.PasteNodes(pos); }); -// else menu.AddDisabledItem(new GUIContent("Paste")); + menu.AddItem("Preferences", () => NodeEditorReflection.OpenPreferences()); - menu.AddItem("创建所有的节点 ---> 测试用", () => + + menu.AddItem("Create All Node ---> Test use", () => { if (!EditorUtility.DisplayDialog("warning","Are you sure you want to create all the nodes?","ok","no")) { @@ -323,7 +79,7 @@ namespace XNodeEditor { //Get node context menu path string path = GetNodeMenuName(type); - //当前Group 不支持该节点跳过 + // skip empty path if (string.IsNullOrEmpty(path)) { continue; From 10636cd24356083ebf72084b28e2ef9ebdc6d30e Mon Sep 17 00:00:00 2001 From: Icarus <1375400884@qq.com> Date: Sat, 21 Dec 2019 20:47:59 +0800 Subject: [PATCH 52/65] !T(Port) remove baseType --- Scripts/Editor/NodeEditorGUILayout.cs | 19 +++++++------- Scripts/NodePort.cs | 37 +-------------------------- 2 files changed, 10 insertions(+), 46 deletions(-) diff --git a/Scripts/Editor/NodeEditorGUILayout.cs b/Scripts/Editor/NodeEditorGUILayout.cs index 56deb3b..b4a756a 100644 --- a/Scripts/Editor/NodeEditorGUILayout.cs +++ b/Scripts/Editor/NodeEditorGUILayout.cs @@ -314,8 +314,8 @@ namespace XNodeEditor { } [Obsolete("Use DynamicPortList instead")] - public static void InstancePortList(string fieldName, Type type, SerializedObject serializedObject, XNode.NodePort.IO io, XNode.Node.ConnectionType connectionType = XNode.Node.ConnectionType.Multiple, XNode.Node.TypeConstraint typeConstraint = XNode.Node.TypeConstraint.None,Type inputTypeConstraintBaseType = null, Action onCreation = null) { - DynamicPortList(fieldName, type, serializedObject, io, connectionType, typeConstraint, inputTypeConstraintBaseType,onCreation); + public static void InstancePortList(string fieldName, Type type, SerializedObject serializedObject, XNode.NodePort.IO io, XNode.Node.ConnectionType connectionType = XNode.Node.ConnectionType.Multiple, XNode.Node.TypeConstraint typeConstraint = XNode.Node.TypeConstraint.None, Action onCreation = null) { + DynamicPortList(fieldName, type, serializedObject, io, connectionType, typeConstraint, onCreation); } #endregion @@ -331,16 +331,16 @@ namespace XNodeEditor { return false; } - /// Draw an editable list of dynamic ports. Port names are named as "[fieldName] [index]" + /// Draw an editable list of dynamic ports. /// Supply a list for editable values /// Value type of added dynamic ports /// The serializedObject of the node /// Connection type of added dynamic ports - /// 并且时可用 /// Called on the list on creation. Use this if you want to customize the created ReorderableList + /// Return port name after adding port public static void DynamicPortList(string fieldName, Type type, SerializedObject serializedObject, XNode.NodePort.IO io, XNode.Node.ConnectionType connectionType = XNode.Node.ConnectionType.Multiple, - XNode.Node.TypeConstraint typeConstraint = XNode.Node.TypeConstraint.None,Type inputTypeConstraintBaseType = null, + XNode.Node.TypeConstraint typeConstraint = XNode.Node.TypeConstraint.None, Action onCreation = null,Action onAdd = null) { XNode.Node node = serializedObject.targetObject as XNode.Node; @@ -358,7 +358,7 @@ namespace XNodeEditor { if (list == null) { SerializedProperty arrayData = serializedObject.FindProperty(fieldName); list = CreateReorderableList(fieldName, dynamicPorts, arrayData, type, serializedObject, - io, connectionType, typeConstraint, inputTypeConstraintBaseType,onAdd); + io, connectionType, typeConstraint, onAdd); onCreation?.Invoke(list); if (reorderableListCache.TryGetValue(serializedObject.targetObject, out rlc)) rlc.Add(fieldName, list); else reorderableListCache.Add(serializedObject.targetObject, new Dictionary() { { fieldName, list } }); @@ -368,8 +368,7 @@ namespace XNodeEditor { } private static ReorderableList CreateReorderableList(string fieldName, List dynamicPorts, SerializedProperty arrayData, Type type, - SerializedObject serializedObject, XNode.NodePort.IO io, XNode.Node.ConnectionType connectionType, XNode.Node.TypeConstraint typeConstraint, - Type inputTypeConstraintBaseType,Action onAdd) { + SerializedObject serializedObject, XNode.NodePort.IO io, XNode.Node.ConnectionType connectionType, XNode.Node.TypeConstraint typeConstraint,Action onAdd) { bool hasArrayData = arrayData != null && arrayData.isArray; XNode.Node node = serializedObject.targetObject as XNode.Node; ReorderableList list = new ReorderableList(dynamicPorts, null, true, true, true, true); @@ -465,7 +464,7 @@ namespace XNodeEditor { while (node.HasPort(newName)) newName = fieldName + " " + (++i); if (io == XNode.NodePort.IO.Output) node.AddDynamicOutput(type, connectionType, XNode.Node.TypeConstraint.None, newName); - else node.AddDynamicInput(type, connectionType, typeConstraint,inputTypeConstraintBaseType, newName); + else node.AddDynamicInput(type, connectionType, typeConstraint, newName); serializedObject.Update(); EditorUtility.SetDirty(node); if (hasArrayData) { @@ -495,7 +494,7 @@ namespace XNodeEditor { int i = 0; while (node.HasPort(newName)) newName = arrayData.name + " " + (++i); if (io == XNode.NodePort.IO.Output) node.AddDynamicOutput(type, connectionType, typeConstraint,newName); - else node.AddDynamicInput(type, connectionType, typeConstraint, inputTypeConstraintBaseType,newName); + else node.AddDynamicInput(type, connectionType, typeConstraint, newName); EditorUtility.SetDirty(node); dynamicPortCount++; } diff --git a/Scripts/NodePort.cs b/Scripts/NodePort.cs index e59e036..146a8ca 100644 --- a/Scripts/NodePort.cs +++ b/Scripts/NodePort.cs @@ -51,30 +51,13 @@ namespace XNode { } } - public Type TypeConstraintBaseType { - get { - if (_typeConstraintBaseType == null && !string.IsNullOrEmpty(_typeConstraintBaseTypeQualifiedName)) - _typeConstraintBaseType = Type.GetType(_typeConstraintBaseTypeQualifiedName, false); - return _typeConstraintBaseType; - } - set { - _typeConstraintBaseType = value; - if (value != null) - { - _typeConstraintBaseTypeQualifiedName = value.AssemblyQualifiedName; - } - } - } - private Type valueType; - private Type _typeConstraintBaseType; #if UNITY_EDITOR public const string FieldNameEditor = nameof(_fieldName); #endif [SerializeField] private string _fieldName; [SerializeField] private Node _node; [SerializeField] private string _typeQualifiedName; - [SerializeField] private string _typeConstraintBaseTypeQualifiedName; [SerializeField] private List connections = new List(); [SerializeField] private IO _direction; [SerializeField] private Node.ConnectionType _connectionType; @@ -92,7 +75,6 @@ namespace XNode { _direction = IO.Input; _connectionType = (attribs[i] as Node.InputAttribute).connectionType; _typeConstraint = (attribs[i] as Node.InputAttribute).typeConstraint; - TypeConstraintBaseType = (attribs[i] as Node.InputAttribute).BaseType; } else if (attribs[i] is Node.OutputAttribute) { _direction = IO.Output; _connectionType = (attribs[i] as Node.OutputAttribute).connectionType; @@ -105,7 +87,6 @@ namespace XNode { public NodePort(NodePort nodePort, Node node) { _fieldName = nodePort._fieldName; ValueType = nodePort.valueType; - TypeConstraintBaseType = nodePort.TypeConstraintBaseType; _direction = nodePort.direction; _dynamic = nodePort._dynamic; _connectionType = nodePort._connectionType; @@ -114,10 +95,9 @@ namespace XNode { } /// Construct a dynamic port. Dynamic ports are not forgotten on reimport, and is ideal for runtime-created ports. - public NodePort(string fieldName, Type type, IO direction, Node.ConnectionType connectionType, Node.TypeConstraint typeConstraint,Type baseType, Node node) { + public NodePort(string fieldName, Type type, IO direction, Node.ConnectionType connectionType, Node.TypeConstraint typeConstraint, Node node) { _fieldName = fieldName; this.ValueType = type; - TypeConstraintBaseType = baseType; _direction = direction; _node = node; _dynamic = true; @@ -301,21 +281,6 @@ namespace XNode { else output = port; // If there isn't one of each, they can't connect if (input == null || output == null) return false; - // Check input type constraints - if (input.typeConstraint == XNode.Node.TypeConstraint.Inherited) - { - //无法分配,失败 - if (!input.ValueType.IsAssignableFrom(output.ValueType)) - { - return false; - } - - //如果存在指定基类,同时无法分配,失败 - if (input.TypeConstraintBaseType != null && !input.TypeConstraintBaseType.IsAssignableFrom(output.ValueType)) - { - return false; - } - } if (input.typeConstraint == XNode.Node.TypeConstraint.Strict && input.ValueType != output.ValueType) return false; if (input.typeConstraint == XNode.Node.TypeConstraint.InheritedInverse && !output.ValueType.IsAssignableFrom(input.ValueType)) return false; // Check output type constraints From 2a12608e3b16754fb9d72409c3a9b9914cd1e251 Mon Sep 17 00:00:00 2001 From: Icarus <1375400884@qq.com> Date: Sat, 21 Dec 2019 20:50:01 +0800 Subject: [PATCH 53/65] !TX(Port) remove baseType --- Scripts/Node.cs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Scripts/Node.cs b/Scripts/Node.cs index 4c94659..b37ead4 100644 --- a/Scripts/Node.cs +++ b/Scripts/Node.cs @@ -76,7 +76,7 @@ namespace XNode { [Obsolete("Use AddDynamicPort instead")] private NodePort AddInstancePort(Type type, NodePort.IO direction, Node.ConnectionType connectionType = Node.ConnectionType.Multiple, Node.TypeConstraint typeConstraint = TypeConstraint.None, string fieldName = null) { - return AddDynamicPort(type, direction, connectionType, typeConstraint, null,fieldName); + return AddDynamicPort(type, direction, connectionType, typeConstraint, fieldName); } [Obsolete("Use RemoveDynamicPort instead")] @@ -147,21 +147,21 @@ namespace XNode { /// Convenience function. /// /// - public NodePort AddDynamicInput(Type type, Node.ConnectionType connectionType = Node.ConnectionType.Multiple, Node.TypeConstraint typeConstraint = TypeConstraint.None,Type baseType = null, string fieldName = null) { - return AddDynamicPort(type, NodePort.IO.Input, connectionType, typeConstraint,baseType, fieldName); + public NodePort AddDynamicInput(Type type, Node.ConnectionType connectionType = Node.ConnectionType.Multiple, Node.TypeConstraint typeConstraint = TypeConstraint.None, string fieldName = null) { + return AddDynamicPort(type, NodePort.IO.Input, connectionType, typeConstraint, fieldName); } /// Convenience function. /// /// public NodePort AddDynamicOutput(Type type, Node.ConnectionType connectionType = Node.ConnectionType.Multiple, Node.TypeConstraint typeConstraint = TypeConstraint.None, string fieldName = null) { - return AddDynamicPort(type, NodePort.IO.Output, connectionType, typeConstraint, null,fieldName); + return AddDynamicPort(type, NodePort.IO.Output, connectionType, typeConstraint,fieldName); } /// Add a dynamic, serialized port to this node. /// /// - private NodePort AddDynamicPort(Type type, NodePort.IO direction, Node.ConnectionType connectionType = Node.ConnectionType.Multiple, Node.TypeConstraint typeConstraint = TypeConstraint.None,Type baseType = null, string fieldName = null) { + private NodePort AddDynamicPort(Type type, NodePort.IO direction, Node.ConnectionType connectionType = Node.ConnectionType.Multiple, Node.TypeConstraint typeConstraint = TypeConstraint.None, string fieldName = null) { if (fieldName == null) { fieldName = "dynamicInput_0"; int i = 0; @@ -170,7 +170,7 @@ namespace XNode { Debug.LogWarning("Port '" + fieldName + "' already exists in " + name, this); return ports[fieldName]; } - NodePort port = new NodePort(fieldName, type, direction, connectionType, typeConstraint,baseType, this); + NodePort port = new NodePort(fieldName, type, direction, connectionType, typeConstraint, this); ports.Add(fieldName, port); @@ -400,6 +400,7 @@ namespace XNode { values.Clear(); foreach (KeyValuePair pair in this) { + //Sorting, output port is always after input port if (pair.Value.direction == NodePort.IO.Input) { var firstOutIndex = values.FindIndex(x => x.direction == NodePort.IO.Output); From 1e155fb0001cc192385b7506b2b77e33fc29594c Mon Sep 17 00:00:00 2001 From: Icarus <1375400884@qq.com> Date: Sat, 21 Dec 2019 20:50:32 +0800 Subject: [PATCH 54/65] !TX(Port) remove baseType --- Scripts/NodeDataCache.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/Scripts/NodeDataCache.cs b/Scripts/NodeDataCache.cs index 5ea5c5a..86b0176 100644 --- a/Scripts/NodeDataCache.cs +++ b/Scripts/NodeDataCache.cs @@ -40,7 +40,6 @@ namespace XNode { else { port.ValueType = staticPort.ValueType; - port.TypeConstraintBaseType = staticPort.TypeConstraintBaseType; } } // If port doesn't exist anymore, remove it From 2fb21d0f8939a6a95f9df0b6301d262f59ddd1f9 Mon Sep 17 00:00:00 2001 From: Icarus <1375400884@qq.com> Date: Sat, 21 Dec 2019 21:01:04 +0800 Subject: [PATCH 55/65] !TX Coding conventions --- Scripts/Editor/MenuPopup/MenuTreeView.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Scripts/Editor/MenuPopup/MenuTreeView.cs b/Scripts/Editor/MenuPopup/MenuTreeView.cs index 79c880c..60e3423 100644 --- a/Scripts/Editor/MenuPopup/MenuTreeView.cs +++ b/Scripts/Editor/MenuPopup/MenuTreeView.cs @@ -26,10 +26,10 @@ namespace XNodeEditor public MenuTreeView(TreeViewState state, MultiColumnHeader multiColumnHeader = null) : base(state, multiColumnHeader) { - Root = new TreeViewItem(_id++,-1,nameof(Root)); + Root = new TreeViewItem(id++,-1,nameof(Root)); } - private int _id = -1; + private int id = -1; private Dictionary> _menuCache = new Dictionary>(); @@ -88,7 +88,7 @@ namespace XNodeEditor } } - var temp = new TreeViewItem(_id++,depth++,path); + var temp = new TreeViewItem(id++,depth++,path); last.AddChild(temp); @@ -98,7 +98,7 @@ namespace XNodeEditor } } - last.AddChild(new MenuItem(_id++,depth,paths.Last(),onClick)); + last.AddChild(new MenuItem(id++,depth,paths.Last(),onClick)); } protected override bool DoesItemMatchSearch(TreeViewItem item, string search) @@ -111,7 +111,7 @@ namespace XNodeEditor return base.DoesItemMatchSearch(item, search); } - List _ids = new List(); + List ids = new List(); protected override void DoubleClickedItem(int id) { var item = FindItem(id,Root); @@ -121,15 +121,15 @@ namespace XNodeEditor { searchString = ""; - _ids.Clear(); + ids.Clear(); while (item != null) { - _ids.Add(item.id); + ids.Add(item.id); item = item.parent; } - SetExpanded(_ids); + SetExpanded(ids); } else { From 5d2259608e5209abb40e52341a85bdc10a7d49a0 Mon Sep 17 00:00:00 2001 From: Icarus <1375400884@qq.com> Date: Mon, 23 Dec 2019 23:29:28 +0800 Subject: [PATCH 56/65] !TX(Code format) --- Scripts/Editor/MenuPopup/MenuPopupWindow.cs | 40 +- Scripts/Editor/NodeEditor.cs | 401 ++++++++++---------- Scripts/Editor/NodeEditorAction.cs | 22 +- Scripts/Editor/NodeEditorGUI.cs | 4 +- Scripts/Editor/NodeEditorGUILayout.cs | 2 +- Scripts/Editor/NodeEditorReflection.cs | 2 +- Scripts/Editor/NodeEditorWindow.cs | 2 +- Scripts/NodeDataCache.cs | 2 +- Scripts/NodePort.cs | 4 +- 9 files changed, 230 insertions(+), 249 deletions(-) diff --git a/Scripts/Editor/MenuPopup/MenuPopupWindow.cs b/Scripts/Editor/MenuPopup/MenuPopupWindow.cs index ef9c61b..62ea6ef 100644 --- a/Scripts/Editor/MenuPopup/MenuPopupWindow.cs +++ b/Scripts/Editor/MenuPopup/MenuPopupWindow.cs @@ -10,17 +10,17 @@ namespace XNodeEditor /// public class MenuPopupWindow : PopupWindowContent { - public Vector2 OpenBeforeMousePos; - private SearchField _search; - private MenuTreeView _menuTree; - public Action OnCloseA; + public Vector2 openBeforeMousePos; + private SearchField search; + private MenuTreeView menuTree; + public Action onCloseAction; public MenuPopupWindow() { - _search = new SearchField(); - _menuTree = new MenuTreeView(); + search = new SearchField(); + menuTree = new MenuTreeView(); } - private bool _isInit; + private bool isInit; /// /// Add Item @@ -31,7 +31,7 @@ namespace XNodeEditor /// Automatically close window after selecting an item public void AddItem(string menuPath, Action onClick, char symbol = '/',bool autoClose = true) { - _menuTree.AddItem(menuPath, () => + menuTree.AddItem(menuPath, () => { onClick?.Invoke(); if (autoClose) @@ -46,52 +46,52 @@ namespace XNodeEditor /// public void Init() { - _menuTree.Reload(); - _isInit = true; + menuTree.Reload(); + isInit = true; } public override void OnOpen() { - _search.SetFocus(); + search.SetFocus(); } public override void OnClose() { - OnCloseA?.Invoke(); + onCloseAction?.Invoke(); } private string _str; public override void OnGUI(Rect rect) { - if (!_isInit) + if (!isInit) { Init(); } - _action(); + EventAction(); EditorGUI.BeginChangeCheck(); { - _str = _search.OnGUI(new Rect(rect.position, new Vector2(rect.width, 20)),_str); + _str = search.OnGUI(new Rect(rect.position, new Vector2(rect.width, 20)),_str); } if (EditorGUI.EndChangeCheck()) { - _menuTree.searchString = _str; + menuTree.searchString = _str; } - _menuTree.OnGUI(new Rect(new Vector2(0,25),rect.size - new Vector2(0,20))); + menuTree.OnGUI(new Rect(new Vector2(0,25),rect.size - new Vector2(0,20))); } - private void _action() + private void EventAction() { Event e = Event.current; switch (e.type) { case EventType.KeyDown: - if (e.keyCode == KeyCode.DownArrow && !_menuTree.HasFocus()) + if (e.keyCode == KeyCode.DownArrow && !menuTree.HasFocus()) { - _menuTree.SetFocusAndEnsureSelectedItem(); + menuTree.SetFocusAndEnsureSelectedItem(); e.Use(); } break; diff --git a/Scripts/Editor/NodeEditor.cs b/Scripts/Editor/NodeEditor.cs index a287263..f6dda2f 100644 --- a/Scripts/Editor/NodeEditor.cs +++ b/Scripts/Editor/NodeEditor.cs @@ -1,210 +1,191 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using UnityEditor; -using UnityEngine; -#if ODIN_INSPECTOR -using Sirenix.OdinInspector.Editor; -using Sirenix.Utilities; -using Sirenix.Utilities.Editor; -#endif - -namespace XNodeEditor { - /// Base class to derive custom Node editors from. Use this to create your own custom inspectors and editors for your nodes. - [CustomNodeEditor(typeof(XNode.Node))] - public class NodeEditor : XNodeEditor.Internal.NodeEditorBase { - - private readonly Color DEFAULTCOLOR = new Color32(90, 97, 105, 255); - - /// Fires every whenever a node was modified through the editor - public static Action onUpdateNode; - public readonly static Dictionary portPositions = new Dictionary(); - -#if ODIN_INSPECTOR - internal static bool inNodeEditor = false; -#endif - private List _excludesField; - public override void OnCreate() - { - _excludesField = new List { "m_Script", "graph", "position", "ports" }; - - var fields = GetExcludesField(); - - if (fields != null) - { - _excludesField.AddRange(fields); - } - } - - 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 - inNodeEditor = true; -#endif - - // Unity specifically requires this to save/update any serial object. - // serializedObject.Update(); must go at the start of an inspector gui, and - // serializedObject.ApplyModifiedProperties(); goes at the end. - serializedObject.Update(); - -#if ODIN_INSPECTOR - InspectorUtilities.BeginDrawPropertyTree(objectTree, true); - GUIHelper.PushLabelWidth(84); - objectTree.Draw(true); - InspectorUtilities.EndDrawPropertyTree(objectTree); - GUIHelper.PopLabelWidth(); -#else - - // Iterate through serialized properties and draw them like the Inspector (But with ports) - SerializedProperty iterator = serializedObject.GetIterator(); - bool enterChildren = true; - List _names = new List(); - while (iterator.NextVisible(enterChildren)) { - enterChildren = false; - if (_excludesField.Contains(iterator.name)) continue; - NodeEditorGUILayout.PropertyField(iterator, true); - _names.Add(iterator.name); - } - - //һûƵĶ˿ - foreach (var port in target.Ports) - { - //̬ - if (port.IsDynamic) - { - continue; - } - - //unityл֧,DZΪ - if (!_names.Contains(port.fieldName)) - { - NodeEditorGUILayout.PortField(port); - } - } -#endif - - // Iterate through dynamic ports and draw them in the order in which they are serialized - foreach (XNode.NodePort dynamicPort in target.DynamicPorts) { - if (NodeEditorGUILayout.IsDynamicPortListPort(dynamicPort)) continue; - NodeEditorGUILayout.PortField(dynamicPort); - } - - serializedObject.ApplyModifiedProperties(); - -#if ODIN_INSPECTOR - // Call repaint so that the graph window elements respond properly to layout changes coming from Odin - if (GUIHelper.RepaintRequested) { - GUIHelper.ClearRepaintRequest(); - window.Repaint(); - } -#endif - -#if ODIN_INSPECTOR - inNodeEditor = false; -#endif - } - - public virtual int GetWidth() { - Type type = target.GetType(); - int width; - if (type.TryGetAttributeWidth(out width)) return width; - else return 208; - } - - public Vector2 GetCurrentMousePosition(float yOffset = 10) - { - return new Vector2(Event.current.mousePosition.x,Event.current.mousePosition.y + yOffset); - } - - /// Returns color for target node - public virtual Color GetTint() { - // Try get color from [NodeTint] attribute - Type type = target.GetType(); - Color color; - if (type.TryGetAttributeTint(out color)) return color; - // Return default color (grey) - else return DEFAULTCOLOR; - } - - public virtual GUIStyle GetBodyStyle() { - return NodeEditorResources.styles.nodeBody; - } - - public virtual GUIStyle GetBodyHighlightStyle() { - return NodeEditorResources.styles.nodeHighlight; - } - - /// Add items for the context menu when right-clicking this node. Override to add custom menu items. - public virtual void AddContextMenuItems(MenuPopupWindow menu) { - // Actions if only one node is selected - if (Selection.objects.Length == 1 && Selection.activeObject is XNode.Node) { - XNode.Node node = Selection.activeObject as XNode.Node; - menu.AddItem("Move To Top", () => NodeEditorWindow.current.MoveNodeToTop(node)); - menu.AddItem("Rename", NodeEditorWindow.current.RenameSelectedNode); - } - - // Add actions to any number of selected nodes - menu.AddItem("Copy", NodeEditorWindow.current.CopySelectedNodes); - menu.AddItem("Duplicate", NodeEditorWindow.current.DuplicateSelectedNodes); - menu.AddItem("Remove", NodeEditorWindow.current.RemoveSelectedNodes); - - // Custom sctions if only one node is selected - if (Selection.objects.Length == 1 && Selection.activeObject is XNode.Node) { - XNode.Node node = Selection.activeObject as XNode.Node; - menu.AddCustomContextMenuItems(node); - } - } - - /// Add items for the context menu when right-clicking this node. Override to add custom menu items. - public virtual void AddContextMenuItems(GenericMenu menu) { - // Actions if only one node is selected - if (Selection.objects.Length == 1 && Selection.activeObject is XNode.Node) { - XNode.Node node = Selection.activeObject as XNode.Node; - menu.AddItem(new GUIContent("Move To Top"), false, () => NodeEditorWindow.current.MoveNodeToTop(node)); - menu.AddItem(new GUIContent("Rename"), false, NodeEditorWindow.current.RenameSelectedNode); - } - - // Add actions to any number of selected nodes - menu.AddItem(new GUIContent("Copy"), false, NodeEditorWindow.current.CopySelectedNodes); - menu.AddItem(new GUIContent("Duplicate"), false, NodeEditorWindow.current.DuplicateSelectedNodes); - menu.AddItem(new GUIContent("Remove"), false, NodeEditorWindow.current.RemoveSelectedNodes); - - // Custom sctions if only one node is selected - if (Selection.objects.Length == 1 && Selection.activeObject is XNode.Node) { - XNode.Node node = Selection.activeObject as XNode.Node; - menu.AddCustomContextMenuItems(node); - } - } - - /// Rename the node asset. This will trigger a reimport of the node. - public void Rename(string newName) { - if (newName == null || newName.Trim() == "") newName = NodeEditorUtilities.NodeDefaultName(target.GetType()); - target.name = newName; - AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(target)); - } - - [AttributeUsage(AttributeTargets.Class)] - public class CustomNodeEditorAttribute : Attribute, - XNodeEditor.Internal.NodeEditorBase.INodeEditorAttrib { - private Type inspectedType; - /// Tells a NodeEditor which Node type it is an editor for - /// Type that this editor can edit - public CustomNodeEditorAttribute(Type inspectedType) { - this.inspectedType = inspectedType; - } - - public Type GetInspectedType() { - return inspectedType; - } - } - } -} +using System; +using System.Collections.Generic; +using System.Linq; +using UnityEditor; +using UnityEngine; +#if ODIN_INSPECTOR +using Sirenix.OdinInspector.Editor; +using Sirenix.Utilities; +using Sirenix.Utilities.Editor; +#endif + +namespace XNodeEditor { + /// Base class to derive custom Node editors from. Use this to create your own custom inspectors and editors for your nodes. + [CustomNodeEditor(typeof(XNode.Node))] + public class NodeEditor : XNodeEditor.Internal.NodeEditorBase { + + private readonly Color DEFAULTCOLOR = new Color32(90, 97, 105, 255); + + /// Fires every whenever a node was modified through the editor + public static Action onUpdateNode; + public readonly static Dictionary portPositions = new Dictionary(); + +#if ODIN_INSPECTOR + internal static bool inNodeEditor = false; +#endif + private List excludesField; + private List portNames = new List(); + + public override void OnCreate() + { + excludesField = new List { "m_Script", "graph", "position", "ports" }; + + var fields = GetExcludesField(); + + if (fields != null) + { + excludesField.AddRange(fields); + } + } + + 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 + inNodeEditor = true; +#endif + + // Unity specifically requires this to save/update any serial object. + // serializedObject.Update(); must go at the start of an inspector gui, and + // serializedObject.ApplyModifiedProperties(); goes at the end. + serializedObject.Update(); + +#if ODIN_INSPECTOR + InspectorUtilities.BeginDrawPropertyTree(objectTree, true); + GUIHelper.PushLabelWidth(84); + objectTree.Draw(true); + InspectorUtilities.EndDrawPropertyTree(objectTree); + GUIHelper.PopLabelWidth(); +#else + + // Iterate through serialized properties and draw them like the Inspector (But with ports) + SerializedProperty iterator = serializedObject.GetIterator(); + bool enterChildren = true; + portNames.Clear(); + while (iterator.NextVisible(enterChildren)) { + enterChildren = false; + if (excludesField.Contains(iterator.name)) continue; + NodeEditorGUILayout.PropertyField(iterator, true); + portNames.Add(iterator.name); + } + + //Deal with ports that are not drawn + foreach (var port in target.Ports) + { + //Dynamic skip + if (port.IsDynamic) + { + continue; + } + + //Not supported by unity serialization, but marked as input or output + if (!portNames.Contains(port.fieldName)) + { + NodeEditorGUILayout.PortField(port); + } + } +#endif + + // Iterate through dynamic ports and draw them in the order in which they are serialized + foreach (XNode.NodePort dynamicPort in target.DynamicPorts) { + if (NodeEditorGUILayout.IsDynamicPortListPort(dynamicPort)) continue; + NodeEditorGUILayout.PortField(dynamicPort); + } + + serializedObject.ApplyModifiedProperties(); + +#if ODIN_INSPECTOR + // Call repaint so that the graph window elements respond properly to layout changes coming from Odin + if (GUIHelper.RepaintRequested) { + GUIHelper.ClearRepaintRequest(); + window.Repaint(); + } +#endif + +#if ODIN_INSPECTOR + inNodeEditor = false; +#endif + } + + public virtual int GetWidth() { + Type type = target.GetType(); + int width; + if (type.TryGetAttributeWidth(out width)) return width; + else return 208; + } + + public Vector2 GetCurrentMousePosition(float yOffset = 10) + { + return new Vector2(Event.current.mousePosition.x,Event.current.mousePosition.y + yOffset); + } + + /// Returns color for target node + public virtual Color GetTint() { + // Try get color from [NodeTint] attribute + Type type = target.GetType(); + Color color; + if (type.TryGetAttributeTint(out color)) return color; + // Return default color (grey) + else return DEFAULTCOLOR; + } + + public virtual GUIStyle GetBodyStyle() { + return NodeEditorResources.styles.nodeBody; + } + + public virtual GUIStyle GetBodyHighlightStyle() { + return NodeEditorResources.styles.nodeHighlight; + } + + /// Add items for the context menu when right-clicking this node. Override to add custom menu items. + public virtual void AddContextMenuItems(GenericMenu menu) { + // Actions if only one node is selected + if (Selection.objects.Length == 1 && Selection.activeObject is XNode.Node) { + XNode.Node node = Selection.activeObject as XNode.Node; + menu.AddItem(new GUIContent("Move To Top"), false, () => NodeEditorWindow.current.MoveNodeToTop(node)); + menu.AddItem(new GUIContent("Rename"), false, NodeEditorWindow.current.RenameSelectedNode); + } + + // Add actions to any number of selected nodes + menu.AddItem(new GUIContent("Copy"), false, NodeEditorWindow.current.CopySelectedNodes); + menu.AddItem(new GUIContent("Duplicate"), false, NodeEditorWindow.current.DuplicateSelectedNodes); + menu.AddItem(new GUIContent("Remove"), false, NodeEditorWindow.current.RemoveSelectedNodes); + + // Custom sctions if only one node is selected + if (Selection.objects.Length == 1 && Selection.activeObject is XNode.Node) { + XNode.Node node = Selection.activeObject as XNode.Node; + menu.AddCustomContextMenuItems(node); + } + } + + /// Rename the node asset. This will trigger a reimport of the node. + public void Rename(string newName) { + if (newName == null || newName.Trim() == "") newName = NodeEditorUtilities.NodeDefaultName(target.GetType()); + target.name = newName; + AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(target)); + } + + [AttributeUsage(AttributeTargets.Class)] + public class CustomNodeEditorAttribute : Attribute, + XNodeEditor.Internal.NodeEditorBase.INodeEditorAttrib { + private Type inspectedType; + /// Tells a NodeEditor which Node type it is an editor for + /// Type that this editor can edit + public CustomNodeEditorAttribute(Type inspectedType) { + this.inspectedType = inspectedType; + } + + public Type GetInspectedType() { + return inspectedType; + } + } + } +} diff --git a/Scripts/Editor/NodeEditorAction.cs b/Scripts/Editor/NodeEditorAction.cs index 40bea2f..26e9873 100644 --- a/Scripts/Editor/NodeEditorAction.cs +++ b/Scripts/Editor/NodeEditorAction.cs @@ -32,13 +32,13 @@ namespace XNodeEditor { private Rect selectionBox; private bool isDoubleClick = false; private Vector2 lastMousePosition; - private MenuPopupWindow _menuPopupWindow; + private MenuPopupWindow menuPopupWindow; public void Controls() { - if (_menuPopupWindow == null) + if (menuPopupWindow == null) { - _menuPopupWindow = new MenuPopupWindow(); - graphEditor.AddContextMenuItems(_menuPopupWindow); + menuPopupWindow = new MenuPopupWindow(); + graphEditor.AddContextMenuItems(menuPopupWindow); } wantsMouseMove = true; Event e = Event.current; @@ -226,12 +226,12 @@ namespace XNodeEditor { } // Open context menu for auto-connection else if (NodeEditorPreferences.GetSettings().dragToCreate && autoConnectOutput != null) { - _menuPopupWindow.OnCloseA = _releaseDraggedConnection; - _menuPopupWindow.OpenBeforeMousePos = e.mousePosition; - PopupWindow.Show(new Rect(Event.current.mousePosition, Vector2.zero),_menuPopupWindow); + menuPopupWindow.OnCloseA = ReleaseDraggedConnection; + menuPopupWindow.OpenBeforeMousePos = e.mousePosition; + PopupWindow.Show(new Rect(Event.current.mousePosition, Vector2.zero),menuPopupWindow); } - _releaseDraggedConnection(); + ReleaseDraggedConnection(); } else if (currentActivity == NodeActivity.DragNode) { IEnumerable nodes = Selection.objects.Where(x => x is XNode.Node).Select(x => x as XNode.Node); @@ -286,8 +286,8 @@ namespace XNodeEditor { e.Use(); // Fixes copy/paste context menu appearing in Unity 5.6.6f2 - doesn't occur in 2018.3.2f1 Probably needs to be used in other places. } else if (!IsHoveringNode) { autoConnectOutput = null; - _menuPopupWindow.OpenBeforeMousePos = e.mousePosition; - PopupWindow.Show(new Rect(Event.current.mousePosition, Vector2.zero),_menuPopupWindow); + menuPopupWindow.OpenBeforeMousePos = e.mousePosition; + PopupWindow.Show(new Rect(Event.current.mousePosition, Vector2.zero),menuPopupWindow); } } isPanning = false; @@ -346,7 +346,7 @@ namespace XNodeEditor { } } - private void _releaseDraggedConnection() + private void ReleaseDraggedConnection() { //Release dragged connection draggedOutput = null; diff --git a/Scripts/Editor/NodeEditorGUI.cs b/Scripts/Editor/NodeEditorGUI.cs index de9374c..65d3aa6 100755 --- a/Scripts/Editor/NodeEditorGUI.cs +++ b/Scripts/Editor/NodeEditorGUI.cs @@ -29,7 +29,7 @@ namespace XNodeEditor { DrawConnections(); DrawNodes(); DrawSelectionBox(); - _drawGroupName(); + DrawGroupName(); DrawTooltip(); graphEditor.OnGUI(); @@ -42,7 +42,7 @@ namespace XNodeEditor { GUI.matrix = m; } - private void _drawGroupName() + private void DrawGroupName() { var guiContent = new GUIContent(this.graph.name); var col = EditorStyles.label.normal.textColor; diff --git a/Scripts/Editor/NodeEditorGUILayout.cs b/Scripts/Editor/NodeEditorGUILayout.cs index b4a756a..542ea03 100644 --- a/Scripts/Editor/NodeEditorGUILayout.cs +++ b/Scripts/Editor/NodeEditorGUILayout.cs @@ -234,7 +234,7 @@ namespace XNodeEditor { Color col = NodeEditorWindow.current.graphEditor.GetPortColor(port); DrawPortHandle(rect, backgroundColor, col); - //当选择节点时显示所有的输入点索引 + //Show all input point indexes when node is selected if (port.direction == XNode.NodePort.IO.Output) { if (port.Connection != null && port.Connection.ConnectionCount > 1) diff --git a/Scripts/Editor/NodeEditorReflection.cs b/Scripts/Editor/NodeEditorReflection.cs index 27136e0..2ef5ac1 100644 --- a/Scripts/Editor/NodeEditorReflection.cs +++ b/Scripts/Editor/NodeEditorReflection.cs @@ -75,7 +75,7 @@ namespace XNodeEditor { return types.ToArray(); } - /// Find methods marked with the [ContextMenu] attribute and add them to the context menu + /// Find methods marked with the [ContextMenu] attribute and add them to the menu popup window public static void AddCustomContextMenuItems(this MenuPopupWindow contextMenu, object obj) { KeyValuePair[] items = GetContextMenuMethods(obj); if (items.Length != 0) { diff --git a/Scripts/Editor/NodeEditorWindow.cs b/Scripts/Editor/NodeEditorWindow.cs index 201a26d..eff4a1b 100644 --- a/Scripts/Editor/NodeEditorWindow.cs +++ b/Scripts/Editor/NodeEditorWindow.cs @@ -26,7 +26,7 @@ namespace XNodeEditor { }); } - [MenuItem("Icarus/Node Editor/Close All Editor Window")] + [MenuItem("xNode/Close All Editor Window")] static void CloseAllNodeEditorWindow() { var windows = Resources.FindObjectsOfTypeAll(); diff --git a/Scripts/NodeDataCache.cs b/Scripts/NodeDataCache.cs index 86b0176..b884da0 100644 --- a/Scripts/NodeDataCache.cs +++ b/Scripts/NodeDataCache.cs @@ -104,7 +104,7 @@ namespace XNode { System.Type tempType = nodeType; while ((tempType = tempType.BaseType) != typeof(XNode.Node)) { - //只返回私有的,保护等其他的不需要 + // Only return private, protected, etc. var fieldInfos = tempType.GetFields(BindingFlags.NonPublic | BindingFlags.Instance).Where(x=>x.IsPrivate); fieldInfo.AddRange(fieldInfos); diff --git a/Scripts/NodePort.cs b/Scripts/NodePort.cs index 146a8ca..c4341ea 100644 --- a/Scripts/NodePort.cs +++ b/Scripts/NodePort.cs @@ -53,7 +53,7 @@ namespace XNode { private Type valueType; #if UNITY_EDITOR - public const string FieldNameEditor = nameof(_fieldName); + public const string FIELDNAMEEDITOR = nameof(_fieldName); #endif [SerializeField] private string _fieldName; [SerializeField] private Node _node; @@ -219,7 +219,7 @@ namespace XNode { if (connectionType == Node.ConnectionType.Override && ConnectionCount != 0) { var conPort = GetConnection(0); - + //Same connection, not disconnect if(conPort.node != port.node || conPort != port) { ClearConnections(); From 6ecef29f07ea4d1f47885482801b289f51d60046 Mon Sep 17 00:00:00 2001 From: Icarus <1375400884@qq.com> Date: Mon, 23 Dec 2019 23:30:04 +0800 Subject: [PATCH 57/65] !TX(Code format) --- Scripts/Editor/NodeEditorAction.cs | 6 +++--- Scripts/Editor/NodeGraphEditor.cs | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Scripts/Editor/NodeEditorAction.cs b/Scripts/Editor/NodeEditorAction.cs index 26e9873..992cbcc 100644 --- a/Scripts/Editor/NodeEditorAction.cs +++ b/Scripts/Editor/NodeEditorAction.cs @@ -226,8 +226,8 @@ namespace XNodeEditor { } // Open context menu for auto-connection else if (NodeEditorPreferences.GetSettings().dragToCreate && autoConnectOutput != null) { - menuPopupWindow.OnCloseA = ReleaseDraggedConnection; - menuPopupWindow.OpenBeforeMousePos = e.mousePosition; + menuPopupWindow.onCloseAction = ReleaseDraggedConnection; + menuPopupWindow.openBeforeMousePos = e.mousePosition; PopupWindow.Show(new Rect(Event.current.mousePosition, Vector2.zero),menuPopupWindow); } @@ -286,7 +286,7 @@ namespace XNodeEditor { e.Use(); // Fixes copy/paste context menu appearing in Unity 5.6.6f2 - doesn't occur in 2018.3.2f1 Probably needs to be used in other places. } else if (!IsHoveringNode) { autoConnectOutput = null; - menuPopupWindow.OpenBeforeMousePos = e.mousePosition; + menuPopupWindow.openBeforeMousePos = e.mousePosition; PopupWindow.Show(new Rect(Event.current.mousePosition, Vector2.zero),menuPopupWindow); } } diff --git a/Scripts/Editor/NodeGraphEditor.cs b/Scripts/Editor/NodeGraphEditor.cs index 0eb2a62..05aa864 100644 --- a/Scripts/Editor/NodeGraphEditor.cs +++ b/Scripts/Editor/NodeGraphEditor.cs @@ -50,7 +50,7 @@ namespace XNodeEditor { if (string.IsNullOrEmpty(path)) continue; menu.AddItem(path, () => { - pos = NodeEditorWindow.current.WindowToGridPosition(menu.OpenBeforeMousePos); + pos = NodeEditorWindow.current.WindowToGridPosition(menu.openBeforeMousePos); XNode.Node node = CreateNode(type, pos); NodeEditorWindow.current.AutoConnect(node); }); @@ -58,7 +58,7 @@ namespace XNodeEditor { if (NodeEditorWindow.copyBuffer != null && NodeEditorWindow.copyBuffer.Length > 0) menu.AddItem("Paste", () => { - pos = NodeEditorWindow.current.WindowToGridPosition(menu.OpenBeforeMousePos); + pos = NodeEditorWindow.current.WindowToGridPosition(menu.openBeforeMousePos); NodeEditorWindow.current.PasteNodes(pos); }); @@ -71,7 +71,7 @@ namespace XNodeEditor { return; } - pos = NodeEditorWindow.current.WindowToGridPosition(menu.OpenBeforeMousePos); + pos = NodeEditorWindow.current.WindowToGridPosition(menu.openBeforeMousePos); for (int i = 0; i < NodeEditorReflection.nodeTypes.Length; i++) { From 33a516b6e29ab1d40af001d6bfc0c2ca08a69f83 Mon Sep 17 00:00:00 2001 From: Icarus <1375400884@qq.com> Date: Tue, 24 Dec 2019 00:23:17 +0800 Subject: [PATCH 58/65] !TX(Code format) var to concrete Type --- Scripts/Editor/MenuPopup/MenuTreeView.cs | 4 ++-- Scripts/Editor/NodeEditor.cs | 2 +- Scripts/Editor/NodeEditorGUI.cs | 6 +++--- Scripts/Editor/NodeEditorWindow.cs | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Scripts/Editor/MenuPopup/MenuTreeView.cs b/Scripts/Editor/MenuPopup/MenuTreeView.cs index 60e3423..aa81fed 100644 --- a/Scripts/Editor/MenuPopup/MenuTreeView.cs +++ b/Scripts/Editor/MenuPopup/MenuTreeView.cs @@ -88,7 +88,7 @@ namespace XNodeEditor } } - var temp = new TreeViewItem(id++,depth++,path); + TreeViewItem temp = new TreeViewItem(id++,depth++,path); last.AddChild(temp); @@ -114,7 +114,7 @@ namespace XNodeEditor List ids = new List(); protected override void DoubleClickedItem(int id) { - var item = FindItem(id,Root); + TreeViewItem item = FindItem(id,Root); if (item.hasChildren) { if (hasSearch) diff --git a/Scripts/Editor/NodeEditor.cs b/Scripts/Editor/NodeEditor.cs index f6dda2f..226f419 100644 --- a/Scripts/Editor/NodeEditor.cs +++ b/Scripts/Editor/NodeEditor.cs @@ -30,7 +30,7 @@ namespace XNodeEditor { { excludesField = new List { "m_Script", "graph", "position", "ports" }; - var fields = GetExcludesField(); + IEnumerable fields = GetExcludesField(); if (fields != null) { diff --git a/Scripts/Editor/NodeEditorGUI.cs b/Scripts/Editor/NodeEditorGUI.cs index 65d3aa6..088998f 100755 --- a/Scripts/Editor/NodeEditorGUI.cs +++ b/Scripts/Editor/NodeEditorGUI.cs @@ -44,11 +44,11 @@ namespace XNodeEditor { private void DrawGroupName() { - var guiContent = new GUIContent(this.graph.name); - var col = EditorStyles.label.normal.textColor; + GUIContent guiContent = new GUIContent(this.graph.name); + Color col = EditorStyles.label.normal.textColor; var fontSize = EditorStyles.label.fontSize; EditorStyles.label.fontSize = 48; - var size = GUILayoutUtility.GetRect(guiContent, EditorStyles.label); + Rect size = GUILayoutUtility.GetRect(guiContent, EditorStyles.label); EditorStyles.label.normal.textColor = new Color(175 / 255f, 185 / 255f, 185 / 255f); EditorGUI.LabelField(new Rect(new Vector2(5, 5), size.size), guiContent); EditorStyles.label.fontSize = fontSize; diff --git a/Scripts/Editor/NodeEditorWindow.cs b/Scripts/Editor/NodeEditorWindow.cs index 6d5150d..4c018ea 100644 --- a/Scripts/Editor/NodeEditorWindow.cs +++ b/Scripts/Editor/NodeEditorWindow.cs @@ -29,7 +29,7 @@ namespace XNodeEditor { [MenuItem("xNode/Close All Editor Window")] static void CloseAllNodeEditorWindow() { - var windows = Resources.FindObjectsOfTypeAll(); + NodeEditorWindow[] windows = Resources.FindObjectsOfTypeAll(); foreach (var window in windows) { From daf7fb9f9fc9d6262aab6a3d4519642ef58ab494 Mon Sep 17 00:00:00 2001 From: Icarus <1375400884@qq.com> Date: Mon, 6 Jan 2020 22:34:54 +0800 Subject: [PATCH 59/65] !B(NodeEditorWindow) multiple NodeEditorWindow,Target error --- Scripts/Editor/NodeEditorWindow.cs | 34 ++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/Scripts/Editor/NodeEditorWindow.cs b/Scripts/Editor/NodeEditorWindow.cs index 4c018ea..7b01503 100644 --- a/Scripts/Editor/NodeEditorWindow.cs +++ b/Scripts/Editor/NodeEditorWindow.cs @@ -33,7 +33,17 @@ namespace XNodeEditor { foreach (var window in windows) { - window.Close(); + if (window) + { + try + { + window.Close(); + } + catch (Exception e) + { + DestroyImmediate(window); + } + } } } @@ -103,7 +113,8 @@ namespace XNodeEditor { public float zoom { get { return _zoom; } set { _zoom = Mathf.Clamp(value, NodeEditorPreferences.GetSettings().minZoom, NodeEditorPreferences.GetSettings().maxZoom); Repaint(); } } private float _zoom = 1; - void OnFocus() { + void OnFocus() + { current = this; ValidateGraphEditor(); if (graphEditor != null && NodeEditorPreferences.GetSettings().autoSave) AssetDatabase.SaveAssets(); @@ -239,15 +250,26 @@ namespace XNodeEditor { if (!w) { - w = CreateWindow("xNode"); + w = EditorWindow.CreateInstance(); + w.titleContent = new GUIContent("xNode"); } - + w.Show(true); w.Focus(); + + if (w.graphEditor == null) + { + NodeGraphEditor graphEditor = NodeGraphEditor.GetEditor(graph, w); + w.graphEditor = graphEditor; + } + else + { + //refresh target + w.graphEditor.target = graph; + } + w.wantsMouseMove = true; w.graph = graph; - NodeGraphEditor graphEditor = NodeGraphEditor.GetEditor(graph, w); - NodeEditorWindow.current.graphEditor = graphEditor; return w; } From 570e01de011073c2ee19ac62da935a4c250aa9fc Mon Sep 17 00:00:00 2001 From: Icarus <1375400884@qq.com> Date: Thu, 28 May 2020 19:04:59 +0800 Subject: [PATCH 60/65] !W OnRename --- Scripts/Editor/NodeEditor.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Scripts/Editor/NodeEditor.cs b/Scripts/Editor/NodeEditor.cs index 226f419..62b060b 100644 --- a/Scripts/Editor/NodeEditor.cs +++ b/Scripts/Editor/NodeEditor.cs @@ -57,7 +57,7 @@ namespace XNodeEditor { // serializedObject.Update(); must go at the start of an inspector gui, and // serializedObject.ApplyModifiedProperties(); goes at the end. serializedObject.Update(); - + #if ODIN_INSPECTOR InspectorUtilities.BeginDrawPropertyTree(objectTree, true); GUIHelper.PushLabelWidth(84); @@ -76,7 +76,7 @@ namespace XNodeEditor { NodeEditorGUILayout.PropertyField(iterator, true); portNames.Add(iterator.name); } - + //Deal with ports that are not drawn foreach (var port in target.Ports) { @@ -103,7 +103,7 @@ namespace XNodeEditor { serializedObject.ApplyModifiedProperties(); #if ODIN_INSPECTOR - // Call repaint so that the graph window elements respond properly to layout changes coming from Odin + // Call repaint so that the graph window elements respond properly to layout changes coming from Odin if (GUIHelper.RepaintRequested) { GUIHelper.ClearRepaintRequest(); window.Repaint(); @@ -144,7 +144,7 @@ namespace XNodeEditor { public virtual GUIStyle GetBodyHighlightStyle() { return NodeEditorResources.styles.nodeHighlight; } - + /// Add items for the context menu when right-clicking this node. Override to add custom menu items. public virtual void AddContextMenuItems(GenericMenu menu) { // Actions if only one node is selected @@ -173,6 +173,9 @@ namespace XNodeEditor { AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(target)); } + /// Called after this node's name has changed. + public virtual void OnRename() { } + [AttributeUsage(AttributeTargets.Class)] public class CustomNodeEditorAttribute : Attribute, XNodeEditor.Internal.NodeEditorBase.INodeEditorAttrib { From e77fcc580f45107f10b7172c00f33d7a1d944c04 Mon Sep 17 00:00:00 2001 From: Icarus <1375400884@qq.com> Date: Mon, 3 Aug 2020 01:12:42 +0800 Subject: [PATCH 61/65] !W(Node Editor) Out Port Always at the bottom --- Scripts/Editor/NodeEditor.cs | 52 +++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 16 deletions(-) diff --git a/Scripts/Editor/NodeEditor.cs b/Scripts/Editor/NodeEditor.cs index 62b060b..7f10a0e 100644 --- a/Scripts/Editor/NodeEditor.cs +++ b/Scripts/Editor/NodeEditor.cs @@ -3,6 +3,8 @@ using System.Collections.Generic; using System.Linq; using UnityEditor; using UnityEngine; +using XNode; + #if ODIN_INSPECTOR using Sirenix.OdinInspector.Editor; using Sirenix.Utilities; @@ -77,21 +79,7 @@ namespace XNodeEditor { portNames.Add(iterator.name); } - //Deal with ports that are not drawn - foreach (var port in target.Ports) - { - //Dynamic skip - if (port.IsDynamic) - { - continue; - } - - //Not supported by unity serialization, but marked as input or output - if (!portNames.Contains(port.fieldName)) - { - NodeEditorGUILayout.PortField(port); - } - } + _drawPort(NodePort.IO.Input); #endif // Iterate through dynamic ports and draw them in the order in which they are serialized @@ -100,6 +88,9 @@ namespace XNodeEditor { NodeEditorGUILayout.PortField(dynamicPort); } +#if !ODIN_INSPECTOR + _drawPort(NodePort.IO.Output); +#endif serializedObject.ApplyModifiedProperties(); #if ODIN_INSPECTOR @@ -115,6 +106,25 @@ namespace XNodeEditor { #endif } + private void _drawPort(NodePort.IO io) + { + //Deal with ports that are not drawn + foreach (var port in io == NodePort.IO.Input ? target.Inputs : target.Outputs) + { + //Dynamic skip + if (port.IsDynamic) + { + continue; + } + + //Not supported by unity serialization, but marked as input or output + if (!portNames.Contains(port.fieldName)) + { + NodeEditorGUILayout.PortField(port); + } + } + } + public virtual int GetWidth() { Type type = target.GetType(); int width; @@ -124,7 +134,17 @@ namespace XNodeEditor { public Vector2 GetCurrentMousePosition(float yOffset = 10) { - return new Vector2(Event.current.mousePosition.x,Event.current.mousePosition.y + yOffset); + Debug.LogError(Event.current.mousePosition + ":" + target.position); + + var mouseGridPos = Event.current.mousePosition;//* window.zoom; + + var nodeWindowPos = window.GridToWindowPosition(target.position + mouseGridPos); + + var position = nodeWindowPos;//window.GridToWindowPositionNoClipped(nodeWindowPos); + // position += mouseGridPos; + // position.x = Event.current.mousePosition.x; + // position.y += yOffset; + return position; } /// Returns color for target node From 3761aa136101d360a8e74d11c74740e646f138f6 Mon Sep 17 00:00:00 2001 From: Icarus <1375400884@qq.com> Date: Mon, 3 Aug 2020 01:13:15 +0800 Subject: [PATCH 62/65] !O(Node Editor) Adjust the drawing order --- Scripts/Editor/NodeEditorGUI.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Scripts/Editor/NodeEditorGUI.cs b/Scripts/Editor/NodeEditorGUI.cs index 2936769..b682bbf 100755 --- a/Scripts/Editor/NodeEditorGUI.cs +++ b/Scripts/Editor/NodeEditorGUI.cs @@ -29,9 +29,9 @@ namespace XNodeEditor { DrawConnections(); DrawNodes(); DrawSelectionBox(); - DrawGroupName(); - DrawTooltip(); graphEditor.OnGUI(); + DrawTooltip(); + DrawGroupName(); // Run and reset onLateGUI if (onLateGUI != null) { @@ -50,7 +50,7 @@ namespace XNodeEditor { EditorStyles.label.fontSize = 48; Rect size = GUILayoutUtility.GetRect(guiContent, EditorStyles.label); EditorStyles.label.normal.textColor = new Color(175 / 255f, 185 / 255f, 185 / 255f); - EditorGUI.LabelField(new Rect(new Vector2(5, 5), size.size), guiContent); + EditorGUI.LabelField(new Rect(new Vector2(5, 15), size.size), guiContent); EditorStyles.label.fontSize = fontSize; EditorStyles.label.normal.textColor = col; } @@ -549,8 +549,8 @@ namespace XNodeEditor { if (e.type != EventType.Layout && currentActivity == NodeActivity.DragGrid) Selection.objects = preSelection.ToArray(); EndZoomed(position, zoom, topPadding); - //If a change in is detected in the selected node, call OnValidate method. - //This is done through reflection because OnValidate is only relevant in editor, + //If a change in is detected in the selected node, call OnValidate method. + //This is done through reflection because OnValidate is only relevant in editor, //and thus, the code should not be included in build. if (onValidate != null && EditorGUI.EndChangeCheck()) onValidate.Invoke(Selection.activeObject, null); } From 8454b1f1a63bb15557015d59ef91865c8262d7b6 Mon Sep 17 00:00:00 2001 From: Icarus <1375400884@qq.com> Date: Mon, 3 Aug 2020 01:15:18 +0800 Subject: [PATCH 63/65] !W(Node Editor Widnow) exposed set Lock --- Scripts/Editor/NodeEditorWindow.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Scripts/Editor/NodeEditorWindow.cs b/Scripts/Editor/NodeEditorWindow.cs index 535da52..5fa0fe8 100644 --- a/Scripts/Editor/NodeEditorWindow.cs +++ b/Scripts/Editor/NodeEditorWindow.cs @@ -8,9 +8,9 @@ using Object = UnityEngine.Object; namespace XNodeEditor { [InitializeOnLoad] public partial class NodeEditorWindow : EditorWindow,IHasCustomMenu { - - public bool Lock { get; private set; } - + + public bool Lock { get; set; } + /// /// Magic method which Unity detects automatically. /// @@ -18,7 +18,7 @@ namespace XNodeEditor { void ShowButton(Rect position) { Lock = GUI.Toggle(position, Lock, GUIContent.none, "IN LockButton"); } - + public void AddItemsToMenu(GenericMenu menu) { menu.AddItem(new GUIContent("Lock"), Lock, () => { @@ -46,7 +46,7 @@ namespace XNodeEditor { } } } - + public static NodeEditorWindow current; /// Stores node positions for all nodePorts. @@ -121,10 +121,10 @@ namespace XNodeEditor { graphEditor.OnWindowFocus(); if (NodeEditorPreferences.GetSettings().autoSave) AssetDatabase.SaveAssets(); } - + dragThreshold = Math.Max(1f, Screen.width / 1000f); } - + void OnLostFocus() { if (graphEditor != null) graphEditor.OnWindowFocusLost(); } @@ -262,7 +262,7 @@ namespace XNodeEditor { w = EditorWindow.CreateInstance(); w.titleContent = new GUIContent("xNode"); } - + w.Show(true); w.Focus(); From 4ab79fe0bb846ca370dda9276057aed7925bf769 Mon Sep 17 00:00:00 2001 From: Icarus <1375400884@qq.com> Date: Mon, 3 Aug 2020 01:16:16 +0800 Subject: [PATCH 64/65] !WT --- Scripts/NodePort.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Scripts/NodePort.cs b/Scripts/NodePort.cs index 5f606a2..fea85c8 100644 --- a/Scripts/NodePort.cs +++ b/Scripts/NodePort.cs @@ -19,7 +19,7 @@ namespace XNode { } } - public IO direction { + public IO direction { get { return _direction; } internal set { _direction = value; } } @@ -48,7 +48,7 @@ namespace XNode { valueType = null; } #endif - + public Type ValueType { get { if (valueType == null && !string.IsNullOrEmpty(_typeQualifiedName)) valueType = Type.GetType(_typeQualifiedName, false); @@ -59,10 +59,11 @@ namespace XNode { if (value != null) _typeQualifiedName = value.AssemblyQualifiedName; } } - + private Type valueType; #if UNITY_EDITOR public const string FIELDNAMEEDITOR = nameof(_fieldName); + public const string ConnectionsEditor = nameof(connections); #endif [SerializeField] private string _fieldName; [SerializeField] private Node _node; From e49753c58503b1a20a515660397b07d3b6fa595b Mon Sep 17 00:00:00 2001 From: Icarus <1375400884@qq.com> Date: Thu, 6 Aug 2020 21:25:03 +0800 Subject: [PATCH 65/65] !TX --- Scripts/Editor/NodeEditor.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/Scripts/Editor/NodeEditor.cs b/Scripts/Editor/NodeEditor.cs index 7f10a0e..4262231 100644 --- a/Scripts/Editor/NodeEditor.cs +++ b/Scripts/Editor/NodeEditor.cs @@ -134,8 +134,6 @@ namespace XNodeEditor { public Vector2 GetCurrentMousePosition(float yOffset = 10) { - Debug.LogError(Event.current.mousePosition + ":" + target.position); - var mouseGridPos = Event.current.mousePosition;//* window.zoom; var nodeWindowPos = window.GridToWindowPosition(target.position + mouseGridPos);