tanghai 9 лет назад
Родитель
Сommit
c5ce87b730
100 измененных файлов с 3188 добавлено и 3187 удалено
  1. 1 4
      Unity/Assets/Editor/BehaviorTreeEditor/BehaviorBatchOperation.cs
  2. 0 2
      Unity/Assets/Editor/BehaviorTreeEditor/BehaviorDesignerUtility.cs
  3. 85 77
      Unity/Assets/Editor/BehaviorTreeEditor/BehaviorDesignerWindow.cs
  4. 243 239
      Unity/Assets/Editor/BehaviorTreeEditor/BehaviorManager.cs
  5. 58 60
      Unity/Assets/Editor/BehaviorTreeEditor/BehaviorNodeConfigExtension.cs
  6. 18 42
      Unity/Assets/Editor/BehaviorTreeEditor/BehaviorNodeData.cs
  7. 15 16
      Unity/Assets/Editor/BehaviorTreeEditor/BehaviorTreeConfigEditor.cs
  8. 49 51
      Unity/Assets/Editor/BehaviorTreeEditor/BehaviorTreeConfigExtension.cs
  9. 1 1
      Unity/Assets/Editor/BehaviorTreeEditor/BehaviorTreeData.cs
  10. 2 6
      Unity/Assets/Editor/BehaviorTreeEditor/BehaviorTreeMenu.cs
  11. 158 154
      Unity/Assets/Editor/BehaviorTreeEditor/BehaviorTreeNodeClassPopup.cs
  12. 156 159
      Unity/Assets/Editor/BehaviorTreeEditor/BehaviorTreeOperateUtility.cs
  13. 25 28
      Unity/Assets/Editor/BehaviorTreeEditor/BehaviorTreeToolWindow.cs
  14. 6 6
      Unity/Assets/Editor/BehaviorTreeEditor/Event/BehaviorTreeOpenEditorEvent_SelectNode.cs
  15. 9 10
      Unity/Assets/Editor/BehaviorTreeEditor/Event/BehaviorTreeRightDesignerDragEvent_ModifyRightBorder.cs
  16. 13 14
      Unity/Assets/Editor/BehaviorTreeEditor/ExportNodeTypeConfig.cs
  17. 132 129
      Unity/Assets/Editor/BehaviorTreeEditor/GraphDesigner.cs
  18. 266 260
      Unity/Assets/Editor/BehaviorTreeEditor/NodeExtension.cs
  19. 40 38
      Unity/Assets/Editor/BehaviorTreeEditor/PropertyDesigner.cs
  20. 306 295
      Unity/Assets/Editor/BehaviorTreeEditor/RightDesigner.cs
  21. 4 7
      Unity/Assets/Editor/EditorInit.cs
  22. 1 2
      Unity/Assets/Editor/ObjectManagerToolsEditor/ObjectManagerToolsWindow.cs
  23. 10 10
      Unity/Assets/Editor/ReferenceCollectorEditor/ReferenceCollectorEditor.cs
  24. 1 1
      Unity/Assets/Editor/RsyncEditor/RsyncConfig.cs
  25. 8 17
      Unity/Assets/Editor/RsyncEditor/RsyncEditor.cs
  26. 8 13
      Unity/Assets/Editor/ServerCommandLineEditor/ServerCommandLineEditor.cs
  27. 5 6
      Unity/Assets/Editor/ServerManagerEditor/ServerManagerEditor.cs
  28. 4 4
      Unity/Assets/Scripts/BehaviorTree/BTEnv.cs
  29. 8 5
      Unity/Assets/Scripts/BehaviorTree/BTEnvKey.cs
  30. 84 84
      Unity/Assets/Scripts/BehaviorTree/BehaviorNodeConfig.cs
  31. 25 25
      Unity/Assets/Scripts/BehaviorTree/BehaviorTree.cs
  32. 615 600
      Unity/Assets/Scripts/BehaviorTree/BehaviorTreeArgsDict.cs
  33. 35 18
      Unity/Assets/Scripts/BehaviorTree/BehaviorTreeConfig.cs
  34. 4 6
      Unity/Assets/Scripts/BehaviorTree/BehaviorTreeType/BTTypeBaseComponent.cs
  35. 31 31
      Unity/Assets/Scripts/BehaviorTree/BehaviorTreeType/BTTypeManager.cs
  36. 4 4
      Unity/Assets/Scripts/BehaviorTree/BehaviorTreeType/BaseType/BTArrayDoubleComponent.cs
  37. 4 4
      Unity/Assets/Scripts/BehaviorTree/BehaviorTreeType/BaseType/BTArrayFloatComponent.cs
  38. 4 4
      Unity/Assets/Scripts/BehaviorTree/BehaviorTreeType/BaseType/BTArrayInt64Component.cs
  39. 4 4
      Unity/Assets/Scripts/BehaviorTree/BehaviorTreeType/BaseType/BTArrayIntComponent.cs
  40. 4 4
      Unity/Assets/Scripts/BehaviorTree/BehaviorTreeType/BaseType/BTArrayStringComponent.cs
  41. 4 4
      Unity/Assets/Scripts/BehaviorTree/BehaviorTreeType/BaseType/BTBoolComponent.cs
  42. 4 4
      Unity/Assets/Scripts/BehaviorTree/BehaviorTreeType/BaseType/BTDoubleComponent.cs
  43. 5 6
      Unity/Assets/Scripts/BehaviorTree/BehaviorTreeType/BaseType/BTEnumComponent.cs
  44. 4 4
      Unity/Assets/Scripts/BehaviorTree/BehaviorTreeType/BaseType/BTFloatComponent.cs
  45. 4 4
      Unity/Assets/Scripts/BehaviorTree/BehaviorTreeType/BaseType/BTInt64Component.cs
  46. 4 4
      Unity/Assets/Scripts/BehaviorTree/BehaviorTreeType/BaseType/BTIntComponent.cs
  47. 4 4
      Unity/Assets/Scripts/BehaviorTree/BehaviorTreeType/BaseType/BTStringComponent.cs
  48. 5 4
      Unity/Assets/Scripts/BehaviorTree/BehaviorTreeType/UnityType/BTArrayAudioClipComponent.cs
  49. 5 4
      Unity/Assets/Scripts/BehaviorTree/BehaviorTreeType/UnityType/BTArrayGameObjectComponent.cs
  50. 5 4
      Unity/Assets/Scripts/BehaviorTree/BehaviorTreeType/UnityType/BTArrayMaterialComponent.cs
  51. 5 4
      Unity/Assets/Scripts/BehaviorTree/BehaviorTreeType/UnityType/BTArrayShaderComponent.cs
  52. 5 4
      Unity/Assets/Scripts/BehaviorTree/BehaviorTreeType/UnityType/BTArraySpriteComponent..cs
  53. 5 4
      Unity/Assets/Scripts/BehaviorTree/BehaviorTreeType/UnityType/BTArrayTexture2DComponent..cs
  54. 5 4
      Unity/Assets/Scripts/BehaviorTree/BehaviorTreeType/UnityType/BTArrayTexture3DComponent..cs
  55. 5 4
      Unity/Assets/Scripts/BehaviorTree/BehaviorTreeType/UnityType/BTArrayTextureComponent.cs
  56. 5 4
      Unity/Assets/Scripts/BehaviorTree/BehaviorTreeType/UnityType/BTAudioClipComponent.cs
  57. 5 4
      Unity/Assets/Scripts/BehaviorTree/BehaviorTreeType/UnityType/BTGameObjectComponent.cs
  58. 5 4
      Unity/Assets/Scripts/BehaviorTree/BehaviorTreeType/UnityType/BTMaterialComponent.cs
  59. 5 4
      Unity/Assets/Scripts/BehaviorTree/BehaviorTreeType/UnityType/BTShaderComponent.cs
  60. 5 4
      Unity/Assets/Scripts/BehaviorTree/BehaviorTreeType/UnityType/BTSpriteComponent.cs
  61. 5 4
      Unity/Assets/Scripts/BehaviorTree/BehaviorTreeType/UnityType/BTTexture2DComponent.cs
  62. 5 4
      Unity/Assets/Scripts/BehaviorTree/BehaviorTreeType/UnityType/BTTexture3DComponent.cs
  63. 5 4
      Unity/Assets/Scripts/BehaviorTree/BehaviorTreeType/UnityType/BTTextureComponent.cs
  64. 35 36
      Unity/Assets/Scripts/BehaviorTree/ClientNodeTypeProto.cs
  65. 72 78
      Unity/Assets/Scripts/BehaviorTree/Node.cs
  66. 12 11
      Unity/Assets/Scripts/BehaviorTree/NodeAttribute.cs
  67. 9 9
      Unity/Assets/Scripts/BehaviorTree/NodeClassifyType.cs
  68. 10 9
      Unity/Assets/Scripts/BehaviorTree/NodeDeprecatedAttribute.cs
  69. 5 5
      Unity/Assets/Scripts/BehaviorTree/NodeDesignerProto.cs
  70. 7 7
      Unity/Assets/Scripts/BehaviorTree/NodeEngineObjectAttribute.cs
  71. 14 13
      Unity/Assets/Scripts/BehaviorTree/NodeFieldBaseAttribute.cs
  72. 10 9
      Unity/Assets/Scripts/BehaviorTree/NodeFieldConstraintAttribute.cs
  73. 13 13
      Unity/Assets/Scripts/BehaviorTree/NodeInputAttribute.cs
  74. 13 13
      Unity/Assets/Scripts/BehaviorTree/NodeOutputAttribute.cs
  75. 7 7
      Unity/Assets/Scripts/BehaviorTree/NodePropAttribute.cs
  76. 118 116
      Unity/Assets/Scripts/BehaviorTree/NodeProto.cs
  77. 181 182
      Unity/Assets/Scripts/BehaviorTree/ValueBase.cs
  78. 2 2
      Unity/Assets/Scripts/Component/BenchmarkComponent.cs
  79. 9 9
      Unity/Assets/Scripts/Component/ChildrenComponent.cs
  80. 4 4
      Unity/Assets/Scripts/Component/ClientConfigComponent.cs
  81. 1 1
      Unity/Assets/Scripts/Component/Config/ClientConfig.cs
  82. 2 2
      Unity/Assets/Scripts/Component/Config/InnerConfig.cs
  83. 2 2
      Unity/Assets/Scripts/Component/Config/OuterConfig.cs
  84. 1 1
      Unity/Assets/Scripts/Component/Config/RunServerConfig.cs
  85. 0 1
      Unity/Assets/Scripts/Component/ConfigComponent.cs
  86. 31 30
      Unity/Assets/Scripts/Component/EventComponent.cs
  87. 4 4
      Unity/Assets/Scripts/Component/GameObjectComponent.cs
  88. 6 7
      Unity/Assets/Scripts/Component/KVComponent.cs
  89. 6 6
      Unity/Assets/Scripts/Component/MessageDispatherComponent.cs
  90. 2 2
      Unity/Assets/Scripts/Component/NetInnerComponent.cs
  91. 2 2
      Unity/Assets/Scripts/Component/NetOuterComponent.cs
  92. 1 2
      Unity/Assets/Scripts/Component/NetworkComponent.cs
  93. 15 14
      Unity/Assets/Scripts/Component/ResourcesComponent.cs
  94. 4 4
      Unity/Assets/Scripts/Component/RobotComponent.cs
  95. 17 17
      Unity/Assets/Scripts/Component/TimeComponent.cs
  96. 5 21
      Unity/Assets/Scripts/Component/TimerComponent.cs
  97. 4 5
      Unity/Assets/Scripts/Component/UIComponent.cs
  98. 4 4
      Unity/Assets/Scripts/Config/ACategory.cs
  99. 3 3
      Unity/Assets/Scripts/Config/AConfigComponent.cs
  100. 2 2
      Unity/Assets/Scripts/Config/ConfigHelper.cs

+ 1 - 4
Unity/Assets/Editor/BehaviorTreeEditor/BehaviorBatchOperation.cs

@@ -1,11 +1,9 @@
 using System;
 using System.Collections.Generic;
-using System.IO;
 using System.Reflection;
 using Base;
 using Model;
 using UnityEditor;
-using UnityEngine;
 
 namespace MyEditor
 {
@@ -37,13 +35,12 @@ namespace MyEditor
 			}
 		}
 
-        public static void SaveOneTree(BehaviorTreeConfig treeConfig, string treePath, params object[] paramList)
+		public static void SaveOneTree(BehaviorTreeConfig treeConfig, string treePath, params object[] paramList)
 		{
 			EditorUtility.SetDirty(treeConfig.gameObject);
 			AssetDatabase.SaveAssets();
 		}
 
-
 		public static void CheckHasName(BehaviorTreeConfig config, string path, string nodeName)
 		{
 			if (HasNode(config.RootNodeProto, nodeName))

+ 0 - 2
Unity/Assets/Editor/BehaviorTreeEditor/BehaviorDesignerUtility.cs

@@ -1,6 +1,5 @@
 using System;
 using System.Collections.Generic;
-using Base;
 using UnityEditor;
 using UnityEngine;
 
@@ -30,7 +29,6 @@ namespace MyEditor
 			{
 				throw new Exception($"无法找到资源: {imageName}", e);
 			}
-
 		}
 
 		public static void DrawConnection(Vector2 src, Vector2 dst)

+ 85 - 77
Unity/Assets/Editor/BehaviorTreeEditor/BehaviorDesignerWindow.cs

@@ -1,16 +1,15 @@
-using Model;
-using System;
-using System.Collections.Generic;
+using System;
 using UnityEditor;
 using UnityEngine;
 
 namespace MyEditor
 {
-    public enum SubWinType
-    {
-        CreateNode,
-        ReplaceNode,
-    }
+	public enum SubWinType
+	{
+		CreateNode,
+		ReplaceNode
+	}
+
 	public class MessageBoxArgs: EventArgs
 	{
 		public string msg;
@@ -20,11 +19,12 @@ namespace MyEditor
 	{
 		private GraphDesigner mGraphDesigner;
 		private PropertyDesigner mPropDesigner;
-        private RightDesigner mRightDesigner;
-        private static bool mShowSubWin;
-        private SubWinType mSubWinType;
-        private BehaviorTreeNodeClassPopup popUpMenu;
-        public GraphDesigner GraphDesigner
+		private RightDesigner mRightDesigner;
+		private static bool mShowSubWin;
+		private SubWinType mSubWinType;
+		private BehaviorTreeNodeClassPopup popUpMenu;
+
+		public GraphDesigner GraphDesigner
 		{
 			get
 			{
@@ -39,48 +39,55 @@ namespace MyEditor
 				return GetWindow<BehaviorDesignerWindow>(false, "行为树编辑器");
 			}
 		}
-        public static bool IsShowSubWin
-        {
-            get
-            {
-                return mShowSubWin;
-            }
-        }
+
+		public static bool IsShowSubWin
+		{
+			get
+			{
+				return mShowSubWin;
+			}
+		}
+
 		public static void ShowWindow()
 		{
 			BehaviorDesignerWindow target = GetWindow<BehaviorDesignerWindow>("行为树编辑器", false);
-            target.minSize = new Vector2(600f, 500f);
-        }
-
-        public void ShowSubWin(Vector2 pos,SubWinType subWinType)
-        {
-            mShowSubWin = true;
-            popUpMenu.Show(windowRect, subWinType);
-            windowRect.position = pos;
-        }
-        public void CloseSubWin()
-        {
-            mShowSubWin = false;
-        }
-        public static Rect windowRect = new Rect(400, 250, 400, 550);//子窗口的大小和位置
-        public void DrawSubWindow()
-        {
-            BeginWindows();//标记开始区域所有弹出式窗口
-            windowRect = GUILayout.Window(1, windowRect, DoWindow, "行为树节点");//创建内联窗口,参数分别为id,大小位置,创建子窗口的组件的函数,标题
-            EndWindows();//标记结束
-        }
-        void DoWindow(int unusedWindowID)
-        {
-            popUpMenu.DrawSearchList();
-            GUI.DragWindow();//画出子窗口
-        }
-        public void Awake()
-        {
-			mGraphDesigner = ScriptableObject.CreateInstance<GraphDesigner>();
-			mPropDesigner = ScriptableObject.CreateInstance<PropertyDesigner>();
-           // mRightDesigner = new RightDesigner();
-            popUpMenu = new BehaviorTreeNodeClassPopup();
-            popUpMenu.GraphDesigner = mGraphDesigner;
+			target.minSize = new Vector2(600f, 500f);
+		}
+
+		public void ShowSubWin(Vector2 pos, SubWinType subWinType)
+		{
+			mShowSubWin = true;
+			popUpMenu.Show(windowRect, subWinType);
+			windowRect.position = pos;
+		}
+
+		public void CloseSubWin()
+		{
+			mShowSubWin = false;
+		}
+
+		public static Rect windowRect = new Rect(400, 250, 400, 550); //子窗口的大小和位置
+
+		public void DrawSubWindow()
+		{
+			BeginWindows(); //标记开始区域所有弹出式窗口
+			windowRect = GUILayout.Window(1, windowRect, DoWindow, "行为树节点"); //创建内联窗口,参数分别为id,大小位置,创建子窗口的组件的函数,标题
+			EndWindows(); //标记结束
+		}
+
+		void DoWindow(int unusedWindowID)
+		{
+			popUpMenu.DrawSearchList();
+			GUI.DragWindow(); //画出子窗口
+		}
+
+		public void Awake()
+		{
+			mGraphDesigner = CreateInstance<GraphDesigner>();
+			mPropDesigner = CreateInstance<PropertyDesigner>();
+			// mRightDesigner = new RightDesigner();
+			popUpMenu = new BehaviorTreeNodeClassPopup();
+			popUpMenu.GraphDesigner = mGraphDesigner;
 			//mGraphDesigner.onSelectTree();
 		}
 
@@ -89,12 +96,12 @@ namespace MyEditor
 			HandleEvents();
 			mPropDesigner?.Draw();
 			mGraphDesigner?.Draw(this.position);
-          //  mRightDesigner?.Draw();
-            if (mShowSubWin)
-            {
-                DrawSubWindow();
-            }
-            this.Repaint();
+			//  mRightDesigner?.Draw();
+			if (mShowSubWin)
+			{
+				DrawSubWindow();
+			}
+			this.Repaint();
 		}
 
 		public void HandleEvents()
@@ -107,15 +114,15 @@ namespace MyEditor
 					{
 						BehaviorManager.GetInstance().SaveAll();
 					}
-                    else if (e.keyCode == KeyCode.F4)
-                    {
-                        BehaviorManager.GetInstance().SaveAll();
-                    }
-                    break;
-                case EventType.MouseDown:
-                    
-                    break;
-            }
+					else if (e.keyCode == KeyCode.F4)
+					{
+						BehaviorManager.GetInstance().SaveAll();
+					}
+					break;
+				case EventType.MouseDown:
+
+					break;
+			}
 		}
 
 		public void OnDestroy()
@@ -136,14 +143,14 @@ namespace MyEditor
 
 		public void OnSelectNode(params object[] list)
 		{
-            if (list.Length == 0)
-            {
-                Debug.LogError(" node list can not be null");
-                return;
-            }
+			if (list.Length == 0)
+			{
+				Debug.LogError(" node list can not be null");
+				return;
+			}
 			mGraphDesigner.onSelectNode(list);
 			mPropDesigner.onSelectNode(list);
-    //      mRightDesigner.onSelectNode(list);
+			//      mRightDesigner.onSelectNode(list);
 		}
 
 		public void onStartConnect(NodeDesigner nodeDesigner, State state)
@@ -170,9 +177,10 @@ namespace MyEditor
 		{
 			return mGraphDesigner.onCreateTree();
 		}
-        public void onDraggingRightDesigner(float deltaX)
-        {
-     //       mRightDesigner.onDraggingBorder(deltaX);
-        }    
+
+		public void onDraggingRightDesigner(float deltaX)
+		{
+			//       mRightDesigner.onDraggingBorder(deltaX);
+		}
 	}
 }

+ 243 - 239
Unity/Assets/Editor/BehaviorTreeEditor/BehaviorManager.cs

@@ -1,10 +1,11 @@
 using System;
 using System.Collections.Generic;
+using System.Reflection;
+using Base;
 using Model;
 using UnityEditor;
 using UnityEngine;
-using System.Reflection;
-using Base;
+using Component = UnityEngine.Component;
 using Object = UnityEngine.Object;
 
 namespace MyEditor
@@ -13,9 +14,9 @@ namespace MyEditor
 	{
 		public GameObject CurTreeGO { get; set; }
 		public BehaviorTreeData CurTree { get; set; }
-        public const int NodeIdStartIndex = 100000;
-        private int AutoID = NodeIdStartIndex;
-        private Dictionary<string, ClientNodeTypeProto> mName2NodeProtoDict = new Dictionary<string, ClientNodeTypeProto>(); //节点类型 name索引
+		public const int NodeIdStartIndex = 100000;
+		private int AutoID = NodeIdStartIndex;
+		private Dictionary<string, ClientNodeTypeProto> mName2NodeProtoDict = new Dictionary<string, ClientNodeTypeProto>(); //节点类型 name索引
 		private Dictionary<string, List<ClientNodeTypeProto>> mClassify2NodeProtoList = new Dictionary<string, List<ClientNodeTypeProto>>(); //节点分类 分类名索引
 		private readonly Dictionary<int, NodeDesignerProto> mId2DesignerDict = new Dictionary<int, NodeDesignerProto>();
 		private static BehaviorManager mInstance = new BehaviorManager();
@@ -40,7 +41,7 @@ namespace MyEditor
 			}
 			return mInstance;
 		}
-         
+
 		public Dictionary<string, List<ClientNodeTypeProto>> Classify2NodeProtoList
 		{
 			get
@@ -48,25 +49,25 @@ namespace MyEditor
 				return mClassify2NodeProtoList;
 			}
 		}
-       
-        public List<ClientNodeTypeProto> AllNodeProtoList
-        {
-            get
-            {
-                List<ClientNodeTypeProto> list = new List<ClientNodeTypeProto>();
-                foreach (var item in BehaviorManager.GetInstance().Classify2NodeProtoList)
-                {
-                    foreach (var proto in item.Value)
-                    {
-                        list.Add(proto);
-                    }
-                }
-                return list;
-            }
-        }
-
-        //节点配置 get set
-        public ClientNodeTypeProto GetNodeTypeProto(string name)
+
+		public List<ClientNodeTypeProto> AllNodeProtoList
+		{
+			get
+			{
+				List<ClientNodeTypeProto> list = new List<ClientNodeTypeProto>();
+				foreach (var item in GetInstance().Classify2NodeProtoList)
+				{
+					foreach (var proto in item.Value)
+					{
+						list.Add(proto);
+					}
+				}
+				return list;
+			}
+		}
+
+		//节点配置 get set
+		public ClientNodeTypeProto GetNodeTypeProto(string name)
 		{
 			ClientNodeTypeProto proto = ExportNodeTypeConfig.GetNodeTypeProtoFromDll(name);
 			return proto;
@@ -96,38 +97,37 @@ namespace MyEditor
 
 		public int AutoNodeId()
 		{
-            return ++AutoID;
+			return ++AutoID;
 		}
-         
-        public void NewLoadData()
-        {
+
+		public void NewLoadData()
+		{
 			Game.EntityEventManager.Register("Controller", DllHelper.GetController());
 
 			LoadNodeTypeProto();
-            NewLoadPrefabTree();
-            FilterClassify();
-        }
+			NewLoadPrefabTree();
+			FilterClassify();
+		}
 
-        public void LoadNodeTypeProto()
+		public void LoadNodeTypeProto()
 		{
 			mName2NodeProtoDict = ExportNodeTypeConfig.ExportToDict();
 		}
-         
-        public void NewLoadPrefabTree()
-        {
-            BehaviorTreeConfig config = CurTreeGO.GetComponent<BehaviorTreeConfig>();
-            CurTree = BehaviorTreeConfigToTreeData(config);
-        }
-        
-      
-        public BehaviorTreeData BehaviorTreeConfigToTreeData(BehaviorTreeConfig config)
-        {
-            BehaviorTreeData tree = new BehaviorTreeData();
-            tree.Root = NodeConfigToNodeData(config.RootNodeConfig);
-            return tree;
-        }
-
-        public void printTree(BehaviorNodeData nodeData)
+
+		public void NewLoadPrefabTree()
+		{
+			BehaviorTreeConfig config = CurTreeGO.GetComponent<BehaviorTreeConfig>();
+			CurTree = BehaviorTreeConfigToTreeData(config);
+		}
+
+		public BehaviorTreeData BehaviorTreeConfigToTreeData(BehaviorTreeConfig config)
+		{
+			BehaviorTreeData tree = new BehaviorTreeData();
+			tree.Root = NodeConfigToNodeData(config.RootNodeConfig);
+			return tree;
+		}
+
+		public void printTree(BehaviorNodeData nodeData)
 		{
 			Log.Info($"printTree  :  {nodeData.nodeId} {nodeData}");
 			foreach (var data in nodeData.children)
@@ -135,12 +135,13 @@ namespace MyEditor
 				printTree(data);
 			}
 		}
-        public bool CheckSatisfyInput()
-        {
-            NodeProto rootNode = NodeDataToNodeProto(CurTree.BehaviorNodeData);
-            return CheckNodeInput(rootNode);
-        }
-       
+
+		public bool CheckSatisfyInput()
+		{
+			NodeProto rootNode = NodeDataToNodeProto(CurTree.BehaviorNodeData);
+			return CheckNodeInput(rootNode);
+		}
+
 		public bool CheckNodeInput(NodeProto nodeProto)
 		{
 			List<NodeFieldDesc> list = ExportNodeTypeConfig.GetNodeFieldInOutPutDescList(nodeProto.name, typeof (NodeInputAttribute));
@@ -164,39 +165,41 @@ namespace MyEditor
 			}
 			return true;
 		}
- 
-        public void SaveAll()
-        {
-            if (!CheckHasTreeDesc())
-            {
-                return;
-            }
-            if (!CheckSatisfyInput())
-            {
-                return;
-            }
-            SavePrefabTree();
-            Log.Info("保存成功!");
-            BehaviorTreeTipsHelper.ShowMessage("保存成功!");
-        }
-        private void SavePrefabTree()
-        {
-            ResetTreeId();
-           
-            BehaviorTreeConfig config = BehaviorTreeDataToConfig(CurTree);
-            RenameTree(config);
-            GameObject.DestroyImmediate(config.gameObject);
-        }
-        public void ResetTreeId()
-		{
-            AutoID = NodeIdStartIndex;
-            CurTree.Root.ResetId();
-        }
-        public void TransformTree(GameObject go)
-        {
- 
-        }
- 
+
+		public void SaveAll()
+		{
+			if (!CheckHasTreeDesc())
+			{
+				return;
+			}
+			if (!CheckSatisfyInput())
+			{
+				return;
+			}
+			SavePrefabTree();
+			Log.Info("保存成功!");
+			BehaviorTreeTipsHelper.ShowMessage("保存成功!");
+		}
+
+		private void SavePrefabTree()
+		{
+			ResetTreeId();
+
+			BehaviorTreeConfig config = BehaviorTreeDataToConfig(CurTree);
+			RenameTree(config);
+			GameObject.DestroyImmediate(config.gameObject);
+		}
+
+		public void ResetTreeId()
+		{
+			AutoID = NodeIdStartIndex;
+			CurTree.Root.ResetId();
+		}
+
+		public void TransformTree(GameObject go)
+		{
+		}
+
 		public void RemoveUnusedArgs(NodeProto nodeProto)
 		{
 			ClientNodeTypeProto proto = ExportNodeTypeConfig.GetNodeTypeProtoFromDll(nodeProto.name);
@@ -218,129 +221,130 @@ namespace MyEditor
 			}
 		}
 
- 
-        private bool CheckHasTreeDesc()
-        {
-            if (string.IsNullOrEmpty(CurTree.Root.describe))
-            {
-                Log.Error("行为树描述不可以不填!!!!!!");
-                return false;
-            }
-            return true;
-        }
- 
-        public void RenameTree(BehaviorTreeConfig config)
-        {
-            string newName = $"{config.RootNodeConfig.describe}";
-            if (!config.RootNodeConfig.describe.StartsWith("BT_"))
-            {
-                newName = $"BT_{config.RootNodeConfig.describe}";
-            }
-            config.gameObject.name = newName;
-            CurTreeGO =  PrefabUtility.ReplacePrefab(config.gameObject, CurTreeGO,ReplacePrefabOptions.ReplaceNameBased);
-            string prefabPath = AssetDatabase.GetAssetPath(CurTreeGO);
-            string result = AssetDatabase.RenameAsset(prefabPath, newName);
-            if (result.Contains("Invalid file name"))
-            {
-                Log.Error(result);
-            }
-            EditorUtility.SetDirty(config.gameObject);
-        }
-        public BehaviorTreeConfig BehaviorTreeDataToConfig(BehaviorTreeData tree)
-        {
-           GameObject curTreeGo = GameObject.Instantiate(CurTreeGO);
-           BehaviorTreeConfig config = curTreeGo.GetComponent<BehaviorTreeConfig>();
-            if (config == null)
-            {
-                config = curTreeGo.AddComponent<BehaviorTreeConfig>();
-            }
-           foreach (Transform child in config.gameObject.transform)
-           {
-                GameObject.DestroyImmediate(child.gameObject);
-           }
-           try
-           {
-                config.RootNodeConfig = NodeDataToNodeConfig(tree.Root);
-            }
-           catch
-           {
-                Debug.LogError($"tree name : {tree.BehaviorNodeData.name}");
-           }
-            
-            config.RootNodeConfig.gameObject.transform.parent = config.gameObject.transform;
-            return config;
-        }
-
-        public BehaviorNodeData NodeConfigToNodeData(BehaviorNodeConfig nodeProto)
-        {
-            BehaviorNodeData nodeData = new BehaviorNodeData();
-            nodeData.nodeId = nodeProto.id;
-            nodeData.name = ((Object) nodeProto).name;
-            nodeData.describe = nodeProto.describe;
-            nodeData.args_dict = nodeProto.GetArgsDict();
-            nodeData.children = new List<BehaviorNodeData>();
-//             foreach (var item in nodeData.args_dict)
-//             {
-//                 Log.Info($"key :{item.Key} value :{item.Value}");
-//             }
-            foreach (Transform child in nodeProto.gameObject.transform)
-            {
-                BehaviorNodeConfig nodeConfig = child.gameObject.GetComponent<BehaviorNodeConfig>();
-                BehaviorNodeData childData = NodeConfigToNodeData(nodeConfig);
-                nodeData.children.Add(childData);
-            }
-            return nodeData;
-        }
-        public BehaviorNodeConfig NodeDataToNodeConfig(BehaviorNodeData nodeData)
-        {
-            GameObject go = new GameObject();
-            BehaviorNodeConfig nodeConfig = go.AddComponent<BehaviorNodeConfig>();
-            nodeConfig.id = nodeData.nodeId;
-            ((Object) nodeConfig).name = nodeData.name;
-            go.name = nodeData.name;
-            nodeConfig.describe = nodeData.describe;
-            List<string> unUseList = new List<string>();
-            foreach (var args in nodeData.args_dict)
-            {
-                if (!ExportNodeTypeConfig.NodeHasField(nodeData.name,args.Key))
-                {
-                    unUseList.Add(args.Key);
-                    continue;
-                }
-                Type originType = ExportNodeTypeConfig.GetFieldType(nodeData.name, args.Key);
-                try
-                {
-                    string fieldName = args.Key;
-                    object fieldValue = args.Value.GetValueByType(originType);
-                    Type type = BTTypeManager.GetBTType(originType);
-                    UnityEngine.Component comp = go.AddComponent(type);
-                    FieldInfo fieldNameInfo = type.GetField("fieldName");
-                    fieldNameInfo.SetValue(comp, fieldName);
-                    FieldInfo fieldValueinfo = type.GetField("fieldValue");
-                    if (BehaviorTreeArgsDict.IsEnumType(originType))
-                    {
-                        fieldValue = fieldValue.ToString();
-                    }
-                    fieldValueinfo.SetValue(comp, fieldValue);
-                }
-                catch (Exception e)
-                {
-                     throw new Exception($"transform failed,nodeName:{nodeData.name}  fieldName:{args.Key} fieldType:{originType}", e);
-                }
-            }
-            foreach (string key in unUseList)
-            {
-                nodeData.args_dict.Remove(key);
-            }
-            foreach (var child in nodeData.children)
-            {
-                BehaviorNodeConfig childConfig = NodeDataToNodeConfig(child);
-                childConfig.gameObject.transform.parent = nodeConfig.gameObject.transform;
-            }
-            return nodeConfig;
-        }
-        
-        public BehaviorNodeData NodeProtoToNodeData(NodeProto nodeProto)
+		private bool CheckHasTreeDesc()
+		{
+			if (string.IsNullOrEmpty(CurTree.Root.describe))
+			{
+				Log.Error("行为树描述不可以不填!!!!!!");
+				return false;
+			}
+			return true;
+		}
+
+		public void RenameTree(BehaviorTreeConfig config)
+		{
+			string newName = $"{config.RootNodeConfig.describe}";
+			if (!config.RootNodeConfig.describe.StartsWith("BT_"))
+			{
+				newName = $"BT_{config.RootNodeConfig.describe}";
+			}
+			config.gameObject.name = newName;
+			CurTreeGO = PrefabUtility.ReplacePrefab(config.gameObject, CurTreeGO, ReplacePrefabOptions.ReplaceNameBased);
+			string prefabPath = AssetDatabase.GetAssetPath(CurTreeGO);
+			string result = AssetDatabase.RenameAsset(prefabPath, newName);
+			if (result.Contains("Invalid file name"))
+			{
+				Log.Error(result);
+			}
+			EditorUtility.SetDirty(config.gameObject);
+		}
+
+		public BehaviorTreeConfig BehaviorTreeDataToConfig(BehaviorTreeData tree)
+		{
+			GameObject curTreeGo = GameObject.Instantiate(CurTreeGO);
+			BehaviorTreeConfig config = curTreeGo.GetComponent<BehaviorTreeConfig>();
+			if (config == null)
+			{
+				config = curTreeGo.AddComponent<BehaviorTreeConfig>();
+			}
+			foreach (Transform child in config.gameObject.transform)
+			{
+				GameObject.DestroyImmediate(child.gameObject);
+			}
+			try
+			{
+				config.RootNodeConfig = NodeDataToNodeConfig(tree.Root);
+			}
+			catch
+			{
+				Debug.LogError($"tree name : {tree.BehaviorNodeData.name}");
+			}
+
+			config.RootNodeConfig.gameObject.transform.parent = config.gameObject.transform;
+			return config;
+		}
+
+		public BehaviorNodeData NodeConfigToNodeData(BehaviorNodeConfig nodeProto)
+		{
+			BehaviorNodeData nodeData = new BehaviorNodeData();
+			nodeData.nodeId = nodeProto.id;
+			nodeData.name = ((Object) nodeProto).name;
+			nodeData.describe = nodeProto.describe;
+			nodeData.args_dict = nodeProto.GetArgsDict();
+			nodeData.children = new List<BehaviorNodeData>();
+			//             foreach (var item in nodeData.args_dict)
+			//             {
+			//                 Log.Info($"key :{item.Key} value :{item.Value}");
+			//             }
+			foreach (Transform child in nodeProto.gameObject.transform)
+			{
+				BehaviorNodeConfig nodeConfig = child.gameObject.GetComponent<BehaviorNodeConfig>();
+				BehaviorNodeData childData = NodeConfigToNodeData(nodeConfig);
+				nodeData.children.Add(childData);
+			}
+			return nodeData;
+		}
+
+		public BehaviorNodeConfig NodeDataToNodeConfig(BehaviorNodeData nodeData)
+		{
+			GameObject go = new GameObject();
+			BehaviorNodeConfig nodeConfig = go.AddComponent<BehaviorNodeConfig>();
+			nodeConfig.id = nodeData.nodeId;
+			((Object) nodeConfig).name = nodeData.name;
+			go.name = nodeData.name;
+			nodeConfig.describe = nodeData.describe;
+			List<string> unUseList = new List<string>();
+			foreach (var args in nodeData.args_dict)
+			{
+				if (!ExportNodeTypeConfig.NodeHasField(nodeData.name, args.Key))
+				{
+					unUseList.Add(args.Key);
+					continue;
+				}
+				Type originType = ExportNodeTypeConfig.GetFieldType(nodeData.name, args.Key);
+				try
+				{
+					string fieldName = args.Key;
+					object fieldValue = args.Value.GetValueByType(originType);
+					Type type = BTTypeManager.GetBTType(originType);
+					Component comp = go.AddComponent(type);
+					FieldInfo fieldNameInfo = type.GetField("fieldName");
+					fieldNameInfo.SetValue(comp, fieldName);
+					FieldInfo fieldValueinfo = type.GetField("fieldValue");
+					if (BehaviorTreeArgsDict.IsEnumType(originType))
+					{
+						fieldValue = fieldValue.ToString();
+					}
+					fieldValueinfo.SetValue(comp, fieldValue);
+				}
+				catch (Exception e)
+				{
+					throw new Exception($"transform failed,nodeName:{nodeData.name}  fieldName:{args.Key} fieldType:{originType}", e);
+				}
+			}
+			foreach (string key in unUseList)
+			{
+				nodeData.args_dict.Remove(key);
+			}
+			foreach (var child in nodeData.children)
+			{
+				BehaviorNodeConfig childConfig = NodeDataToNodeConfig(child);
+				childConfig.gameObject.transform.parent = nodeConfig.gameObject.transform;
+			}
+			return nodeConfig;
+		}
+
+		public BehaviorNodeData NodeProtoToNodeData(NodeProto nodeProto)
 		{
 			BehaviorNodeData nodeData = new BehaviorNodeData();
 			nodeData.nodeId = nodeProto.nodeId;
@@ -368,7 +372,7 @@ namespace MyEditor
 			foreach (var child in nodeData.children)
 			{
 				nodeProto.children.Add(NodeDataToNodeProto(child));
-                nodeProto.nodeIdList.Add(child.nodeId);
+				nodeProto.nodeIdList.Add(child.nodeId);
 			}
 			return nodeProto;
 		}
@@ -405,7 +409,7 @@ namespace MyEditor
 			copyNode.args_dict = new BehaviorTreeArgsDict();
 			foreach (var item in node.args_dict)
 			{
-                ValueBase valueBase = ValueBase.Clone(item.Value);
+				ValueBase valueBase = ValueBase.Clone(item.Value);
 				copyNode.args_dict.Add(item.Key, valueBase);
 			}
 			List<BehaviorNodeData> list = new List<BehaviorNodeData>();
@@ -415,31 +419,31 @@ namespace MyEditor
 			}
 			foreach (var child in list)
 			{
-			    copyNode.AddChild(CopyNode(child));
+				copyNode.AddChild(CopyNode(child));
 			}
-            copyNode.ResetId();
+			copyNode.ResetId();
 			return copyNode;
 		}
- 
-        public void OpenBehaviorEditor(GameObject go)
-        {
-            if (go == null)
-            {
-                return;
-            }
-            selectNodeName = "";
-            CurTreeGO = go;
-            NewLoadData();
-            BehaviorDesignerWindow.ShowWindow();
-            Game.Scene.GetComponent<EventComponent>().Run(EventIdType.BehaviorTreeOpenEditor);
-        }
-        
-        public string[] GetCanInPutEnvKeyArray(BehaviorNodeData nodeData, NodeFieldDesc desc)
+
+		public void OpenBehaviorEditor(GameObject go)
+		{
+			if (go == null)
+			{
+				return;
+			}
+			selectNodeName = "";
+			CurTreeGO = go;
+			NewLoadData();
+			BehaviorDesignerWindow.ShowWindow();
+			Game.Scene.GetComponent<EventComponent>().Run(EventIdType.BehaviorTreeOpenEditor);
+		}
+
+		public string[] GetCanInPutEnvKeyArray(BehaviorNodeData nodeData, NodeFieldDesc desc)
 		{
 			List<string> list1 = new List<string>();
 			list1.AddRange(GetInstance().GetNodeOutPutEnvKeyList(nodeData, desc));
-            list1.Add(BTEnvKey.None);
-            HashSet<string> hashSet = new HashSet<string>();
+			list1.Add(BTEnvKey.None);
+			HashSet<string> hashSet = new HashSet<string>();
 			foreach (var item in list1)
 			{
 				hashSet.Add(item);
@@ -472,13 +476,13 @@ namespace MyEditor
 
 		public List<string> GetNodeOutPutEnvKeyList(BehaviorNodeData nodeData, NodeFieldDesc desc = null)
 		{
-            NodeProto rootNode = NodeDataToNodeProto(CurTree.Root);
+			NodeProto rootNode = NodeDataToNodeProto(CurTree.Root);
 			NodeProto inputNode = NodeDataToNodeProto(nodeData);
 			List<NodeFieldDesc> descList = _GetNodeOutPutEnvKeyList(rootNode, inputNode, desc);
 			List<string> list = new List<string>();
 			foreach (var item in descList)
 			{
-                string str = item.value?.ToString() ?? "";
+				string str = item.value?.ToString() ?? "";
 				list.Add(str);
 			}
 			return list;
@@ -527,7 +531,7 @@ namespace MyEditor
 				}
 				if (string.IsNullOrEmpty(nodeProto.args_dict[desc.name].enumValue))
 				{
-					nodeProto.args_dict[desc.name].enumValue = BTEnvKey.None.ToString();
+					nodeProto.args_dict[desc.name].enumValue = BTEnvKey.None;
 				}
 				string value = nodeProto.args_dict.GetTreeDictValue(desc.type, desc.name)?.ToString();
 				resultList.Add(value);
@@ -551,10 +555,10 @@ namespace MyEditor
 			List<NodeFieldDesc> list = ExportNodeTypeConfig.GetNodeFieldInOutPutDescList(nodeProto.name, typeof (NodeOutputAttribute));
 			foreach (var desc in list)
 			{
-                if (!nodeProto.args_dict.ContainsKey(desc.name))
-                {
-                    continue;
-                }
+				if (!nodeProto.args_dict.ContainsKey(desc.name))
+				{
+					continue;
+				}
 				string value = nodeProto.args_dict.GetTreeDictValue(desc.type, desc.name)?.ToString();
 				List<string> resultList = inputValueList.FindAll(str => { return str == value; });
 				if (resultList.Count > 0)

+ 58 - 60
Unity/Assets/Editor/BehaviorTreeEditor/BehaviorNodeConfigExtension.cs

@@ -1,69 +1,67 @@
-using MyEditor;
-using System;
+using System;
 using System.Collections.Generic;
 using System.Reflection;
+using MyEditor;
 using UnityEngine;
 
 namespace Model
 {
-    public static class BehaviorNodeConfigExtension
-    {
-        public static BehaviorNodeConfig ProtoToConfig(NodeProto nodeData)
-        {
-            GameObject go = new GameObject();
-            BehaviorNodeConfig nodeConfig = go.AddComponent<BehaviorNodeConfig>();
-            nodeConfig.id = nodeData.nodeId;
-            ((UnityEngine.Object) nodeConfig).name = nodeData.name;
-            go.name = nodeData.name;
-            nodeConfig.describe = nodeData.describe;
-            foreach (var args in nodeData.args_dict)
-            {
-                Type originType = ExportNodeTypeConfig.GetFieldType(nodeData.name, args.Key);
-                try
-                {
-                    string fieldName = args.Key;
-                    object fieldValue = args.Value.GetValueByType(originType);
-                    Type type = BTTypeManager.GetBTType(originType);
+	public static class BehaviorNodeConfigExtension
+	{
+		public static BehaviorNodeConfig ProtoToConfig(NodeProto nodeData)
+		{
+			GameObject go = new GameObject();
+			BehaviorNodeConfig nodeConfig = go.AddComponent<BehaviorNodeConfig>();
+			nodeConfig.id = nodeData.nodeId;
+			((UnityEngine.Object) nodeConfig).name = nodeData.name;
+			go.name = nodeData.name;
+			nodeConfig.describe = nodeData.describe;
+			foreach (var args in nodeData.args_dict)
+			{
+				Type originType = ExportNodeTypeConfig.GetFieldType(nodeData.name, args.Key);
+				try
+				{
+					string fieldName = args.Key;
+					object fieldValue = args.Value.GetValueByType(originType);
+					Type type = BTTypeManager.GetBTType(originType);
 					UnityEngine.Component comp = go.AddComponent(type);
-                    FieldInfo fieldNameInfo = type.GetField("fieldName");
-                    fieldNameInfo.SetValue(comp, fieldName);
-                    FieldInfo fieldValueinfo = type.GetField("fieldValue");
-                    if (BehaviorTreeArgsDict.IsEnumType(originType))
-                    {
-                        fieldValue = fieldValue.ToString();
-                    }
-                    fieldValueinfo.SetValue(comp, fieldValue);
-                }
-                catch (Exception ex)
-                {
-                    throw new GameException($"transform failed,nodeName:{nodeData.name}  fieldName:{args.Key} fieldType:{originType}");
-                }
+					FieldInfo fieldNameInfo = type.GetField("fieldName");
+					fieldNameInfo.SetValue(comp, fieldName);
+					FieldInfo fieldValueinfo = type.GetField("fieldValue");
+					if (BehaviorTreeArgsDict.IsEnumType(originType))
+					{
+						fieldValue = fieldValue.ToString();
+					}
+					fieldValueinfo.SetValue(comp, fieldValue);
+				}
+				catch (Exception ex)
+				{
+					throw new GameException($"transform failed,nodeName:{nodeData.name}  fieldName:{args.Key} fieldType:{originType}");
+				}
+			}
+			foreach (var child in nodeData.children)
+			{
+				BehaviorNodeConfig childConfig = ProtoToConfig(child);
+				childConfig.gameObject.transform.parent = nodeConfig.gameObject.transform;
+			}
+			return nodeConfig;
+		}
 
-            }
-            foreach (var child in nodeData.children)
-            {
-                BehaviorNodeConfig childConfig = ProtoToConfig(child);
-                childConfig.gameObject.transform.parent = nodeConfig.gameObject.transform;
-            }
-            return nodeConfig;
-        }
-
-        public static NodeProto ConfigToNode(BehaviorNodeConfig nodeProto)
-        {
-            NodeProto nodeData = new NodeProto();
-            nodeData.nodeId = nodeProto.id;
-            nodeData.name = ((UnityEngine.Object) nodeProto).name;
-            nodeData.describe = nodeProto.describe;
-            nodeData.args_dict = nodeProto.GetArgsDict();
-            nodeData.children = new List<NodeProto>();
-            foreach (Transform child in nodeProto.gameObject.transform)
-            {
-                BehaviorNodeConfig nodeConfig = child.gameObject.GetComponent<BehaviorNodeConfig>();
-                NodeProto childData = ConfigToNode(nodeConfig);
-                nodeData.children.Add(childData);
-            }
-            return nodeData;
-        }
-
-    }
+		public static NodeProto ConfigToNode(BehaviorNodeConfig nodeProto)
+		{
+			NodeProto nodeData = new NodeProto();
+			nodeData.nodeId = nodeProto.id;
+			nodeData.name = ((UnityEngine.Object) nodeProto).name;
+			nodeData.describe = nodeProto.describe;
+			nodeData.args_dict = nodeProto.GetArgsDict();
+			nodeData.children = new List<NodeProto>();
+			foreach (Transform child in nodeProto.gameObject.transform)
+			{
+				BehaviorNodeConfig nodeConfig = child.gameObject.GetComponent<BehaviorNodeConfig>();
+				NodeProto childData = ConfigToNode(nodeConfig);
+				nodeData.children.Add(childData);
+			}
+			return nodeData;
+		}
+	}
 }

+ 18 - 42
Unity/Assets/Editor/BehaviorTreeEditor/BehaviorNodeData.cs

@@ -1,5 +1,4 @@
-using System;
-using System.Collections.Generic;
+using System.Collections.Generic;
 using Model;
 using UnityEngine;
 
@@ -13,7 +12,7 @@ namespace MyEditor
 		Error,
 		Normal
 	}
- 
+
 	public class BehaviorNodeData
 	{
 		public int nodeId;
@@ -21,38 +20,25 @@ namespace MyEditor
 		public string name;
 
 		public string describe = "";
-  
+
 		public List<BehaviorNodeData> children = new List<BehaviorNodeData>();
 
 		public BehaviorTreeArgsDict args_dict = new BehaviorTreeArgsDict();
-        /// <summary>
-        ///  
-        /// </summary>
-		public string error = "";
 
-		private ClientNodeTypeProto mProto;
-
-		private BehaviorNodeData mParent;
+		/// <summary>
+		///  
+		/// </summary>
+		public string error = "";
 
 		private string mClassify = "";
 
 		public NodeDesigner NodeDesigner { get; set; }
-		
+
 		public Vector2 Pos;
 		public DebugState NodeDeubgState { get; set; }
 		public string time;
 
-		public ClientNodeTypeProto Proto
-		{
-			get
-			{
-				return mProto;
-			}
-			set
-			{
-				mProto = value;
-			}
-		}
+		public ClientNodeTypeProto Proto { get; set; }
 
 		public List<BehaviorNodeData> Children
 		{
@@ -62,17 +48,7 @@ namespace MyEditor
 			}
 		}
 
-		public BehaviorNodeData Parent
-		{
-			get
-			{
-				return mParent;
-			}
-			set
-			{
-				mParent = value;
-			}
-		}
+		public BehaviorNodeData Parent { get; set; }
 
 		public string Classify
 		{
@@ -89,15 +65,15 @@ namespace MyEditor
 		public BehaviorNodeData(string proto_name)
 		{
 			name = proto_name;
-			mProto = BehaviorManager.GetInstance().GetNodeTypeProto(proto_name);
-			if (mProto == null)
+			this.Proto = BehaviorManager.GetInstance().GetNodeTypeProto(proto_name);
+			if (this.Proto == null)
 			{
-				mProto = BehaviorManager.GetInstance().GetNodeTypeProto("Unknow");
+				this.Proto = BehaviorManager.GetInstance().GetNodeTypeProto("Unknow");
 				return;
 			}
-			mClassify = mProto.classify;
+			mClassify = this.Proto.classify;
 
-			foreach (var args_desc in mProto.new_args_desc)
+			foreach (var args_desc in this.Proto.new_args_desc)
 			{
 				args_dict.SetKeyValueComp(args_desc.type, args_desc.name, args_desc.value);
 			}
@@ -117,7 +93,7 @@ namespace MyEditor
 		{
 			index = index == -1? this.Children.Count : index;
 			children.Insert(index, node);
-			node.mParent = this;
+			node.Parent = this;
 		}
 
 		public BehaviorNodeData RemoveChild(BehaviorNodeData node)
@@ -136,12 +112,12 @@ namespace MyEditor
 		{
 			return Parent == null;
 		}
- 
+
 		public bool CanAddChild()
 		{
 			return children.Count < Proto.child_limit;
 		}
-         
+
 		public void ResetId()
 		{
 			this.nodeId = BehaviorManager.GetInstance().AutoNodeId();

+ 15 - 16
Unity/Assets/Editor/BehaviorTreeEditor/BehaviorTreeConfigEditor.cs

@@ -1,23 +1,22 @@
-using System;
-using Model;
+using Model;
 using UnityEditor;
 using UnityEngine;
 
 namespace MyEditor
 {
-    [CustomEditor(typeof(BehaviorTreeConfig))]
-    public class BehaviorTreeConfigEditor : Editor
-    {
-        public override void OnInspectorGUI()
-        {
-            base.OnInspectorGUI();
-            BehaviorTreeConfig config = target as BehaviorTreeConfig;
+	[CustomEditor(typeof (BehaviorTreeConfig))]
+	public class BehaviorTreeConfigEditor: Editor
+	{
+		public override void OnInspectorGUI()
+		{
+			base.OnInspectorGUI();
+			BehaviorTreeConfig config = target as BehaviorTreeConfig;
 
 			if (GUILayout.Button("打开行为树"))
-            {
-                BehaviorManager.GetInstance().OpenBehaviorEditor(config.gameObject);
-            }
-            EditorUtility.SetDirty(config);
-        }
-    }
-}
+			{
+				BehaviorManager.GetInstance().OpenBehaviorEditor(config.gameObject);
+			}
+			EditorUtility.SetDirty(config);
+		}
+	}
+}

+ 49 - 51
Unity/Assets/Editor/BehaviorTreeEditor/BehaviorTreeConfigExtension.cs

@@ -1,58 +1,56 @@
-using MyEditor;
-using System;
-using System.Collections.Generic;
+using System;
 using System.Reflection;
+using MyEditor;
 using UnityEngine;
 
 namespace Model
 {
-    public static class  BehaviorTreeConfigExtension
-    {
-       
-        public static BehaviorNodeConfig AddRootNode(this BehaviorTreeConfig treeConfig, string rootName)
-        {
-            BehaviorNodeConfig go = treeConfig.CreateNodeConfig(rootName);
-            treeConfig.RootNodeConfig = go.GetComponent<BehaviorNodeConfig>();
-            treeConfig.RootNodeConfig.id = BehaviorManager.NodeIdStartIndex;
-            go.gameObject.name = rootName;
-            return go;
-        }
- 
-        public static BehaviorNodeConfig AddChild(this BehaviorTreeConfig treeConfig, BehaviorNodeConfig parent, string name)
-        {
-            BehaviorNodeConfig child = treeConfig.CreateNodeConfig(name);
-            AddChild(treeConfig, parent, child);
-            return child;
-        }
- 
-        public static BehaviorNodeConfig AddChild(this BehaviorTreeConfig treeConfig, BehaviorNodeConfig parent, BehaviorNodeConfig child)
-        {
-            child.transform.parent = parent.transform;
-            child.transform.SetAsLastSibling();
-            child.GetComponent<BehaviorNodeConfig>().id = treeConfig.RootNodeId + treeConfig.AutoId;
-            return child.GetComponent<BehaviorNodeConfig>();
-        }
-        private static BehaviorNodeConfig CreateNodeConfig(this BehaviorTreeConfig treeConfig, string name)
-        {
-            ClientNodeTypeProto proto = ExportNodeTypeConfig.GetNodeTypeProtoFromDll(name);
-            GameObject go = new GameObject();
-            go.name = name;
-            go.transform.parent = treeConfig.gameObject.transform;
-            BehaviorNodeConfig node = go.AddComponent<BehaviorNodeConfig>();
-            node.name = name;
-            node.describe = proto.describe;
+	public static class BehaviorTreeConfigExtension
+	{
+		public static BehaviorNodeConfig AddRootNode(this BehaviorTreeConfig treeConfig, string rootName)
+		{
+			BehaviorNodeConfig go = treeConfig.CreateNodeConfig(rootName);
+			treeConfig.RootNodeConfig = go.GetComponent<BehaviorNodeConfig>();
+			treeConfig.RootNodeConfig.id = BehaviorManager.NodeIdStartIndex;
+			go.gameObject.name = rootName;
+			return go;
+		}
 
-            foreach (var args in proto.new_args_desc)
-            {
-                Type type = BTTypeManager.GetBTType(args.type);
+		public static BehaviorNodeConfig AddChild(this BehaviorTreeConfig treeConfig, BehaviorNodeConfig parent, string name)
+		{
+			BehaviorNodeConfig child = treeConfig.CreateNodeConfig(name);
+			AddChild(treeConfig, parent, child);
+			return child;
+		}
+
+		public static BehaviorNodeConfig AddChild(this BehaviorTreeConfig treeConfig, BehaviorNodeConfig parent, BehaviorNodeConfig child)
+		{
+			child.transform.parent = parent.transform;
+			child.transform.SetAsLastSibling();
+			child.GetComponent<BehaviorNodeConfig>().id = treeConfig.RootNodeId + treeConfig.AutoId;
+			return child.GetComponent<BehaviorNodeConfig>();
+		}
+
+		private static BehaviorNodeConfig CreateNodeConfig(this BehaviorTreeConfig treeConfig, string name)
+		{
+			ClientNodeTypeProto proto = ExportNodeTypeConfig.GetNodeTypeProtoFromDll(name);
+			GameObject go = new GameObject();
+			go.name = name;
+			go.transform.parent = treeConfig.gameObject.transform;
+			BehaviorNodeConfig node = go.AddComponent<BehaviorNodeConfig>();
+			node.name = name;
+			node.describe = proto.describe;
+
+			foreach (var args in proto.new_args_desc)
+			{
+				Type type = BTTypeManager.GetBTType(args.type);
 				UnityEngine.Component comp = go.AddComponent(type);
-                FieldInfo info = type.GetField("fieldName");
-                info.SetValue(comp, args.name);
-                FieldInfo info1 = type.GetField("fieldValue");
-                info1.SetValue(comp, args.value);
-            }
-            return node;
-        }
-  
-    }
-}
+				FieldInfo info = type.GetField("fieldName");
+				info.SetValue(comp, args.name);
+				FieldInfo info1 = type.GetField("fieldValue");
+				info1.SetValue(comp, args.value);
+			}
+			return node;
+		}
+	}
+}

+ 1 - 1
Unity/Assets/Editor/BehaviorTreeEditor/BehaviorTreeData.cs

@@ -18,7 +18,7 @@ namespace MyEditor
 		{
 		}
 
-		public BehaviorTreeData(long id) : base(id, EntityType.Config)
+		public BehaviorTreeData(long id): base(id, EntityType.Config)
 		{
 		}
 

+ 2 - 6
Unity/Assets/Editor/BehaviorTreeEditor/BehaviorTreeMenu.cs

@@ -1,8 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Text;
+using System.IO;
 using UnityEditor;
 using UnityEngine;
 
@@ -23,4 +19,4 @@ namespace MyEditor
 			BehaviorTreeOperateUtility.CreateNewTree($"{folderPath}", "Root");
 		}
 	}
-}
+}

+ 158 - 154
Unity/Assets/Editor/BehaviorTreeEditor/BehaviorTreeNodeClassPopup.cs

@@ -1,160 +1,164 @@
-using Model;
-using System;
+using System;
 using System.Collections.Generic;
+using Model;
 using UnityEditor;
 using UnityEngine;
 
 namespace MyEditor
 {
-    public class BehaviorTreeNodeClassPopup
-    {
-        private string mSearchNode = "";
-        private Vector2 mTreeScrollPos = Vector2.zero;
-        private int mNodeCount;
-        private float mWidth = 400f;
-
-        public GraphDesigner GraphDesigner;
-        private SubWinType mSubWinType;
-        public Rect windowRect = new Rect();//子窗口的大小和位置
-        string[] mEnumNodeTypeArr;
-        Rect toolbarRect = new Rect(0f, 0f, 0, 0);
-        private int mEnumNodeTypeSelection;
-        public string DrawSearchList()
-        {
-            List<string> targetList = new List<string>();
-            if (mSubWinType == SubWinType.CreateNode)
-            {
-                targetList = GraphDesigner.GetCanCreateList();
-            }
-            else if (mSubWinType == SubWinType.ReplaceNode)
-            {
-                targetList = GraphDesigner.GetCanRepalceList();
-            }
-
-            List<string> nodeNameList = Filter(targetList, mSearchNode);
-
-            GUILayout.BeginHorizontal();
-            GUI.SetNextControlName("Search");
-            this.mSearchNode = GUILayout.TextField(this.mSearchNode, GUI.skin.FindStyle("ToolbarSeachTextField"));
-            GUI.FocusControl("Search");
-            GUILayout.EndHorizontal();
-            //
-            toolbarRect = new Rect(0f, 15f + 20, mWidth, 25f);
-            Rect boxRect = new Rect(0f, toolbarRect.height, this.mWidth, (Screen.height - toolbarRect.height) - 21f + 10);
-            GUILayout.BeginArea(toolbarRect, EditorStyles.toolbar);
-            GUILayout.BeginHorizontal();
-
-            GUILayout.Label("Filter");
-            Array strArr = Enum.GetValues(typeof(NodeClassifyType));
-            List<string> strList = new List<string>();
-            strList.Add("All");
-            foreach (var str in strArr)
-            {
-                strList.Add(str.ToString());
-            }
-            mEnumNodeTypeArr = strList.ToArray();
-            mEnumNodeTypeSelection = EditorGUILayout.Popup(mEnumNodeTypeSelection, mEnumNodeTypeArr);
-            if (GUILayout.Button("Clear"))
-            {
-                ClearNodes();
-            }
-            GUILayout.EndHorizontal();
-            GUILayout.EndArea();
-            //
-
-
-            GUILayout.BeginArea(new Rect(0, 0, windowRect.width, windowRect.height));
-            float topSpace = 60;
-            this.mTreeScrollPos = GUI.BeginScrollView(new Rect(0f, topSpace, windowRect.width, windowRect.height - topSpace), this.mTreeScrollPos,
-                    new Rect(0f, 0f, windowRect.width - 20f, nodeNameList.Count * 19), false, true);
-
-            foreach (var name in nodeNameList)
-            {
-                ClientNodeTypeProto proto = ExportNodeTypeConfig.GetNodeTypeProtoFromDll(name);
-                if (GUILayout.Button(name +$"({proto.describe})", GetButtonStyle()))
-                {
-                    if (SubWinType.CreateNode == mSubWinType)
-                    {
-                        GraphDesigner.onCreateNode(name, Vector2.zero);
-                    }
-                    else if (SubWinType.ReplaceNode == mSubWinType)
-                    {
-                        GraphDesigner.onChangeNodeType(name, Vector2.zero);
-                    }
-                    BehaviorDesignerWindow.Instance.CloseSubWin();
-                }
-            }
-
-            GUI.EndScrollView();
-            GUILayout.EndArea();
-
-            return "";
-        }
-        private void ClearNodes()
-        {
-            mEnumNodeTypeSelection = 0;
-            mSearchNode = "";
-        }
-        public List<string> Filter(List<string> list, string text)
-        {
-            List<string> result1 = new List<string>();
-            string selectType;
-            if (mEnumNodeTypeSelection == 0)
-            {
-                selectType = "All";
-                result1 = list;
-            }
-            else
-            {
-                selectType = Enum.GetName(typeof(NodeClassifyType), mEnumNodeTypeSelection - 1);
-                foreach (var name in list)
-                {
-                    ClientNodeTypeProto proto = ExportNodeTypeConfig.GetNodeTypeProtoFromDll(name);
-                    if (selectType == proto.classify)
-                    {
-                        result1.Add(name);
-                    }
-                }
-            }
-            
-            if (string.IsNullOrEmpty(text))
-            {
-                return result1;
-            }
-
-            List<string> result2 = new List<string>();
-            foreach (var name in result1)
-            {
-                ClientNodeTypeProto proto = ExportNodeTypeConfig.GetNodeTypeProtoFromDll(name);
-                if (name.ToUpper().Contains(text.ToUpper()) || proto.describe.ToUpper().Contains(text.ToUpper()))
-                {
-                    result2.Add(name);
-                }
-            }
-            return result2;
-        }
-        private Color textColor = new Color(200f / 255f, 200f / 255f, 200f / 255f);
-        private Color textHighLightColor = new Color(200f / 255f, 200f / 255f, 0);
-        public GUIStyle GetButtonStyle()
-        {
-            GUIStyle style = new GUIStyle();
-            style.fontSize = 15;
-            style.alignment = TextAnchor.MiddleLeft;
-            GUIStyleState onHoverStyleState = new GUIStyleState();
-            onHoverStyleState.textColor = textHighLightColor;
-            onHoverStyleState.background = BehaviorDesignerUtility.GetTexture("blue");
-            style.hover = onHoverStyleState;
-
-            GUIStyleState onNormalStyleState = new GUIStyleState();
-            onNormalStyleState.textColor = textColor;
-            style.normal = onNormalStyleState;
-            return style;
-        }
-
-        public void Show(Rect rect, SubWinType subWinType)
-        {
-            windowRect = rect;
-            mSubWinType = subWinType;
-        }
-    }
-}
+	public class BehaviorTreeNodeClassPopup
+	{
+		private string mSearchNode = "";
+		private Vector2 mTreeScrollPos = Vector2.zero;
+		private int mNodeCount;
+		private readonly float mWidth = 400f;
+
+		public GraphDesigner GraphDesigner;
+		private SubWinType mSubWinType;
+		public Rect windowRect; //子窗口的大小和位置
+		string[] mEnumNodeTypeArr;
+		Rect toolbarRect = new Rect(0f, 0f, 0, 0);
+		private int mEnumNodeTypeSelection;
+
+		public string DrawSearchList()
+		{
+			List<string> targetList = new List<string>();
+			if (mSubWinType == SubWinType.CreateNode)
+			{
+				targetList = GraphDesigner.GetCanCreateList();
+			}
+			else if (mSubWinType == SubWinType.ReplaceNode)
+			{
+				targetList = GraphDesigner.GetCanRepalceList();
+			}
+
+			List<string> nodeNameList = Filter(targetList, mSearchNode);
+
+			GUILayout.BeginHorizontal();
+			GUI.SetNextControlName("Search");
+			this.mSearchNode = GUILayout.TextField(this.mSearchNode, GUI.skin.FindStyle("ToolbarSeachTextField"));
+			GUI.FocusControl("Search");
+			GUILayout.EndHorizontal();
+			//
+			toolbarRect = new Rect(0f, 15f + 20, mWidth, 25f);
+			Rect boxRect = new Rect(0f, toolbarRect.height, this.mWidth, (Screen.height - toolbarRect.height) - 21f + 10);
+			GUILayout.BeginArea(toolbarRect, EditorStyles.toolbar);
+			GUILayout.BeginHorizontal();
+
+			GUILayout.Label("Filter");
+			Array strArr = Enum.GetValues(typeof (NodeClassifyType));
+			List<string> strList = new List<string>();
+			strList.Add("All");
+			foreach (var str in strArr)
+			{
+				strList.Add(str.ToString());
+			}
+			mEnumNodeTypeArr = strList.ToArray();
+			mEnumNodeTypeSelection = EditorGUILayout.Popup(mEnumNodeTypeSelection, mEnumNodeTypeArr);
+			if (GUILayout.Button("Clear"))
+			{
+				ClearNodes();
+			}
+			GUILayout.EndHorizontal();
+			GUILayout.EndArea();
+			//
+
+			GUILayout.BeginArea(new Rect(0, 0, windowRect.width, windowRect.height));
+			float topSpace = 60;
+			this.mTreeScrollPos = GUI.BeginScrollView(new Rect(0f, topSpace, windowRect.width, windowRect.height - topSpace), this.mTreeScrollPos,
+					new Rect(0f, 0f, windowRect.width - 20f, nodeNameList.Count * 19), false, true);
+
+			foreach (var name in nodeNameList)
+			{
+				ClientNodeTypeProto proto = ExportNodeTypeConfig.GetNodeTypeProtoFromDll(name);
+				if (GUILayout.Button(name + $"({proto.describe})", GetButtonStyle()))
+				{
+					if (SubWinType.CreateNode == mSubWinType)
+					{
+						GraphDesigner.onCreateNode(name, Vector2.zero);
+					}
+					else if (SubWinType.ReplaceNode == mSubWinType)
+					{
+						GraphDesigner.onChangeNodeType(name, Vector2.zero);
+					}
+					BehaviorDesignerWindow.Instance.CloseSubWin();
+				}
+			}
+
+			GUI.EndScrollView();
+			GUILayout.EndArea();
+
+			return "";
+		}
+
+		private void ClearNodes()
+		{
+			mEnumNodeTypeSelection = 0;
+			mSearchNode = "";
+		}
+
+		public List<string> Filter(List<string> list, string text)
+		{
+			List<string> result1 = new List<string>();
+			string selectType;
+			if (mEnumNodeTypeSelection == 0)
+			{
+				selectType = "All";
+				result1 = list;
+			}
+			else
+			{
+				selectType = Enum.GetName(typeof (NodeClassifyType), mEnumNodeTypeSelection - 1);
+				foreach (var name in list)
+				{
+					ClientNodeTypeProto proto = ExportNodeTypeConfig.GetNodeTypeProtoFromDll(name);
+					if (selectType == proto.classify)
+					{
+						result1.Add(name);
+					}
+				}
+			}
+
+			if (string.IsNullOrEmpty(text))
+			{
+				return result1;
+			}
+
+			List<string> result2 = new List<string>();
+			foreach (var name in result1)
+			{
+				ClientNodeTypeProto proto = ExportNodeTypeConfig.GetNodeTypeProtoFromDll(name);
+				if (name.ToUpper().Contains(text.ToUpper()) || proto.describe.ToUpper().Contains(text.ToUpper()))
+				{
+					result2.Add(name);
+				}
+			}
+			return result2;
+		}
+
+		private readonly Color textColor = new Color(200f / 255f, 200f / 255f, 200f / 255f);
+		private readonly Color textHighLightColor = new Color(200f / 255f, 200f / 255f, 0);
+
+		public GUIStyle GetButtonStyle()
+		{
+			GUIStyle style = new GUIStyle();
+			style.fontSize = 15;
+			style.alignment = TextAnchor.MiddleLeft;
+			GUIStyleState onHoverStyleState = new GUIStyleState();
+			onHoverStyleState.textColor = textHighLightColor;
+			onHoverStyleState.background = BehaviorDesignerUtility.GetTexture("blue");
+			style.hover = onHoverStyleState;
+
+			GUIStyleState onNormalStyleState = new GUIStyleState();
+			onNormalStyleState.textColor = textColor;
+			style.normal = onNormalStyleState;
+			return style;
+		}
+
+		public void Show(Rect rect, SubWinType subWinType)
+		{
+			windowRect = rect;
+			mSubWinType = subWinType;
+		}
+	}
+}

+ 156 - 159
Unity/Assets/Editor/BehaviorTreeEditor/BehaviorTreeOperateUtility.cs

@@ -5,169 +5,166 @@ using Base;
 using Model;
 using UnityEditor;
 using UnityEngine;
+using Object = UnityEngine.Object;
 
 namespace MyEditor
 {
-    public class BehaviourTreeNodeProxy<T> where T : Node
-    {
-        public T Node;
-        public NodeProto Proto;
-
-        public BehaviourTreeNodeProxy(NodeProto p)
-        {
-            Node = (T)Activator.CreateInstance(typeof(T), p);
-            Proto = p;
-            UpdateData();
-        }
-
-        public void SetDescribe(string desc)
-        {
-            Proto.describe = desc;
-        }
-
-        public void Apply()
-        {
-            FieldInfo[] mems = Node.GetType().GetFields();
-            foreach (FieldInfo mem in mems)
-            {
-                Proto.args_dict.SetKeyValueComp(mem.FieldType, mem.Name, mem.GetValue(Node));
-            }
-        }
-
-        public NodeProto GetNodeProtoCopy()
-        {
-            return BehaviorTreeOperateUtility.NodeProtoParamClone(Proto);
-        }
-
-        public void UpdateData()
-        {
-            foreach (var argsItem in Proto.args_dict)
-            {
-                FieldInfo fieldInfo = typeof(T).GetField(argsItem.Key, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
-                fieldInfo.SetValue(Node, argsItem.Value.GetValueByType(fieldInfo.FieldType));
-            }
-        }
-    }
-
-    public static class BehaviorTreeOperateUtility
-    {
-
-        /// <summary>
-        /// 克隆Node Proto的参数队列
-        /// </summary>
-        /// <param name="p"></param>
-        /// <returns></returns>
-        public static NodeProto NodeProtoParamClone(NodeProto p)
-        {
-            NodeProto newP = new NodeProto();
-            foreach (var dict in p.args_dict)
-            {
-                string key = dict.Key;
-                ValueBase value = ValueBase.Clone(dict.Value);
-                newP.args_dict.Add(key, value);
-            }
-            return newP;
-        }
-
-        public static GameObject CreateTreeWithType<T>(string path, string desc = "默认行为树")
-        {
-            desc = desc.Replace("BT_", "");
-            return CreateTree(path, typeof(T).Name, desc);
-        }
-
-        public static GameObject CreateTree(string path,string rootNodeName, string desc = "默认行为树")
-        {
-            GameObject prefab = null;
-            try
-            {
-
-                GameObject go = new GameObject();
-                go.name = desc;
-                prefab = PrefabUtility.CreatePrefab($"{path}/BT_{desc}.prefab", go, ReplacePrefabOptions.ReplaceNameBased);
-                BehaviorTreeConfig config = prefab.AddComponent<BehaviorTreeConfig>();
-                config.AddRootNode(rootNodeName);
-                EditorUtility.SetDirty(config);
-                EditorUtility.SetDirty(prefab);
-                UnityEngine.Object.DestroyImmediate(go);
-               
-            }
-            catch (Exception ex)
-            {
-                Log.Error($"创建行为树失败|{ex}");
-            }
-            return prefab;
-        }
-
-        public static GameObject CreateNewTree(string path, string rootNodeName, string desc = "默认行为树")
-        {
-            GameObject prefab = null;
-            try
-            {
+	public class BehaviourTreeNodeProxy<T> where T : Node
+	{
+		public T Node;
+		public NodeProto Proto;
+
+		public BehaviourTreeNodeProxy(NodeProto p)
+		{
+			Node = (T) Activator.CreateInstance(typeof (T), p);
+			Proto = p;
+			UpdateData();
+		}
+
+		public void SetDescribe(string desc)
+		{
+			Proto.describe = desc;
+		}
+
+		public void Apply()
+		{
+			FieldInfo[] mems = Node.GetType().GetFields();
+			foreach (FieldInfo mem in mems)
+			{
+				Proto.args_dict.SetKeyValueComp(mem.FieldType, mem.Name, mem.GetValue(Node));
+			}
+		}
+
+		public NodeProto GetNodeProtoCopy()
+		{
+			return BehaviorTreeOperateUtility.NodeProtoParamClone(Proto);
+		}
+
+		public void UpdateData()
+		{
+			foreach (var argsItem in Proto.args_dict)
+			{
+				FieldInfo fieldInfo = typeof (T).GetField(argsItem.Key, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
+				fieldInfo.SetValue(Node, argsItem.Value.GetValueByType(fieldInfo.FieldType));
+			}
+		}
+	}
+
+	public static class BehaviorTreeOperateUtility
+	{
+		/// <summary>
+		/// 克隆Node Proto的参数队列
+		/// </summary>
+		/// <param name="p"></param>
+		/// <returns></returns>
+		public static NodeProto NodeProtoParamClone(NodeProto p)
+		{
+			NodeProto newP = new NodeProto();
+			foreach (var dict in p.args_dict)
+			{
+				string key = dict.Key;
+				ValueBase value = ValueBase.Clone(dict.Value);
+				newP.args_dict.Add(key, value);
+			}
+			return newP;
+		}
+
+		public static GameObject CreateTreeWithType<T>(string path, string desc = "默认行为树")
+		{
+			desc = desc.Replace("BT_", "");
+			return CreateTree(path, typeof (T).Name, desc);
+		}
+
+		public static GameObject CreateTree(string path, string rootNodeName, string desc = "默认行为树")
+		{
+			GameObject prefab = null;
+			try
+			{
+				GameObject go = new GameObject();
+				go.name = desc;
+				prefab = PrefabUtility.CreatePrefab($"{path}/BT_{desc}.prefab", go, ReplacePrefabOptions.ReplaceNameBased);
+				BehaviorTreeConfig config = prefab.AddComponent<BehaviorTreeConfig>();
+				config.AddRootNode(rootNodeName);
+				EditorUtility.SetDirty(config);
+				EditorUtility.SetDirty(prefab);
+				Object.DestroyImmediate(go);
+			}
+			catch (Exception ex)
+			{
+				Log.Error($"创建行为树失败|{ex}");
+			}
+			return prefab;
+		}
+
+		public static GameObject CreateNewTree(string path, string rootNodeName, string desc = "默认行为树")
+		{
+			GameObject prefab = null;
+			try
+			{
 				Game.EntityEventManager.Register("Controller", DllHelper.GetController());
 
 				GameObject go = new GameObject();
-                BehaviorTreeConfig newConfig = go.AddComponent<BehaviorTreeConfig>();
-                BehaviorNodeConfig root = newConfig.AddRootNode(rootNodeName);
-
-                prefab = PrefabUtility.CreatePrefab($"{path}/BT_{desc}.prefab", go, ReplacePrefabOptions.ReplaceNameBased);
-                EditorUtility.SetDirty(newConfig);
-                EditorUtility.SetDirty(prefab);
-                UnityEngine.Object.DestroyImmediate(go);
-
-            }
-            catch (Exception ex)
-            {
-                Log.Error($"创建行为树失败|{ex}");
-            }
-            return prefab;
-        }
-        private static void SortBehaviorTree(BehaviorNodeConfig nodeConfig)
-        {
-
-        }
-
-        public static BehaviourTreeNodeProxy<T> AddNodeToLast<T>(BehaviorTreeConfig tree) where T : Node
-        {
-            BehaviorNodeConfig parent = tree.RootNodeConfig;
-            string name = typeof(T).Name;
-            BehaviorNodeConfig p = tree.AddChild(parent, name);
-            BehaviourTreeNodeProxy<T> proxy = new BehaviourTreeNodeProxy<T>(p.ToNodeProto());
-            return proxy;
-        }
-
-        public static BehaviourTreeNodeProxy<T> CreateNode<T>() where T : Node
-        {
-            NodeProto p = new NodeProto();
-            p.name = typeof(T).Name;
-            BehaviourTreeNodeProxy<T> proxy = new BehaviourTreeNodeProxy<T>(p);
-            return proxy;
-        }
-
-        /// <summary>
-        /// 从父节点获取某个指定名字的子节点
-        /// </summary>
-        /// <param name="list"></param>
-        /// <param name="name"></param>
-        /// <param name="p"></param>
-        /// <returns></returns>
-        public static bool TryGetActionChild(List<NodeProto> list, string name, out NodeProto p)
-        {
-            foreach (NodeProto proto in list)
-            {
-                if (proto.describe == name)
-                {
-                    p = proto;
-                    return true;
-                }
-            }
-            p = null;
-            return false;
-        }
-
-        public static BTEditorTree Open(GameObject go)
-        {
-            BehaviorTreeConfig config = go.GetComponent<BehaviorTreeConfig>();
-            return new BTEditorTree(config);
-        }
-    }
+				BehaviorTreeConfig newConfig = go.AddComponent<BehaviorTreeConfig>();
+				BehaviorNodeConfig root = newConfig.AddRootNode(rootNodeName);
+
+				prefab = PrefabUtility.CreatePrefab($"{path}/BT_{desc}.prefab", go, ReplacePrefabOptions.ReplaceNameBased);
+				EditorUtility.SetDirty(newConfig);
+				EditorUtility.SetDirty(prefab);
+				Object.DestroyImmediate(go);
+			}
+			catch (Exception ex)
+			{
+				Log.Error($"创建行为树失败|{ex}");
+			}
+			return prefab;
+		}
+
+		private static void SortBehaviorTree(BehaviorNodeConfig nodeConfig)
+		{
+		}
+
+		public static BehaviourTreeNodeProxy<T> AddNodeToLast<T>(BehaviorTreeConfig tree) where T : Node
+		{
+			BehaviorNodeConfig parent = tree.RootNodeConfig;
+			string name = typeof (T).Name;
+			BehaviorNodeConfig p = tree.AddChild(parent, name);
+			BehaviourTreeNodeProxy<T> proxy = new BehaviourTreeNodeProxy<T>(p.ToNodeProto());
+			return proxy;
+		}
+
+		public static BehaviourTreeNodeProxy<T> CreateNode<T>() where T : Node
+		{
+			NodeProto p = new NodeProto();
+			p.name = typeof (T).Name;
+			BehaviourTreeNodeProxy<T> proxy = new BehaviourTreeNodeProxy<T>(p);
+			return proxy;
+		}
+
+		/// <summary>
+		/// 从父节点获取某个指定名字的子节点
+		/// </summary>
+		/// <param name="list"></param>
+		/// <param name="name"></param>
+		/// <param name="p"></param>
+		/// <returns></returns>
+		public static bool TryGetActionChild(List<NodeProto> list, string name, out NodeProto p)
+		{
+			foreach (NodeProto proto in list)
+			{
+				if (proto.describe == name)
+				{
+					p = proto;
+					return true;
+				}
+			}
+			p = null;
+			return false;
+		}
+
+		public static BTEditorTree Open(GameObject go)
+		{
+			BehaviorTreeConfig config = go.GetComponent<BehaviorTreeConfig>();
+			return new BTEditorTree(config);
+		}
+	}
 }

+ 25 - 28
Unity/Assets/Editor/BehaviorTreeEditor/BehaviorTreeToolWindow.cs

@@ -4,33 +4,30 @@ using UnityEngine;
 
 namespace MyEditor
 {
-    public class BehaviorTreeToolWindow : EditorWindow
-    {
-        
-        public static BehaviorTreeToolWindow Instance
-        {
-            get
-            {
-                return GetWindow<BehaviorTreeToolWindow>(false, "工具箱");
-            }
-        }
+	public class BehaviorTreeToolWindow: EditorWindow
+	{
+		public static BehaviorTreeToolWindow Instance
+		{
+			get
+			{
+				return GetWindow<BehaviorTreeToolWindow>(false, "工具箱");
+			}
+		}
 
-        public static void ShowWindow()
-        {
-            Type[] a = new Type[1];
-            a[0] = typeof(BehaviorDesignerWindow);
-            //BehaviorDesignerWindow target = GetWindow<BehaviorDesignerWindow>(false, "行为树编辑器",a);
-            BehaviorTreeToolWindow target = GetWindow<BehaviorTreeToolWindow>("工具箱", true, a);
-            target.ShowTab();
-            //target.maximized = false;
-            // target.Show();
-            Rect rect = BehaviorDesignerWindow.Instance.position;
-            rect.width = 200;
-            target.minSize = rect.size;
-          //  target.position = rect;
-            //target.minSize = new Vector2(600f, 500f);
-             
-
-        }
-    }
+		public static void ShowWindow()
+		{
+			Type[] a = new Type[1];
+			a[0] = typeof (BehaviorDesignerWindow);
+			//BehaviorDesignerWindow target = GetWindow<BehaviorDesignerWindow>(false, "行为树编辑器",a);
+			BehaviorTreeToolWindow target = GetWindow<BehaviorTreeToolWindow>("工具箱", true, a);
+			target.ShowTab();
+			//target.maximized = false;
+			// target.Show();
+			Rect rect = BehaviorDesignerWindow.Instance.position;
+			rect.width = 200;
+			target.minSize = rect.size;
+			//  target.position = rect;
+			//target.minSize = new Vector2(600f, 500f);
+		}
+	}
 }

+ 6 - 6
Unity/Assets/Editor/BehaviorTreeEditor/Event/BehaviorTreeOpenEditorEvent_SelectNode.cs

@@ -8,12 +8,12 @@ namespace MyEditor
 	{
 		public void Run()
 		{
-            NodeDesigner dstNode = BehaviorDesignerWindow.Instance.onCreateTree();
-            if (dstNode == null)
-            {
-                Debug.LogError($"RootNode can not be null");
-                return;
-            }
+			NodeDesigner dstNode = BehaviorDesignerWindow.Instance.onCreateTree();
+			if (dstNode == null)
+			{
+				Debug.LogError($"RootNode can not be null");
+				return;
+			}
 			BehaviorDesignerWindow.Instance.OnSelectNode(dstNode.NodeData, dstNode);
 		}
 	}

+ 9 - 10
Unity/Assets/Editor/BehaviorTreeEditor/Event/BehaviorTreeRightDesignerDragEvent_ModifyRightBorder.cs

@@ -1,15 +1,14 @@
-using System.Collections.Generic;
-using Model;
+using Model;
 using MyEditor;
 
 namespace Controller
 {
-    [Event(EventIdType.BehaviorTreeRightDesignerDrag)]
-    public class BehaviorTreeRightDesignerDragEvent_ModifyRightBorder : IEvent<float>
-    {
-        public void Run(float deltaX)
-        {
-            BehaviorDesignerWindow.Instance.onDraggingRightDesigner(deltaX);
-        }
-    }
+	[Event(EventIdType.BehaviorTreeRightDesignerDrag)]
+	public class BehaviorTreeRightDesignerDragEvent_ModifyRightBorder: IEvent<float>
+	{
+		public void Run(float deltaX)
+		{
+			BehaviorDesignerWindow.Instance.onDraggingRightDesigner(deltaX);
+		}
+	}
 }

+ 13 - 14
Unity/Assets/Editor/BehaviorTreeEditor/ExportNodeTypeConfig.cs

@@ -3,7 +3,6 @@ using System.Collections.Generic;
 using System.Reflection;
 using Base;
 using Model;
-using UnityEditor;
 using UnityEngine;
 using Object = UnityEngine.Object;
 
@@ -44,7 +43,6 @@ namespace MyEditor
 			}
 			return name2NodeProtoDict;
 		}
-		
 
 		public static Assembly GetControllerAssembly()
 		{
@@ -112,7 +110,7 @@ namespace MyEditor
 			List<NodeFieldDesc> filterList = new List<NodeFieldDesc>();
 			foreach (var item in list)
 			{
-				if (item.envKeyType == paramType ||  item.envKeyType.IsSubclassOf(paramType) || paramType.IsAssignableFrom(item.envKeyType))
+				if (item.envKeyType == paramType || item.envKeyType.IsSubclassOf(paramType) || paramType.IsAssignableFrom(item.envKeyType))
 				{
 					filterList.Add(item);
 				}
@@ -160,7 +158,7 @@ namespace MyEditor
 		{
 			if (att.DefaultValue != null)
 			{
-				if ((BehaviorTreeArgsDict.IsEnumType(type) && BTEnvKey.None.ToString() != att.DefaultValue.ToString()) || !BehaviorTreeArgsDict.IsEnumType(type))
+				if ((BehaviorTreeArgsDict.IsEnumType(type) && BTEnvKey.None != att.DefaultValue.ToString()) || !BehaviorTreeArgsDict.IsEnumType(type))
 				{
 					return att.DefaultValue;
 				}
@@ -230,10 +228,10 @@ namespace MyEditor
 			{
 				value = default(Object[]);
 			}
-            else if (BehaviorTreeArgsDict.IsConvertble(type))
-            {
-                value = 1f;
-            }
+			else if (BehaviorTreeArgsDict.IsConvertble(type))
+			{
+				value = 1f;
+			}
 			else
 			{
 				Log.Error($"行为树节点暂时未支持此类型:{type}!");
@@ -252,12 +250,13 @@ namespace MyEditor
 			}
 			return fieldInfo.FieldType;
 		}
-        public static bool NodeHasField(string nodeName, string fieldName)
-        {
-            Type nodeType = GetNodeType(nodeName);
-            FieldInfo fieldInfo = nodeType.GetField(fieldName, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
-            return fieldInfo != null;
-        }
+
+		public static bool NodeHasField(string nodeName, string fieldName)
+		{
+			Type nodeType = GetNodeType(nodeName);
+			FieldInfo fieldInfo = nodeType.GetField(fieldName, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
+			return fieldInfo != null;
+		}
 
 		public static FieldInfo[] GetFieldInfos(string nodeName)
 		{

+ 132 - 129
Unity/Assets/Editor/BehaviorTreeEditor/GraphDesigner.cs

@@ -26,8 +26,8 @@ namespace MyEditor
 
 		private Rect mGraphRect = new Rect(0, 0, 2000, 2000); //绘图区域
 		private float mLeftWidth = 380f;
-         private float mRightWidth = 0;
-        private Vector2 mScrollPosition = Vector2.zero;
+		private float mRightWidth;
+		private Vector2 mScrollPosition = Vector2.zero;
 
 		public void Draw(Rect windowRect)
 		{
@@ -60,7 +60,6 @@ namespace MyEditor
 			HandleEvents();
 			CalcGraphRect();
 		}
-        
 
 		public void DrawNodes()
 		{
@@ -93,26 +92,26 @@ namespace MyEditor
 		private Vector2 mSrcOffset = Vector2.zero;
 		private bool mLock = true;
 		private bool mDragingLeftBorder;
-        private bool mDragingRightBorder;
+		private bool mDragingRightBorder;
 
-        public void HandleEvents()
+		public void HandleEvents()
 		{
 			var e = Event.current;
 			switch (e.type)
 			{
 				case EventType.MouseDown:
-                    GUI.FocusControl("");
+					GUI.FocusControl("");
 					mMousePos = e.mousePosition;
-                    if (!BehaviorDesignerWindow.windowRect.Contains(mMousePos))
-                    {
-                        BehaviorDesignerWindow.Instance.CloseSubWin();
-                    }
-                    if (BehaviorDesignerWindow.windowRect.Contains(mMousePos) && BehaviorDesignerWindow.IsShowSubWin)
-                    {
-                        break;
-                    }
-                    //单击选中
-                    if (e.button == 0)
+					if (!BehaviorDesignerWindow.windowRect.Contains(mMousePos))
+					{
+						BehaviorDesignerWindow.Instance.CloseSubWin();
+					}
+					if (BehaviorDesignerWindow.windowRect.Contains(mMousePos) && BehaviorDesignerWindow.IsShowSubWin)
+					{
+						break;
+					}
+					//单击选中
+					if (e.button == 0)
 					{
 						CheckMouseInNode();
 					}
@@ -137,18 +136,18 @@ namespace MyEditor
 					{
 						mDragingLeftBorder = true;
 					}
-                    if (e.button == 0 && e.mousePosition.x < mLeftWidth + mBorderRect.width && e.mousePosition.x > mLeftWidth + mBorderRect.width - 30)
-                    {
-                        mDragingRightBorder = true;
-                    } 
-                    
-                    break;
+					if (e.button == 0 && e.mousePosition.x < mLeftWidth + mBorderRect.width && e.mousePosition.x > mLeftWidth + mBorderRect.width - 30)
+					{
+						mDragingRightBorder = true;
+					}
+
+					break;
 				case EventType.MouseUp:
-                    if (BehaviorDesignerWindow.windowRect.Contains(mMousePos) && BehaviorDesignerWindow.IsShowSubWin)
-                    {
-                        break;
-                    }
-                    if (e.button == 0 && e.shift)
+					if (BehaviorDesignerWindow.windowRect.Contains(mMousePos) && BehaviorDesignerWindow.IsShowSubWin)
+					{
+						break;
+					}
+					if (e.button == 0 && e.shift)
 					{
 						mSelectedNode.Offset = mSrcOffset;
 						mSelectedNode.Parent.AutoSort();
@@ -160,7 +159,7 @@ namespace MyEditor
 					}
 					mState = State.Normal;
 					mDragingLeftBorder = false;
-                    mDragingRightBorder = false;
+					mDragingRightBorder = false;
 					break;
 				case EventType.MouseDrag:
 					//中键
@@ -197,15 +196,15 @@ namespace MyEditor
 						mLeftWidth += e.delta.x;
 						return;
 					}
-                    if (mDragingRightBorder)
-                    {
-                        mRightWidth -= e.delta.x;
-                        Game.Scene.GetComponent<EventComponent>().Run(EventIdType.BehaviorTreeRightDesignerDrag, e.delta.x);
-                        return;
-                    }
-
-                    //左键
-                    if (e.button == 0 && (e.control || !mLock))
+					if (mDragingRightBorder)
+					{
+						mRightWidth -= e.delta.x;
+						Game.Scene.GetComponent<EventComponent>().Run(EventIdType.BehaviorTreeRightDesignerDrag, e.delta.x);
+						return;
+					}
+
+					//左键
+					if (e.button == 0 && (e.control || !mLock))
 					{
 						if (mSelectedNode != null)
 						{
@@ -322,74 +321,75 @@ namespace MyEditor
 			}
 		}
 
-        public List<string>GetCanRepalceList()
-        {
-            List<string> result = new List<string>();
-            if (mSelectedNode != null)
-            {
-                if (mSelectedNode.NodeData.Proto.classify == NodeClassifyType.Root.ToString() || BehaviorManager.GetInstance().CurTree.Root.nodeId == mSelectedNode.NodeData.nodeId)
-                {
-                    List<ClientNodeTypeProto> list = BehaviorManager.GetInstance().Classify2NodeProtoList[NodeClassifyType.Root.ToString()];
-                    foreach (ClientNodeTypeProto nodeType in list)
-                    {
-                        result.Add(nodeType.name);
-                       // menu.AddItem(new GUIContent(string.Format("{0}/{1}", "替换为", nodeType.name)), false, new GenericMenu.MenuFunction2(this.ChangeNodeType), nodeType.name);
-                    }
-                }
-                else
-                {
-                   // NodeChildLimitType nodeChildLimitType = mSelectedNode.NodeData.IsLeaf() ? NodeChildLimitType.All : NodeChildLimitType.WithChild;
-                    List<ClientNodeTypeProto> canSubtituteList = BehaviorManager.GetInstance().AllNodeProtoList;
-                    canSubtituteList.Sort(CompareShowName);
-                    foreach (ClientNodeTypeProto nodeType in canSubtituteList)
-                    {
-                        if (nodeType.classify == NodeClassifyType.Root.ToString())
-                        {
-                            continue;
-                        }
-                        // menu.AddItem(new GUIContent(string.Format("{0}/{1}", "替换为", nodeType.name)), false, new GenericMenu.MenuFunction2(this.ChangeNodeType), nodeType.name);
-                        if (mSelectedNode.NodeData.Proto.child_limit <= nodeType.child_limit)
-                        {
-                            result.Add(nodeType.name);
-                        }
-                        
-                    }
-                }
-
-            }
-            return result;
-        }
-        public List<string> GetCanCreateList()
-        {
-            List<string> result = new List<string>();
-
-            foreach (KeyValuePair<string, List<ClientNodeTypeProto>> kv in BehaviorManager.GetInstance().Classify2NodeProtoList)
-            {
-                string classify = kv.Key;
-                List<ClientNodeTypeProto> nodeProtoList = kv.Value;
-                nodeProtoList.Sort(CompareShowName);
-                if (classify == NodeClassifyType.Root.ToString())
-                {
-                    continue;
-                }
-                foreach (var node in nodeProtoList)
-                {
-                    if (mSelectedNode != null && mSelectedNode.NodeData.Children.Count < mSelectedNode.NodeData.Proto.child_limit)
-                    {
-                        result.Add(node.name);
-                    }
-                }
-            }
-            return result;
-        }
-        ///菜单相关
-        public void PopMenu()
+		public List<string> GetCanRepalceList()
+		{
+			List<string> result = new List<string>();
+			if (mSelectedNode != null)
+			{
+				if (mSelectedNode.NodeData.Proto.classify == NodeClassifyType.Root.ToString() ||
+				    BehaviorManager.GetInstance().CurTree.Root.nodeId == mSelectedNode.NodeData.nodeId)
+				{
+					List<ClientNodeTypeProto> list = BehaviorManager.GetInstance().Classify2NodeProtoList[NodeClassifyType.Root.ToString()];
+					foreach (ClientNodeTypeProto nodeType in list)
+					{
+						result.Add(nodeType.name);
+						// menu.AddItem(new GUIContent(string.Format("{0}/{1}", "替换为", nodeType.name)), false, new GenericMenu.MenuFunction2(this.ChangeNodeType), nodeType.name);
+					}
+				}
+				else
+				{
+					// NodeChildLimitType nodeChildLimitType = mSelectedNode.NodeData.IsLeaf() ? NodeChildLimitType.All : NodeChildLimitType.WithChild;
+					List<ClientNodeTypeProto> canSubtituteList = BehaviorManager.GetInstance().AllNodeProtoList;
+					canSubtituteList.Sort(CompareShowName);
+					foreach (ClientNodeTypeProto nodeType in canSubtituteList)
+					{
+						if (nodeType.classify == NodeClassifyType.Root.ToString())
+						{
+							continue;
+						}
+						// menu.AddItem(new GUIContent(string.Format("{0}/{1}", "替换为", nodeType.name)), false, new GenericMenu.MenuFunction2(this.ChangeNodeType), nodeType.name);
+						if (mSelectedNode.NodeData.Proto.child_limit <= nodeType.child_limit)
+						{
+							result.Add(nodeType.name);
+						}
+					}
+				}
+			}
+			return result;
+		}
+
+		public List<string> GetCanCreateList()
+		{
+			List<string> result = new List<string>();
+
+			foreach (KeyValuePair<string, List<ClientNodeTypeProto>> kv in BehaviorManager.GetInstance().Classify2NodeProtoList)
+			{
+				string classify = kv.Key;
+				List<ClientNodeTypeProto> nodeProtoList = kv.Value;
+				nodeProtoList.Sort(CompareShowName);
+				if (classify == NodeClassifyType.Root.ToString())
+				{
+					continue;
+				}
+				foreach (var node in nodeProtoList)
+				{
+					if (mSelectedNode != null && mSelectedNode.NodeData.Children.Count < mSelectedNode.NodeData.Proto.child_limit)
+					{
+						result.Add(node.name);
+					}
+				}
+			}
+			return result;
+		}
+
+		///菜单相关
+		public void PopMenu()
 		{
 			var menu = new GenericMenu();
-			
-            menu.AddItem(new GUIContent("创建子节点"), false, this.PopUpCreate);
-            menu.AddItem(new GUIContent("替换当前节点"), false, this.PopUpReplace);
-            string selectNodeName = BehaviorManager.GetInstance().selectNodeName;
+
+			menu.AddItem(new GUIContent("创建子节点"), false, this.PopUpCreate);
+			menu.AddItem(new GUIContent("替换当前节点"), false, this.PopUpReplace);
+			string selectNodeName = BehaviorManager.GetInstance().selectNodeName;
 			string selectNodeType = BehaviorManager.GetInstance().selectNodeType;
 			if (mSelectedNode != null && selectNodeName != "")
 			{
@@ -433,22 +433,25 @@ namespace MyEditor
 				menu.AddDisabledItem(new GUIContent("新建"));
 				menu.AddDisabledItem(new GUIContent("替换"));
 			}
-            menu.AddItem(new GUIContent("自动排序"), false, this.AutoSort);
-            menu.AddItem(new GUIContent("复制"), false, this.CopyNode);
+			menu.AddItem(new GUIContent("自动排序"), false, this.AutoSort);
+			menu.AddItem(new GUIContent("复制"), false, this.CopyNode);
 			menu.AddItem(new GUIContent("剪切"), false, this.CutNode);
 			menu.AddItem(new GUIContent("粘贴"), false, this.PasteNode);
 			menu.AddItem(new GUIContent("删除节点"), false, this.RemoveNode);
-            menu.ShowAsContext();
-		}
-        private void PopUpCreate()
-        {
-            BehaviorDesignerWindow.Instance.ShowSubWin(mMousePos,SubWinType.CreateNode);
-        }
-        private void PopUpReplace()
-        {
-            BehaviorDesignerWindow.Instance.ShowSubWin(mMousePos, SubWinType.ReplaceNode);
-        }
-        private static int CompareShowName(ClientNodeTypeProto clientNodeType1, ClientNodeTypeProto clientNodeType2)
+			menu.ShowAsContext();
+		}
+
+		private void PopUpCreate()
+		{
+			BehaviorDesignerWindow.Instance.ShowSubWin(mMousePos, SubWinType.CreateNode);
+		}
+
+		private void PopUpReplace()
+		{
+			BehaviorDesignerWindow.Instance.ShowSubWin(mMousePos, SubWinType.ReplaceNode);
+		}
+
+		private static int CompareShowName(ClientNodeTypeProto clientNodeType1, ClientNodeTypeProto clientNodeType2)
 		{
 			if (string.IsNullOrEmpty(clientNodeType1.name) || string.IsNullOrEmpty(clientNodeType2.name))
 			{
@@ -506,7 +509,7 @@ namespace MyEditor
 			if (mCopyNode != null && mCopyNode != mSelectedNode)
 			{
 				var data = BehaviorManager.GetInstance().CopyNode(mCopyNode.NodeData);
-                BehaviorManager.GetInstance().ResetTreeId();
+				BehaviorManager.GetInstance().ResetTreeId();
 				var node = CreateNode(data, Vector2.zero);
 				ConnectNode(node, mSelectedNode);
 			}
@@ -542,8 +545,8 @@ namespace MyEditor
 				return;
 			}
 			mDetachedNodes.Remove(mSelectedNode);
-            BehaviorManager.GetInstance().ResetTreeId();
-        }
+			BehaviorManager.GetInstance().ResetTreeId();
+		}
 
 		private void ChangeNodeType()
 		{
@@ -580,8 +583,8 @@ namespace MyEditor
 			{
 				newNode.AddChild(child);
 			}
-            BehaviorManager.GetInstance().ResetTreeId();
-            Game.Scene.GetComponent<EventComponent>().Run(EventIdType.BehaviorTreeAfterChangeNodeType);
+			BehaviorManager.GetInstance().ResetTreeId();
+			Game.Scene.GetComponent<EventComponent>().Run(EventIdType.BehaviorTreeAfterChangeNodeType);
 		}
 
 		public void onChangeNodeType(params object[] list)
@@ -622,22 +625,22 @@ namespace MyEditor
 			{
 				mDetachedNodes.Add(node);
 			}
-            BehaviorManager.GetInstance().ResetTreeId();
-            Game.Scene.GetComponent<EventComponent>().Run(EventIdType.BehaviorTreeCreateNode, node);
+			BehaviorManager.GetInstance().ResetTreeId();
+			Game.Scene.GetComponent<EventComponent>().Run(EventIdType.BehaviorTreeCreateNode, node);
 			return node;
 		}
 
 		/// 事件相关
 		public NodeDesigner onCreateTree(params object[] list)
 		{
-            if (BehaviorManager.GetInstance().CurTree == null)
-            {
-                Log.Error($"CurTree can not be null");
-                return null;
-            }
+			if (BehaviorManager.GetInstance().CurTree == null)
+			{
+				Log.Error($"CurTree can not be null");
+				return null;
+			}
 			RootNode = new NodeDesigner(BehaviorManager.GetInstance().CurTree.Root);
 			CalcGraphRect();
-            return RootNode;
+			return RootNode;
 		}
 
 		public void onSelectNode(params object[] list)

+ 266 - 260
Unity/Assets/Editor/BehaviorTreeEditor/NodeExtension.cs

@@ -1,284 +1,290 @@
-using MyEditor;
-using System;
+using System;
 using System.Collections.Generic;
 using System.Reflection;
+using MyEditor;
 using UnityEditor;
 using UnityEngine;
 
 namespace Model
 {
-    public class BTEditorTree
-    {
-        private int _id = BehaviorManager.NodeIdStartIndex;
-        private Node _root;
-        private BehaviorTreeConfig _config;
-        public BTEditorTree(BehaviorTreeConfig config)
-        {
-            Type rootType = Game.EntityEventManager.GetAssembly("Controller").GetType($"Controller.{config.RootNodeProto.name}");
-            Node root = (Node)Activator.CreateInstance(rootType, config.RootNodeProto);
-            root.Id = BehaviorManager.NodeIdStartIndex;
-            Queue<NodeProto> protoStack = new Queue<NodeProto>();
-            Queue<Node> nodeStack = new Queue<Node>();
-            protoStack.Enqueue(config.RootNodeProto);
-            nodeStack.Enqueue(root);
-            while (protoStack.Count > 0)
-            {
-                NodeProto p = protoStack.Dequeue();
-                Node node = nodeStack.Dequeue();
+	public class BTEditorTree
+	{
+		private int _id = BehaviorManager.NodeIdStartIndex;
+		private readonly Node _root;
 
-                foreach (var argsItem in p.args_dict)
-                {
-                    FieldInfo fieldInfo = node.GetType().GetField(argsItem.Key, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
-                    fieldInfo.SetValue(node, argsItem.Value.GetValueByType(fieldInfo.FieldType));
-                }
-                foreach (NodeProto child in p.Children)
-                {
-                    Type t = Game.EntityEventManager.GetAssembly("Controller").GetType($"Controller.{child.name}");
-                    Node childNode = (Node)Activator.CreateInstance(t, child);
-                    AddChild(childNode, node);
-                    protoStack.Enqueue(child);
-                    nodeStack.Enqueue(childNode);
-                }
-            }
-            _config = config;
-            _root = root;
-        }
+		public BTEditorTree(BehaviorTreeConfig config)
+		{
+			Type rootType = Game.EntityEventManager.GetAssembly("Controller").GetType($"Controller.{config.RootNodeProto.name}");
+			Node root = (Node) Activator.CreateInstance(rootType, config.RootNodeProto);
+			root.Id = BehaviorManager.NodeIdStartIndex;
+			Queue<NodeProto> protoStack = new Queue<NodeProto>();
+			Queue<Node> nodeStack = new Queue<Node>();
+			protoStack.Enqueue(config.RootNodeProto);
+			nodeStack.Enqueue(root);
+			while (protoStack.Count > 0)
+			{
+				NodeProto p = protoStack.Dequeue();
+				Node node = nodeStack.Dequeue();
 
-        public T CreateNode<T>(Node parent) where T : Node
-        {
-            T node = (T)Activator.CreateInstance(typeof(T), new NodeProto());
-            AddChild(node, parent);
-            return node;
-        }
+				foreach (var argsItem in p.args_dict)
+				{
+					FieldInfo fieldInfo = node.GetType().GetField(argsItem.Key, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
+					fieldInfo.SetValue(node, argsItem.Value.GetValueByType(fieldInfo.FieldType));
+				}
+				foreach (NodeProto child in p.Children)
+				{
+					Type t = Game.EntityEventManager.GetAssembly("Controller").GetType($"Controller.{child.name}");
+					Node childNode = (Node) Activator.CreateInstance(t, child);
+					AddChild(childNode, node);
+					protoStack.Enqueue(child);
+					nodeStack.Enqueue(childNode);
+				}
+			}
+			this.BTConfig = config;
+			_root = root;
+		}
 
-        public string Description
-        {
-            get { return _root.Description; }
-            set { _root.Description = value; }
-        }
+		public T CreateNode<T>(Node parent) where T : Node
+		{
+			T node = (T) Activator.CreateInstance(typeof (T), new NodeProto());
+			AddChild(node, parent);
+			return node;
+		}
 
-        public BehaviorTreeConfig BTConfig
-        {
-            get { return _config; }
-        }
+		public string Description
+		{
+			get
+			{
+				return _root.Description;
+			}
+			set
+			{
+				_root.Description = value;
+			}
+		}
 
-        public T GetRoot<T>() where T : Node
-        {
-            return _root as T;
-        }
+		public BehaviorTreeConfig BTConfig { get; }
 
-        private BTEditorTree(Node root, BehaviorTreeConfig config)
-        {
-            _root = root;
-            _root.Id = BehaviorManager.NodeIdStartIndex;
-            _config = config;
-        }
-       
-        public static BTEditorTree CreateTree<T>(GameObject source)
-        {
-            BehaviorTreeConfig sourceTree = source.GetComponent<BehaviorTreeConfig>();
-            if (sourceTree == null)
-            {
-                sourceTree = source.AddComponent<BehaviorTreeConfig>();
-            }
-            Node root = (Node)Activator.CreateInstance(typeof(T), new NodeProto());
-            BTEditorTree tree = new BTEditorTree(root, sourceTree);
-            return tree;
-        }
+		public T GetRoot<T>() where T : Node
+		{
+			return _root as T;
+		}
 
-        public static BTEditorTree OpenFromGameObject(GameObject source)
-        {
-            BehaviorTreeConfig sourceTree = source.GetComponent<BehaviorTreeConfig>();
-            if (sourceTree == null)
-            {
-                throw new GameException($"{source.name}预制中不包含行为树");
-            }
-            return new BTEditorTree(sourceTree);
-        }
+		private BTEditorTree(Node root, BehaviorTreeConfig config)
+		{
+			_root = root;
+			_root.Id = BehaviorManager.NodeIdStartIndex;
+			this.BTConfig = config;
+		}
 
-        public T GetChildInType<T>() where T : Node
-        {
-            Queue<Node> nodeStack = new Queue<Node>();
-            nodeStack.Enqueue(_root);
-            while (nodeStack.Count > 0)
-            {
-                Node c = nodeStack.Dequeue();
-                if (c.GetType() == typeof(T))
-                {
-                    return c as T;
-                }
-                foreach (Node child in c.GetChildren)
-                {
-                    nodeStack.Enqueue(child);
-                }
-            }
-            return null;
-        }
+		public static BTEditorTree CreateTree<T>(GameObject source)
+		{
+			BehaviorTreeConfig sourceTree = source.GetComponent<BehaviorTreeConfig>();
+			if (sourceTree == null)
+			{
+				sourceTree = source.AddComponent<BehaviorTreeConfig>();
+			}
+			Node root = (Node) Activator.CreateInstance(typeof (T), new NodeProto());
+			BTEditorTree tree = new BTEditorTree(root, sourceTree);
+			return tree;
+		}
 
-        public void AddChild(Node child, Node parent)
-        {
-            parent.AddChild(child);
-            child.Id = ++_id;
-        }
+		public static BTEditorTree OpenFromGameObject(GameObject source)
+		{
+			BehaviorTreeConfig sourceTree = source.GetComponent<BehaviorTreeConfig>();
+			if (sourceTree == null)
+			{
+				throw new GameException($"{source.name}预制中不包含行为树");
+			}
+			return new BTEditorTree(sourceTree);
+		}
 
-        public T[] GetChildrenInType<T>() where T : Node
-        {
-            Queue<Node> nodeStack = new Queue<Node>();
-            List<T> list = new List<T>();
-            nodeStack.Enqueue(_root);
-            while (nodeStack.Count > 0)
-            {
-                Node c = nodeStack.Dequeue();
-                if (c.GetType() == typeof(T))
-                {
-                    list.Add(c as T);
-                }
-                foreach (Node child in c.GetChildren)
-                {
-                    nodeStack.Enqueue(child);
-                }
-            }
-            return list.ToArray();
-        }
+		public T GetChildInType<T>() where T : Node
+		{
+			Queue<Node> nodeStack = new Queue<Node>();
+			nodeStack.Enqueue(_root);
+			while (nodeStack.Count > 0)
+			{
+				Node c = nodeStack.Dequeue();
+				if (c.GetType() == typeof (T))
+				{
+					return c as T;
+				}
+				foreach (Node child in c.GetChildren)
+				{
+					nodeStack.Enqueue(child);
+				}
+			}
+			return null;
+		}
 
-        public void SaveToBehaviorTreeConfig(BehaviorTreeConfig config)
-        {
-            _root.Serialize(config);
-        }
+		public void AddChild(Node child, Node parent)
+		{
+			parent.AddChild(child);
+			child.Id = ++_id;
+		}
 
-        public void Save()
-        {
-            if (IsPrefab(_config.gameObject))
-            {
-                GameObject go = GameObject.Instantiate(_config.gameObject);
-                go.name = _config.gameObject.name;
-                BehaviorTreeConfig newConfig = go.GetComponent<BehaviorTreeConfig>();
-                _root.Serialize(newConfig);
-                PrefabUtility.ReplacePrefab(go, _config, ReplacePrefabOptions.ReplaceNameBased);
-                GameObject.DestroyImmediate(go);
-            }
-            else
-            {
-                _root.Serialize(_config);
-            }
-        }
+		public T[] GetChildrenInType<T>() where T : Node
+		{
+			Queue<Node> nodeStack = new Queue<Node>();
+			List<T> list = new List<T>();
+			nodeStack.Enqueue(_root);
+			while (nodeStack.Count > 0)
+			{
+				Node c = nodeStack.Dequeue();
+				if (c.GetType() == typeof (T))
+				{
+					list.Add(c as T);
+				}
+				foreach (Node child in c.GetChildren)
+				{
+					nodeStack.Enqueue(child);
+				}
+			}
+			return list.ToArray();
+		}
 
-        private bool IsPrefab(GameObject go)
-        {
-            string path = AssetDatabase.GetAssetPath(_config);
-            return !string.IsNullOrEmpty(path);
-        }
-    }
+		public void SaveToBehaviorTreeConfig(BehaviorTreeConfig config)
+		{
+			_root.Serialize(config);
+		}
 
-    public static class NodeExtension
-    {
-        public static T FindChildOnDesc<T>(this Node node, string desc) where T : Node
-        {
-            foreach (Node child in node.GetChildren)
-            {
-                if (child.Description == desc)
-                {
-                    return node as T;
-                }
-            }
-            return null;
-        }
+		public void Save()
+		{
+			if (IsPrefab(this.BTConfig.gameObject))
+			{
+				GameObject go = GameObject.Instantiate(this.BTConfig.gameObject);
+				go.name = this.BTConfig.gameObject.name;
+				BehaviorTreeConfig newConfig = go.GetComponent<BehaviorTreeConfig>();
+				_root.Serialize(newConfig);
+				PrefabUtility.ReplacePrefab(go, this.BTConfig, ReplacePrefabOptions.ReplaceNameBased);
+				GameObject.DestroyImmediate(go);
+			}
+			else
+			{
+				_root.Serialize(this.BTConfig);
+			}
+		}
 
-        public static T GetChildInType<T>(this Node root) where T : Node
-        {
-            Queue<Node> nodeStack = new Queue<Node>();
-            nodeStack.Enqueue(root);
-            while (nodeStack.Count > 0)
-            {
-                Node c = nodeStack.Dequeue();
-                foreach (Node child in c.GetChildren)
-                {
-                    if (child.GetType() == typeof(T))
-                    {
-                        return child as T;
-                    }
-                    nodeStack.Enqueue(child);
-                }
-            }
-            return null;
-        }
+		private bool IsPrefab(GameObject go)
+		{
+			string path = AssetDatabase.GetAssetPath(this.BTConfig);
+			return !string.IsNullOrEmpty(path);
+		}
+	}
 
-        public static T[] GetChildrenInType<T>(this Node root) where T : Node
-        {
-            Queue<Node> nodeStack = new Queue<Node>();
-            List<T> list = new List<T>();
-            nodeStack.Enqueue(root);
-            while (nodeStack.Count > 0)
-            {
-                Node c = nodeStack.Dequeue();
-                foreach (Node child in c.GetChildren)
-                {
-                    if (child.GetType() == typeof(T))
-                    {
-                        list.Add(child as T);
-                    }
-                    nodeStack.Enqueue(child);
-                }
-            }
-            return list.ToArray();
-        }
-        public static void Serialize(this Node root, BehaviorTreeConfig config)
-        {
-            config.Clear();
-            BehaviorNodeConfig rootNp = config.AddRootNode(root.GetType().Name);
-            Queue<Node> queue = new Queue<Node>();
-            Queue<BehaviorNodeConfig> npQue = new Queue<BehaviorNodeConfig>();
-            rootNp.describe = root.Description;
-            queue.Enqueue(root);
-            npQue.Enqueue(rootNp);
-            while (queue.Count > 0)
-            {
-                Node cur = queue.Dequeue();
-                BehaviorNodeConfig np = npQue.Dequeue();
-                foreach (Node child in cur.GetChildren)
-                {
-                    BehaviorNodeConfig childNp = GetNodeConfigFromNode(child);
-                    queue.Enqueue(child);
-                    npQue.Enqueue(childNp);
-                    config.AddChild(np, childNp);
-                }
-            }
-//             PrintNode(root);
-//             PrintConfigNode(config.RootNodeConfig);
-        }
-//         private static void PrintNode(Node node)
-//         {
-//             Log.Info($"id:{node.Id}  type:{node.GetType().Name}");
-//             foreach (var child in node.GetChildren)
-//             {
-//                 PrintNode(child);
-//             }
-//         }
-//         private static void PrintConfigNode(BehaviorNodeConfig node)
-//         {
-//             Log.Info($"nodeConfigId:{node.id}  nodeConfigType:{node.name} childCount:{node.transform.childCount}");
-//             foreach (Transform child in node.transform)
-//             {
-//                 PrintConfigNode(child.gameObject.GetComponent<BehaviorNodeConfig>());
-//             }
-//         }
+	public static class NodeExtension
+	{
+		public static T FindChildOnDesc<T>(this Node node, string desc) where T : Node
+		{
+			foreach (Node child in node.GetChildren)
+			{
+				if (child.Description == desc)
+				{
+					return node as T;
+				}
+			}
+			return null;
+		}
 
-        private static NodeProto GetNodeProtoFromNode(Node node)
-        {
-            NodeProto np = new NodeProto();
-            np.nodeId = (int)node.Id;
-            FieldInfo[] mens = node.GetType().GetFields();
-            np.describe = node.Description;
-            np.name = node.GetType().Name;
-            foreach (FieldInfo men in mens)
-            {
-                np.args_dict.SetKeyValueComp(men.FieldType, men.Name, men.GetValue(node));
-            }
-            return np;
-        }
-        private static BehaviorNodeConfig GetNodeConfigFromNode(Node node)
-        {
-            return BehaviorNodeConfigExtension.ProtoToConfig(GetNodeProtoFromNode(node));
-        }
-    }
-}
+		public static T GetChildInType<T>(this Node root) where T : Node
+		{
+			Queue<Node> nodeStack = new Queue<Node>();
+			nodeStack.Enqueue(root);
+			while (nodeStack.Count > 0)
+			{
+				Node c = nodeStack.Dequeue();
+				foreach (Node child in c.GetChildren)
+				{
+					if (child.GetType() == typeof (T))
+					{
+						return child as T;
+					}
+					nodeStack.Enqueue(child);
+				}
+			}
+			return null;
+		}
+
+		public static T[] GetChildrenInType<T>(this Node root) where T : Node
+		{
+			Queue<Node> nodeStack = new Queue<Node>();
+			List<T> list = new List<T>();
+			nodeStack.Enqueue(root);
+			while (nodeStack.Count > 0)
+			{
+				Node c = nodeStack.Dequeue();
+				foreach (Node child in c.GetChildren)
+				{
+					if (child.GetType() == typeof (T))
+					{
+						list.Add(child as T);
+					}
+					nodeStack.Enqueue(child);
+				}
+			}
+			return list.ToArray();
+		}
+
+		public static void Serialize(this Node root, BehaviorTreeConfig config)
+		{
+			config.Clear();
+			BehaviorNodeConfig rootNp = config.AddRootNode(root.GetType().Name);
+			Queue<Node> queue = new Queue<Node>();
+			Queue<BehaviorNodeConfig> npQue = new Queue<BehaviorNodeConfig>();
+			rootNp.describe = root.Description;
+			queue.Enqueue(root);
+			npQue.Enqueue(rootNp);
+			while (queue.Count > 0)
+			{
+				Node cur = queue.Dequeue();
+				BehaviorNodeConfig np = npQue.Dequeue();
+				foreach (Node child in cur.GetChildren)
+				{
+					BehaviorNodeConfig childNp = GetNodeConfigFromNode(child);
+					queue.Enqueue(child);
+					npQue.Enqueue(childNp);
+					config.AddChild(np, childNp);
+				}
+			}
+			//             PrintNode(root);
+			//             PrintConfigNode(config.RootNodeConfig);
+		}
+
+		//         private static void PrintNode(Node node)
+		//         {
+		//             Log.Info($"id:{node.Id}  type:{node.GetType().Name}");
+		//             foreach (var child in node.GetChildren)
+		//             {
+		//                 PrintNode(child);
+		//             }
+		//         }
+		//         private static void PrintConfigNode(BehaviorNodeConfig node)
+		//         {
+		//             Log.Info($"nodeConfigId:{node.id}  nodeConfigType:{node.name} childCount:{node.transform.childCount}");
+		//             foreach (Transform child in node.transform)
+		//             {
+		//                 PrintConfigNode(child.gameObject.GetComponent<BehaviorNodeConfig>());
+		//             }
+		//         }
+
+		private static NodeProto GetNodeProtoFromNode(Node node)
+		{
+			NodeProto np = new NodeProto();
+			np.nodeId = (int) node.Id;
+			FieldInfo[] mens = node.GetType().GetFields();
+			np.describe = node.Description;
+			np.name = node.GetType().Name;
+			foreach (FieldInfo men in mens)
+			{
+				np.args_dict.SetKeyValueComp(men.FieldType, men.Name, men.GetValue(node));
+			}
+			return np;
+		}
+
+		private static BehaviorNodeConfig GetNodeConfigFromNode(Node node)
+		{
+			return BehaviorNodeConfigExtension.ProtoToConfig(GetNodeProtoFromNode(node));
+		}
+	}
+}

+ 40 - 38
Unity/Assets/Editor/BehaviorTreeEditor/PropertyDesigner.cs

@@ -1,4 +1,4 @@
-using System;
+using System;
 using System.Collections.Generic;
 using Base;
 using Model;
@@ -39,7 +39,7 @@ namespace MyEditor
 					{
 						mDragingBorder = true;
 					}
-                    break;
+					break;
 				case EventType.MouseDrag:
 					if (mDragingBorder)
 					{
@@ -290,7 +290,7 @@ namespace MyEditor
 
 		private string searchNodeName = "";
 		private BehaviorTreeConfig searchTree;
-		private GameObject[] searchGoArr = new GameObject[0];
+		private readonly GameObject[] searchGoArr = new GameObject[0];
 		private Rect mBorderRect; //边框
 		private Vector2 mScrollPosition = Vector2.zero;
 		private Rect mGraphRect = new Rect(0, 0, 50, 50); //绘图区域
@@ -325,7 +325,7 @@ namespace MyEditor
 			EditorGUILayout.EndHorizontal();
 			return value;
 		}
-		
+
 		private void DrawValueView()
 		{
 			if (mCurBehaviorNode == null || mCurBehaviorNode.Proto == null)
@@ -393,26 +393,26 @@ namespace MyEditor
 			{
 				NodeFieldDesc desc = fieldList[i];
 				Type fieldType = ExportNodeTypeConfig.GetFieldType(nodeName, desc.name);
-                ClientNodeTypeProto clientNode = ExportNodeTypeConfig.GetNodeTypeProtoFromDll(nodeName);
-                object newValue = null;
+				ClientNodeTypeProto clientNode = ExportNodeTypeConfig.GetNodeTypeProtoFromDll(nodeName);
+				object newValue = null;
 				if (!mCurBehaviorNode.args_dict.ContainsKey(desc.name))
 				{
 					mCurBehaviorNode.args_dict.Add(desc.name, new ValueBase());
 				}
 				if (BehaviorTreeArgsDict.IsStringType(fieldType))
 				{
-                    if (nodeParamType == NodeParamType.Input)
-                    {
-                        newValue = InputEnumFieldValue(desc);
-                    }
-                    else if (nodeParamType == NodeParamType.Output && clientNode.classify == NodeClassifyType.Root.ToString())
-                    { 
-                        newValue = ConstTextFieldValue(desc);   
-                    }
-                    else
-                    {
-                        newValue = TextFieldValue(desc);
-                    }
+					if (nodeParamType == NodeParamType.Input)
+					{
+						newValue = InputEnumFieldValue(desc);
+					}
+					else if (nodeParamType == NodeParamType.Output && clientNode.classify == NodeClassifyType.Root.ToString())
+					{
+						newValue = ConstTextFieldValue(desc);
+					}
+					else
+					{
+						newValue = TextFieldValue(desc);
+					}
 				}
 				else if (BehaviorTreeArgsDict.IsFloatType(fieldType))
 				{
@@ -501,14 +501,16 @@ namespace MyEditor
 			}
 			return newValue;
 		}
-        private object ConstTextFieldValue(NodeFieldDesc desc)
-        {
-            string oldValue =  desc.value.ToString();
-            EditorGUILayout.LabelField(GetPropDesc(desc));
-            EditorGUILayout.LabelField("", oldValue);
-            return oldValue;
-        }
-        private object TextFieldValue(NodeFieldDesc desc)
+
+		private object ConstTextFieldValue(NodeFieldDesc desc)
+		{
+			string oldValue = desc.value.ToString();
+			EditorGUILayout.LabelField(GetPropDesc(desc));
+			EditorGUILayout.LabelField("", oldValue);
+			return oldValue;
+		}
+
+		private object TextFieldValue(NodeFieldDesc desc)
 		{
 			string oldValue = (string) mCurBehaviorNode.args_dict.GetTreeDictValue(desc.type, desc.name);
 			EditorGUILayout.LabelField(GetPropDesc(desc));
@@ -618,7 +620,7 @@ namespace MyEditor
 				oldValue = BTEnvKey.None;
 			}
 			string[] enumValueArr;
-			if (mCurBehaviorNode.IsRoot() && desc.value.ToString() != BTEnvKey.None.ToString())
+			if (mCurBehaviorNode.IsRoot() && desc.value.ToString() != BTEnvKey.None)
 			{
 				enumValueArr = new string[1] { desc.value.ToString() };
 			}
@@ -627,9 +629,9 @@ namespace MyEditor
 				enumValueArr = BehaviorTreeInOutConstrain.GetEnvKeyEnum(typeof (BTEnvKey));
 				if (enumValueArr.Length == 0)
 				{
-					enumValueArr = new string[1] { BTEnvKey.None.ToString() };
+					enumValueArr = new string[1] { BTEnvKey.None };
 				}
-				if (oldValue == BTEnvKey.None.ToString())
+				if (oldValue == BTEnvKey.None)
 				{
 					oldValue = desc.value.ToString();
 				}
@@ -649,12 +651,12 @@ namespace MyEditor
 			string[] enumValueArr = BehaviorManager.GetInstance().GetCanInPutEnvKeyArray(mCurBehaviorNode, desc);
 			if (enumValueArr.Length == 0)
 			{
-				enumValueArr = new string[1] { BTEnvKey.None.ToString() };
+				enumValueArr = new string[1] { BTEnvKey.None };
+			}
+			else if (string.IsNullOrEmpty(oldValue))
+			{
+				oldValue = enumValueArr[0];
 			}
-            else if(string.IsNullOrEmpty(oldValue))
-            {
-                oldValue = enumValueArr[0];
-            }
 			int oldSelect = IndexInStringArr(enumValueArr, oldValue);
 			string label = desc.name + (desc.desc == ""? "" : $"({desc.desc})") + $"({desc.envKeyType})";
 			EditorGUILayout.LabelField(label);
@@ -678,14 +680,14 @@ namespace MyEditor
 		private object EnumFieldValue(NodeFieldDesc desc)
 		{
 			string oldValue = mCurBehaviorNode.args_dict.GetTreeDictValue(desc.type, desc.name)?.ToString();
-            if (string.IsNullOrEmpty(oldValue))
+			if (string.IsNullOrEmpty(oldValue))
 			{
 				oldValue = GetDefaultEnumValue(desc.type);
 			}
-            Enum oldValueEnum = (Enum)Enum.Parse(desc.type, oldValue);
-            Enum newValueEnum;
+			Enum oldValueEnum = (Enum) Enum.Parse(desc.type, oldValue);
+			Enum newValueEnum;
 			EditorGUILayout.LabelField(desc.type.ToString());
-            newValueEnum = EditorGUILayout.EnumPopup(oldValueEnum);
+			newValueEnum = EditorGUILayout.EnumPopup(oldValueEnum);
 			return newValueEnum.ToString();
 		}
 

+ 306 - 295
Unity/Assets/Editor/BehaviorTreeEditor/RightDesigner.cs

@@ -6,299 +6,310 @@ using UnityEngine;
 
 namespace MyEditor
 {
-    public class RightDesigner : Editor
-    {
-        private readonly string[] mBehaviorToolbarStrings = {"节点", "工具"};
-        private int mBehaviorToolbarSelection;
-        private float mWidth = 380f;
-      
-        private BehaviorNodeData mCurBehaviorNode;
-        private string mSearchNode = "";
-        private FoldoutNode mCurNode;
-
-        private int mNodeTypeSelection;
-        private string[] mNodeTypeToolbarStrings = { "All", "Composite", "Decorator", "Action", "Condition", "Root", "DataTrans" };
-        private int mEnumNodeTypeSelection;
-        string[] mEnumNodeTypeArr;
-       // private FoldoutFolder mNodeFoldout;
-
-        private Vector2 mTreeScrollPos = Vector2.zero;
-        private int mNodeCount;
-        private FoldoutFolder mNodeFoldout;
-        private FoldoutFolder mCurNodeFolder;
-        public RightDesigner()
-        {
-            UpdateList();
-        }
-        Rect toolbarRect = new Rect(0f, 0f, 0, 0);
-        public void Draw()
-        {
-           // HandleEvents();
-            toolbarRect = new Rect(Screen.width - mWidth, 0f, mWidth, 18f);
-            Rect boxRect = new Rect(Screen.width - mWidth, toolbarRect.height, this.mWidth, (Screen.height - toolbarRect.height) - 21f);
-            GUILayout.BeginArea(toolbarRect, EditorStyles.toolbar);
-            this.mBehaviorToolbarSelection = GUILayout.Toolbar(this.mBehaviorToolbarSelection, this.mBehaviorToolbarStrings, EditorStyles.toolbarButton);
-            GUILayout.EndArea();
-            GUILayout.BeginArea(boxRect);
-            Filter();
-            if (mBehaviorToolbarSelection == 0)
-            {
-                DrawNodes();
-            }
-            else if (mBehaviorToolbarSelection == 1)
-            {
-                DrawTools();
-            }
-//             else if (mBehaviorToolbarSelection == 2)
-//             {
-//                 DrawTools();
-//             }
-//             else if (mBehaviorToolbarSelection == 3)
-//             {
-//                 DrawDebugView();
-//             }
-            GUILayout.EndArea();
-        }
-        private void DrawNodes()
-        {
-            float offset = 190f;
-            if (mCurNode == null)
-            {
-                offset = 55f;
-            }
-            DrawSearchList(offset);
-            DrawNodeFunctions(offset);
-        }
-        private string searchNodeName = "";
-        private BehaviorTreeConfig searchTree;
-        private GameObject[] searchGoArr = new GameObject[0];
-        private Rect mBorderRect; //边框
-        private Vector2 mScrollPosition = Vector2.zero;
-        private Rect mGraphRect = new Rect(0, 0, 50, 50); //绘图区域
-        private Vector2 scrollPosition = Vector2.zero;
-
-        private void DrawTools()
-        {
-        }
-
-        private void ShowResult()
-        {
-            Rect boxRect1 = new Rect(0f, 100, this.mWidth, Screen.height);
-            GUILayout.BeginArea(boxRect1);
-
-            scrollPosition = GUI.BeginScrollView(new Rect(0, 0, this.mWidth, 220), scrollPosition, new Rect(0, 0, this.mWidth - 20, searchGoArr.Length * 20));
-            for (int i = 0; i < this.searchGoArr.Length; i++)
-            {
-                searchGoArr[i] = BehaviourTreeField((i + 1).ToString(), searchGoArr[i]);
-            }
-
-            GUI.EndScrollView();
-            GUILayout.EndArea();
-        }
-        private BehaviorTreeConfig treeConfig;
-
-        public GameObject BehaviourTreeField(string desc, GameObject value)
-        {
-            EditorGUILayout.BeginHorizontal();
-            value = (GameObject)EditorGUILayout.ObjectField(desc, value, typeof(GameObject), false);
-            if (value.GetComponent<BehaviorTreeConfig>() != null && GUILayout.Button("打开行为树"))
-            {
-                BehaviorManager.GetInstance().OpenBehaviorEditor(value);
-                SetToolBar(2);
-            }
-            EditorGUILayout.EndHorizontal();
-            return value;
-        }
-        public void SetToolBar(int select)
-        {
-            this.mBehaviorToolbarSelection = select;
-        }
-
-        private string DrawSearchList(float offset)
-        {
-            GUILayout.BeginHorizontal();
-            GUI.SetNextControlName("Search");
-            this.mSearchNode = GUILayout.TextField(this.mSearchNode, GUI.skin.FindStyle("ToolbarSeachTextField"));
-            GUILayout.EndHorizontal();
-
-            toolbarRect = new Rect(0f, 15f, mWidth, 25f);
-            Rect boxRect = new Rect(0f, toolbarRect.height, this.mWidth, (Screen.height - toolbarRect.height) - 21f + 10);
-            GUILayout.BeginArea(toolbarRect, EditorStyles.toolbar);
-            GUILayout.BeginHorizontal();
-
-            GUILayout.Label("Filter");
-            Array strArr = Enum.GetValues(typeof(NodeClassifyType));
-            List<string> strList = new List<string>();
-            strList.Add("All");
-            foreach (var str in strArr)
-            {
-                strList.Add(str.ToString());
-            }
-            mEnumNodeTypeArr = strList.ToArray();
-            mEnumNodeTypeSelection = EditorGUILayout.Popup(mEnumNodeTypeSelection, mEnumNodeTypeArr);
-            if (GUILayout.Button("Clear"))
-            {
-                ClearNodes();
-            }
-            GUILayout.EndHorizontal();
-            GUILayout.EndArea();
-
-            GUILayout.BeginArea(new Rect(0f, 15f + 20, this.mWidth, Screen.height - offset));
-            this.mTreeScrollPos = GUI.BeginScrollView(new Rect(0f, 0f, this.mWidth, Screen.height - offset), this.mTreeScrollPos,
-                    new Rect(0f, 0f, this.mWidth - 20f, mNodeCount * 19), false, false);
-            mNodeFoldout.Draw();
-            GUI.EndScrollView();
-            GUILayout.EndArea();
-            if (mCurNode != null)
-            {
-                string[] arr = mCurNode.Text.Split(' ');
-                string name = arr[0];
-                return name;
-            }
-            return "";
-        }
-        private void ClearNodes()
-        {
-            BehaviorManager.GetInstance().selectNodeName = "";
-            mEnumNodeTypeSelection = 0;
-            mSearchNode = "";
-            foreach (FoldoutFolder folder in mNodeFoldout.Folders)
-            {
-                foreach (FoldoutNode node in folder.Nodes)
-                {
-                    node.Hide = false;
-                }
-            }
-        }
-
-        private void DrawNodeFunctions(float offset)
-        {
-            Rect boxRect = new Rect(0f, Screen.height - offset + 15f, this.mWidth, 200f);
-            GUILayout.BeginArea(boxRect);
-            BehaviorManager.GetInstance().selectNodeName = "";
-            if (mCurNode != null)
-            {
-                string[] arr = mCurNode.Text.Split(' ');
-                string name = arr[0];
-                BehaviorManager.GetInstance().selectNodeName = name;
-                BehaviorManager.GetInstance().selectNodeType = mCurNode.folderName;
-                if (mCurNode.folderName != NodeClassifyType.Root.ToString())
-                {
-                    if (GUILayout.Button("新建"))
-                    {
-                        Game.Scene.GetComponent<EventComponent>().Run(EventIdType.BehaviorTreePropertyDesignerNewCreateClick, name, Vector2.zero);
-                    }
-                }
-                if (mCurNode.folderName != NodeClassifyType.Root.ToString() ||
-                    (mCurNode.folderName == NodeClassifyType.Root.ToString() && mCurBehaviorNode.IsRoot()))
-                {
-                    if (GUILayout.Button("替换"))
-                    {
-                        Game.Scene.GetComponent<EventComponent>().Run(EventIdType.BehaviorTreeReplaceClick, name, Vector2.zero);
-                    }
-                }
-
-                if (GUILayout.Button("保存"))
-                {
-                    BehaviorManager.GetInstance().SaveAll();
-                }
-                var node = BehaviorManager.GetInstance().GetNodeTypeProto(name);
-                GUILayout.Label("节点名:" + node.name);
-                GUILayout.Label("描述:" + node.describe);
-            }
-
-            GUILayout.EndArea();
-        }
-        private void UpdateList()
-        {
-            mNodeFoldout = new FoldoutFolder("所有节点", SelectNodeFolderCallback);
-            mNodeFoldout.Fold = true;
-
-            foreach (var kv in BehaviorManager.GetInstance().Classify2NodeProtoList)
-            {
-                string classify = kv.Key;
-                var nodeTypeList = kv.Value;
-                FoldoutFolder folder = mNodeFoldout.AddFolder(classify, SelectNodeFolderCallback);
-                folder.Fold = true;
-
-                mNodeCount++;
-                foreach (var nodeType in nodeTypeList)
-                {
-                    folder.AddNode(classify, nodeType.name + " (" + nodeType.describe + ")", SelectNodeCallback);
-                    mNodeCount++;
-                }
-            }
-        }
-        private void Filter()
-        {
-            foreach (FoldoutFolder folder in mNodeFoldout.Folders)
-            {
-                string selectType;
-                if (mEnumNodeTypeSelection == 0)
-                {
-                    selectType = "All";
-                }
-                else
-                {
-                    selectType = Enum.GetName(typeof(NodeClassifyType), mEnumNodeTypeSelection - 1);
-                }
-
-                if (selectType == folder.Text || selectType == "All")
-                {
-                    folder.Hide = false;
-                    foreach (FoldoutNode node in folder.Nodes)
-                    {
-                        if (node.Text.ToUpper().IndexOf(mSearchNode.ToUpper()) == -1)
-                        {
-                            node.Hide = true;
-                        }
-                        else
-                        {
-                            node.Hide = false;
-                        }
-                    }
-                }
-                else
-                {
-                    foreach (FoldoutNode node in folder.Nodes)
-                    {
-                        node.Hide = true;
-                    }
-                    folder.Hide = true;
-                }
-            }
-        }
-        public void SelectNodeFolderCallback(FoldoutFolder folder)
-        {
-            folder.Select = true;
-            if (mCurNodeFolder != null && mCurNodeFolder != folder)
-            {
-                mCurNodeFolder.Select = false;
-                mCurNodeFolder = null;
-            }
-            mCurNodeFolder = folder;
-        }
-
-        public void SelectNodeCallback(FoldoutNode node)
-        {
-            node.Select = true;
-            if (mCurNode != null && mCurNode != node)
-            {
-                mCurNode.Select = false;
-                mCurNode = null;
-            }
-            mCurNode = node;
-        }
-
-        public void onDraggingBorder(float deltaX)
-        {
-            mWidth -= deltaX;
-        }
-
-        public void onSelectNode(params object[] list)
-        {
-            mCurBehaviorNode = (BehaviorNodeData)list[0];
-            GUI.FocusControl("");
-        }
-    }
+	public class RightDesigner: Editor
+	{
+		private readonly string[] mBehaviorToolbarStrings = { "节点", "工具" };
+		private int mBehaviorToolbarSelection;
+		private float mWidth = 380f;
+
+		private BehaviorNodeData mCurBehaviorNode;
+		private string mSearchNode = "";
+		private FoldoutNode mCurNode;
+
+		private int mNodeTypeSelection;
+		private string[] mNodeTypeToolbarStrings = { "All", "Composite", "Decorator", "Action", "Condition", "Root", "DataTrans" };
+		private int mEnumNodeTypeSelection;
+		string[] mEnumNodeTypeArr;
+		// private FoldoutFolder mNodeFoldout;
+
+		private Vector2 mTreeScrollPos = Vector2.zero;
+		private int mNodeCount;
+		private FoldoutFolder mNodeFoldout;
+		private FoldoutFolder mCurNodeFolder;
+
+		public RightDesigner()
+		{
+			UpdateList();
+		}
+
+		Rect toolbarRect = new Rect(0f, 0f, 0, 0);
+
+		public void Draw()
+		{
+			// HandleEvents();
+			toolbarRect = new Rect(Screen.width - mWidth, 0f, mWidth, 18f);
+			Rect boxRect = new Rect(Screen.width - mWidth, toolbarRect.height, this.mWidth, (Screen.height - toolbarRect.height) - 21f);
+			GUILayout.BeginArea(toolbarRect, EditorStyles.toolbar);
+			this.mBehaviorToolbarSelection = GUILayout.Toolbar(this.mBehaviorToolbarSelection, this.mBehaviorToolbarStrings, EditorStyles.toolbarButton);
+			GUILayout.EndArea();
+			GUILayout.BeginArea(boxRect);
+			Filter();
+			if (mBehaviorToolbarSelection == 0)
+			{
+				DrawNodes();
+			}
+			else if (mBehaviorToolbarSelection == 1)
+			{
+				DrawTools();
+			}
+			//             else if (mBehaviorToolbarSelection == 2)
+			//             {
+			//                 DrawTools();
+			//             }
+			//             else if (mBehaviorToolbarSelection == 3)
+			//             {
+			//                 DrawDebugView();
+			//             }
+			GUILayout.EndArea();
+		}
+
+		private void DrawNodes()
+		{
+			float offset = 190f;
+			if (mCurNode == null)
+			{
+				offset = 55f;
+			}
+			DrawSearchList(offset);
+			DrawNodeFunctions(offset);
+		}
+
+		private string searchNodeName = "";
+		private BehaviorTreeConfig searchTree;
+		private readonly GameObject[] searchGoArr = new GameObject[0];
+		private Rect mBorderRect; //边框
+		private Vector2 mScrollPosition = Vector2.zero;
+		private Rect mGraphRect = new Rect(0, 0, 50, 50); //绘图区域
+		private Vector2 scrollPosition = Vector2.zero;
+
+		private void DrawTools()
+		{
+		}
+
+		private void ShowResult()
+		{
+			Rect boxRect1 = new Rect(0f, 100, this.mWidth, Screen.height);
+			GUILayout.BeginArea(boxRect1);
+
+			scrollPosition = GUI.BeginScrollView(new Rect(0, 0, this.mWidth, 220), scrollPosition, new Rect(0, 0, this.mWidth - 20, searchGoArr.Length * 20));
+			for (int i = 0; i < this.searchGoArr.Length; i++)
+			{
+				searchGoArr[i] = BehaviourTreeField((i + 1).ToString(), searchGoArr[i]);
+			}
+
+			GUI.EndScrollView();
+			GUILayout.EndArea();
+		}
+
+		private BehaviorTreeConfig treeConfig;
+
+		public GameObject BehaviourTreeField(string desc, GameObject value)
+		{
+			EditorGUILayout.BeginHorizontal();
+			value = (GameObject) EditorGUILayout.ObjectField(desc, value, typeof (GameObject), false);
+			if (value.GetComponent<BehaviorTreeConfig>() != null && GUILayout.Button("打开行为树"))
+			{
+				BehaviorManager.GetInstance().OpenBehaviorEditor(value);
+				SetToolBar(2);
+			}
+			EditorGUILayout.EndHorizontal();
+			return value;
+		}
+
+		public void SetToolBar(int select)
+		{
+			this.mBehaviorToolbarSelection = select;
+		}
+
+		private string DrawSearchList(float offset)
+		{
+			GUILayout.BeginHorizontal();
+			GUI.SetNextControlName("Search");
+			this.mSearchNode = GUILayout.TextField(this.mSearchNode, GUI.skin.FindStyle("ToolbarSeachTextField"));
+			GUILayout.EndHorizontal();
+
+			toolbarRect = new Rect(0f, 15f, mWidth, 25f);
+			Rect boxRect = new Rect(0f, toolbarRect.height, this.mWidth, (Screen.height - toolbarRect.height) - 21f + 10);
+			GUILayout.BeginArea(toolbarRect, EditorStyles.toolbar);
+			GUILayout.BeginHorizontal();
+
+			GUILayout.Label("Filter");
+			Array strArr = Enum.GetValues(typeof (NodeClassifyType));
+			List<string> strList = new List<string>();
+			strList.Add("All");
+			foreach (var str in strArr)
+			{
+				strList.Add(str.ToString());
+			}
+			mEnumNodeTypeArr = strList.ToArray();
+			mEnumNodeTypeSelection = EditorGUILayout.Popup(mEnumNodeTypeSelection, mEnumNodeTypeArr);
+			if (GUILayout.Button("Clear"))
+			{
+				ClearNodes();
+			}
+			GUILayout.EndHorizontal();
+			GUILayout.EndArea();
+
+			GUILayout.BeginArea(new Rect(0f, 15f + 20, this.mWidth, Screen.height - offset));
+			this.mTreeScrollPos = GUI.BeginScrollView(new Rect(0f, 0f, this.mWidth, Screen.height - offset), this.mTreeScrollPos,
+					new Rect(0f, 0f, this.mWidth - 20f, mNodeCount * 19), false, false);
+			mNodeFoldout.Draw();
+			GUI.EndScrollView();
+			GUILayout.EndArea();
+			if (mCurNode != null)
+			{
+				string[] arr = mCurNode.Text.Split(' ');
+				string name = arr[0];
+				return name;
+			}
+			return "";
+		}
+
+		private void ClearNodes()
+		{
+			BehaviorManager.GetInstance().selectNodeName = "";
+			mEnumNodeTypeSelection = 0;
+			mSearchNode = "";
+			foreach (FoldoutFolder folder in mNodeFoldout.Folders)
+			{
+				foreach (FoldoutNode node in folder.Nodes)
+				{
+					node.Hide = false;
+				}
+			}
+		}
+
+		private void DrawNodeFunctions(float offset)
+		{
+			Rect boxRect = new Rect(0f, Screen.height - offset + 15f, this.mWidth, 200f);
+			GUILayout.BeginArea(boxRect);
+			BehaviorManager.GetInstance().selectNodeName = "";
+			if (mCurNode != null)
+			{
+				string[] arr = mCurNode.Text.Split(' ');
+				string name = arr[0];
+				BehaviorManager.GetInstance().selectNodeName = name;
+				BehaviorManager.GetInstance().selectNodeType = mCurNode.folderName;
+				if (mCurNode.folderName != NodeClassifyType.Root.ToString())
+				{
+					if (GUILayout.Button("新建"))
+					{
+						Game.Scene.GetComponent<EventComponent>().Run(EventIdType.BehaviorTreePropertyDesignerNewCreateClick, name, Vector2.zero);
+					}
+				}
+				if (mCurNode.folderName != NodeClassifyType.Root.ToString() ||
+				    (mCurNode.folderName == NodeClassifyType.Root.ToString() && mCurBehaviorNode.IsRoot()))
+				{
+					if (GUILayout.Button("替换"))
+					{
+						Game.Scene.GetComponent<EventComponent>().Run(EventIdType.BehaviorTreeReplaceClick, name, Vector2.zero);
+					}
+				}
+
+				if (GUILayout.Button("保存"))
+				{
+					BehaviorManager.GetInstance().SaveAll();
+				}
+				var node = BehaviorManager.GetInstance().GetNodeTypeProto(name);
+				GUILayout.Label("节点名:" + node.name);
+				GUILayout.Label("描述:" + node.describe);
+			}
+
+			GUILayout.EndArea();
+		}
+
+		private void UpdateList()
+		{
+			mNodeFoldout = new FoldoutFolder("所有节点", SelectNodeFolderCallback);
+			mNodeFoldout.Fold = true;
+
+			foreach (var kv in BehaviorManager.GetInstance().Classify2NodeProtoList)
+			{
+				string classify = kv.Key;
+				var nodeTypeList = kv.Value;
+				FoldoutFolder folder = mNodeFoldout.AddFolder(classify, SelectNodeFolderCallback);
+				folder.Fold = true;
+
+				mNodeCount++;
+				foreach (var nodeType in nodeTypeList)
+				{
+					folder.AddNode(classify, nodeType.name + " (" + nodeType.describe + ")", SelectNodeCallback);
+					mNodeCount++;
+				}
+			}
+		}
+
+		private void Filter()
+		{
+			foreach (FoldoutFolder folder in mNodeFoldout.Folders)
+			{
+				string selectType;
+				if (mEnumNodeTypeSelection == 0)
+				{
+					selectType = "All";
+				}
+				else
+				{
+					selectType = Enum.GetName(typeof (NodeClassifyType), mEnumNodeTypeSelection - 1);
+				}
+
+				if (selectType == folder.Text || selectType == "All")
+				{
+					folder.Hide = false;
+					foreach (FoldoutNode node in folder.Nodes)
+					{
+						if (node.Text.ToUpper().IndexOf(mSearchNode.ToUpper()) == -1)
+						{
+							node.Hide = true;
+						}
+						else
+						{
+							node.Hide = false;
+						}
+					}
+				}
+				else
+				{
+					foreach (FoldoutNode node in folder.Nodes)
+					{
+						node.Hide = true;
+					}
+					folder.Hide = true;
+				}
+			}
+		}
+
+		public void SelectNodeFolderCallback(FoldoutFolder folder)
+		{
+			folder.Select = true;
+			if (mCurNodeFolder != null && mCurNodeFolder != folder)
+			{
+				mCurNodeFolder.Select = false;
+				mCurNodeFolder = null;
+			}
+			mCurNodeFolder = folder;
+		}
+
+		public void SelectNodeCallback(FoldoutNode node)
+		{
+			node.Select = true;
+			if (mCurNode != null && mCurNode != node)
+			{
+				mCurNode.Select = false;
+				mCurNode = null;
+			}
+			mCurNode = node;
+		}
+
+		public void onDraggingBorder(float deltaX)
+		{
+			mWidth -= deltaX;
+		}
+
+		public void onSelectNode(params object[] list)
+		{
+			mCurBehaviorNode = (BehaviorNodeData) list[0];
+			GUI.FocusControl("");
+		}
+	}
 }

+ 4 - 7
Unity/Assets/Editor/EditorInit.cs

@@ -1,8 +1,5 @@
-using System;
-using Base;
-using Model;
+using Model;
 using UnityEditor;
-using UnityEngine;
 
 namespace MyEditor
 {
@@ -11,8 +8,8 @@ namespace MyEditor
 	{
 		static EditorInit()
 		{
-			Game.EntityEventManager.Register("Model", typeof(Game).Assembly);
-			Game.EntityEventManager.Register("Editor", typeof(EditorInit).Assembly);
+			Game.EntityEventManager.Register("Model", typeof (Game).Assembly);
+			Game.EntityEventManager.Register("Editor", typeof (EditorInit).Assembly);
 		}
 	}
-}
+}

+ 1 - 2
Unity/Assets/Editor/ObjectManagerToolsEditor/ObjectManagerToolsWindow.cs

@@ -2,14 +2,13 @@
 using Model;
 using UnityEditor;
 
-public class ObjectManagerToolsWindow : EditorWindow
+public class ObjectManagerToolsWindow: EditorWindow
 {
 	[MenuItem("Tools/ObjectManagerTools/显示未Dispose的对象")]
 	private static void ShowUnDisposeObjects()
 	{
 		Log.Info(Game.DisposerInfo());
 	}
-	
 
 	[MenuItem("Tools/ObjectManagerTools/清除所有对象")]
 	private static void ClearAllObjects()

+ 10 - 10
Unity/Assets/Editor/ReferenceCollectorEditor/ReferenceCollectorEditor.cs

@@ -1,12 +1,12 @@
 using System;
 using System.Collections.Generic;
-using System.Linq;
 using UnityEditor;
 using UnityEngine;
+using Object = UnityEngine.Object;
 
-[CustomEditor(typeof(ReferenceCollector))]
+[CustomEditor(typeof (ReferenceCollector))]
 [CanEditMultipleObjects]
-public class ReferenceCollectorEditor : Editor
+public class ReferenceCollectorEditor: Editor
 {
 	private string searchKey
 	{
@@ -19,14 +19,14 @@ public class ReferenceCollectorEditor : Editor
 			if (_searchKey != value)
 			{
 				_searchKey = value;
-				heroPrefab = referenceCollector.Get<UnityEngine.Object>(searchKey);
+				heroPrefab = referenceCollector.Get<Object>(searchKey);
 			}
 		}
 	}
 
 	private ReferenceCollector referenceCollector;
 
-	private UnityEngine.Object heroPrefab = null;
+	private Object heroPrefab;
 
 	private string _searchKey = "";
 
@@ -45,7 +45,7 @@ public class ReferenceCollectorEditor : Editor
 
 	private void OnEnable()
 	{
-		referenceCollector = (ReferenceCollector)target;
+		referenceCollector = (ReferenceCollector) target;
 	}
 
 	public override void OnInspectorGUI()
@@ -72,7 +72,7 @@ public class ReferenceCollectorEditor : Editor
 		EditorGUILayout.EndHorizontal();
 		EditorGUILayout.BeginHorizontal();
 		searchKey = EditorGUILayout.TextField(searchKey);
-		EditorGUILayout.ObjectField(heroPrefab, typeof(UnityEngine.Object), false);
+		EditorGUILayout.ObjectField(heroPrefab, typeof (Object), false);
 		if (GUILayout.Button("删除"))
 		{
 			referenceCollector.Remove(searchKey);
@@ -86,7 +86,7 @@ public class ReferenceCollectorEditor : Editor
 		{
 			GUILayout.BeginHorizontal();
 			referenceCollector.data[i].key = EditorGUILayout.TextField(referenceCollector.data[i].key, GUILayout.Width(150));
-			referenceCollector.data[i].gameObject = EditorGUILayout.ObjectField(referenceCollector.data[i].gameObject, typeof(UnityEngine.Object), true);
+			referenceCollector.data[i].gameObject = EditorGUILayout.ObjectField(referenceCollector.data[i].gameObject, typeof (Object), true);
 			if (GUILayout.Button("X"))
 			{
 				delList.Add(i);
@@ -118,7 +118,7 @@ public class ReferenceCollectorEditor : Editor
 		serializedObject.UpdateIfDirtyOrScript();
 	}
 
-	private void AddReference(SerializedProperty dataProperty, string key, UnityEngine.Object obj)
+	private void AddReference(SerializedProperty dataProperty, string key, Object obj)
 	{
 		int index = dataProperty.arraySize;
 		dataProperty.InsertArrayElementAtIndex(index);
@@ -126,4 +126,4 @@ public class ReferenceCollectorEditor : Editor
 		element.FindPropertyRelative("key").stringValue = key;
 		element.FindPropertyRelative("gameObject").objectReferenceValue = obj;
 	}
-}
+}

+ 1 - 1
Unity/Assets/Editor/RsyncEditor/RsyncConfig.cs

@@ -10,4 +10,4 @@ namespace MyEditor
 		public string RelativePath = "";
 		public List<string> Exclude = new List<string>();
 	}
-}
+}

+ 8 - 17
Unity/Assets/Editor/RsyncEditor/RsyncEditor.cs

@@ -6,7 +6,7 @@ using UnityEngine;
 
 namespace MyEditor
 {
-	public class RsyncEditor : EditorWindow
+	public class RsyncEditor: EditorWindow
 	{
 		private const string ConfigFile = @"..\Tools\cwRsync\Config\rsyncConfig.txt";
 		private RsyncConfig rsyncConfig;
@@ -15,7 +15,7 @@ namespace MyEditor
 		[MenuItem("Tools/Rsync同步")]
 		private static void ShowWindow()
 		{
-			GetWindow(typeof(RsyncEditor));
+			GetWindow(typeof (RsyncEditor));
 		}
 
 		private void OnEnable()
@@ -72,25 +72,16 @@ namespace MyEditor
 				File.WriteAllText($@"..\Tools\cwRsync\Config\rsync.secrets", this.rsyncConfig.Password);
 				File.WriteAllText($@"..\Tools\cwRsync\Config\rsyncd.secrets", $"{this.rsyncConfig.Account}:{this.rsyncConfig.Password}");
 
-				string rsyncdConf =
-					"uid = root\n" +
-					"gid = root\n" +
-					"use chroot = no\n" +
-					"max connections = 100\n" +
-					"read only = no\n" +
-					"write only = no\n" +
-					"log file =/var/log/rsyncd.log\n" +
-					"[Upload]\n" +
-					$"path = /home/{this.rsyncConfig.Account}/\n" +
-					$"auth users = {this.rsyncConfig.Account}\n" +
-					"secrets file = /etc/rsyncd.secrets\n" +
-					"list = yes";
+				string rsyncdConf = "uid = root\n" + "gid = root\n" + "use chroot = no\n" + "max connections = 100\n" + "read only = no\n" + "write only = no\n" +
+				                    "log file =/var/log/rsyncd.log\n" + "[Upload]\n" + $"path = /home/{this.rsyncConfig.Account}/\n" +
+				                    $"auth users = {this.rsyncConfig.Account}\n" + "secrets file = /etc/rsyncd.secrets\n" + "list = yes";
 				File.WriteAllText($@"..\Tools\cwRsync\Config\rsyncd.conf", rsyncdConf);
 			}
 
 			if (GUILayout.Button("同步"))
 			{
-				string arguments = $"-vzrtopg --password-file=./Tools/cwRsync/Config/rsync.secrets --exclude-from=./Tools/cwRsync/Config/exclude.txt --delete ./ {this.rsyncConfig.Account}@{this.rsyncConfig.Host}::Upload/{this.rsyncConfig.RelativePath} --chmod=ugo=rwX";
+				string arguments =
+						$"-vzrtopg --password-file=./Tools/cwRsync/Config/rsync.secrets --exclude-from=./Tools/cwRsync/Config/exclude.txt --delete ./ {this.rsyncConfig.Account}@{this.rsyncConfig.Host}::Upload/{this.rsyncConfig.RelativePath} --chmod=ugo=rwX";
 				ProcessStartInfo startInfo = new ProcessStartInfo();
 				startInfo.FileName = @".\Tools\cwRsync\rsync.exe";
 				startInfo.Arguments = arguments;
@@ -103,4 +94,4 @@ namespace MyEditor
 			}
 		}
 	}
-}
+}

+ 8 - 13
Unity/Assets/Editor/ServerCommandLineEditor/ServerCommandLineEditor.cs

@@ -10,7 +10,7 @@ using UnityEngine;
 
 namespace MyEditor
 {
-	public class ServerCommandLineEditor : EditorWindow
+	public class ServerCommandLineEditor: EditorWindow
 	{
 		private const string ConfigDir = @"..\Config\StartConfig\";
 
@@ -31,7 +31,7 @@ namespace MyEditor
 		[MenuItem("Tools/命令行配置")]
 		private static void ShowWindow()
 		{
-			GetWindow(typeof(ServerCommandLineEditor));
+			GetWindow(typeof (ServerCommandLineEditor));
 		}
 
 		private void OnEnable()
@@ -124,7 +124,7 @@ namespace MyEditor
 			{
 				this.LoadConfig();
 			}
-			
+
 			this.newFileName = EditorGUILayout.TextField("文件名", this.newFileName);
 
 			if (GUILayout.Button("添加"))
@@ -183,7 +183,7 @@ namespace MyEditor
 				GUILayout.Label($"服务器IP:");
 				startConfig.ServerIP = EditorGUILayout.TextField(startConfig.ServerIP);
 				GUILayout.Label($"AppType:");
-				startConfig.AppType = (AppType)EditorGUILayout.EnumPopup(startConfig.AppType);
+				startConfig.AppType = (AppType) EditorGUILayout.EnumPopup(startConfig.AppType);
 
 				InnerConfig innerConfig = startConfig.GetComponent<InnerConfig>();
 				if (innerConfig != null)
@@ -221,7 +221,7 @@ namespace MyEditor
 				{
 					for (int j = 1; j < this.copyNum + 1; ++j)
 					{
-						StartConfig newStartConfig = (StartConfig)startConfig.Clone();
+						StartConfig newStartConfig = (StartConfig) startConfig.Clone();
 						newStartConfig.AppId += j;
 						this.startConfigs.Add(newStartConfig);
 					}
@@ -236,14 +236,14 @@ namespace MyEditor
 			this.copyNum = EditorGUILayout.IntField("复制数量: ", this.copyNum);
 
 			GUILayout.Label($"添加的AppType:");
-			this.AppType = (AppType)EditorGUILayout.EnumPopup(this.AppType);
+			this.AppType = (AppType) EditorGUILayout.EnumPopup(this.AppType);
 
 			if (GUILayout.Button("添加一行配置"))
 			{
 				StartConfig newStartConfig = new StartConfig();
 
 				newStartConfig.AppType = this.AppType;
-				
+
 				if (this.AppType.Is(AppType.Gate | AppType.Realm | AppType.Manager))
 				{
 					newStartConfig.AddComponent<InnerConfig>();
@@ -259,7 +259,6 @@ namespace MyEditor
 			}
 			GUILayout.EndHorizontal();
 
-
 			GUILayout.BeginHorizontal();
 
 			if (GUILayout.Button("保存"))
@@ -286,11 +285,7 @@ namespace MyEditor
 
 				string arguments = $"--appId={startConfig.AppId} --appType={startConfig.AppType} --config=../Config/StartConfig/{this.fileName}";
 
-				ProcessStartInfo info = new ProcessStartInfo(@"App.exe", arguments)
-				{
-					UseShellExecute = true,
-					WorkingDirectory = @"..\Bin\"
-				};
+				ProcessStartInfo info = new ProcessStartInfo(@"App.exe", arguments) { UseShellExecute = true, WorkingDirectory = @"..\Bin\" };
 				Process.Start(info);
 			}
 			GUILayout.EndHorizontal();

+ 5 - 6
Unity/Assets/Editor/ServerManagerEditor/ServerManagerEditor.cs

@@ -6,7 +6,7 @@ using UnityEngine;
 
 namespace MyEditor
 {
-	public class ServerManagerEditor : EditorWindow
+	public class ServerManagerEditor: EditorWindow
 	{
 		private string managerAddress;
 
@@ -18,7 +18,7 @@ namespace MyEditor
 		[MenuItem("Tools/服务器管理")]
 		private static void ShowWindow()
 		{
-			GetWindow(typeof(ServerManagerEditor));
+			GetWindow(typeof (ServerManagerEditor));
 		}
 
 		private void OnEnable()
@@ -34,7 +34,6 @@ namespace MyEditor
 				return;
 			}
 
-
 			AppType reloadType = AppType.None;
 			this.isAll = GUILayout.Toggle(this.isAll, "All");
 			if (this.isAll)
@@ -53,12 +52,12 @@ namespace MyEditor
 					this.isAll = false;
 				}
 			}
-			
+
 			this.managerAddress = EditorGUILayout.TextField("Manager Address: ", this.managerAddress);
 
 			if (GUILayout.Button("Reload"))
 			{
-				for(int i = 0; i < this.isCheck.Length; ++i)
+				for (int i = 0; i < this.isCheck.Length; ++i)
 				{
 					if (this.isCheck[i])
 					{
@@ -82,4 +81,4 @@ namespace MyEditor
 			}
 		}
 	}
-}
+}

+ 4 - 4
Unity/Assets/Scripts/BehaviorTree/BTEnv.cs

@@ -4,7 +4,7 @@ using System.Collections.Generic;
 
 namespace Model
 {
-	public class BTEnv : IEnumerable
+	public class BTEnv: IEnumerable
 	{
 		public Dictionary<string, object> Values
 		{
@@ -13,7 +13,7 @@ namespace Model
 				return values;
 			}
 		}
-		
+
 		private Dictionary<string, object> values = new Dictionary<string, object>();
 
 		public virtual void BeginInit()
@@ -57,11 +57,11 @@ namespace Model
 			object value = values[key];
 			try
 			{
-				return (T)value;
+				return (T) value;
 			}
 			catch (InvalidCastException e)
 			{
-				throw new GameException($"不能把{value.GetType()}转换为{typeof(T)}", e);
+				throw new GameException($"不能把{value.GetType()}转换为{typeof (T)}", e);
 			}
 		}
 

+ 8 - 5
Unity/Assets/Scripts/BehaviorTree/BTEnvKey.cs

@@ -7,12 +7,13 @@ namespace Model
 	{
 		Input,
 		Output,
-		None,
+		None
 	}
+
 	public enum BehaviorTreeEnum
 	{
 		SkillShakingTree,
-		SkillShakingTree2,
+		SkillShakingTree2
 	}
 
 	public static class BTEnvKey
@@ -82,15 +83,17 @@ namespace Model
 			}
 			return strArr;
 		}
+
 		public static List<string> GetTreeEnumList(Dictionary<string, Type> envKeyDict)
 		{
 			List<string> list = new List<string>();
 			foreach (var item in envKeyDict)
 			{
-				list.Add(item.Key.ToString());
+				list.Add(item.Key);
 			}
 			return list;
 		}
+
 		public static List<string> GetTreeEnumFilterList(Dictionary<string, Type> envKeyDict, Type type)
 		{
 			List<string> list = new List<string>();
@@ -98,10 +101,10 @@ namespace Model
 			{
 				if (item.Value == type)
 				{
-					list.Add(item.Key.ToString());
+					list.Add(item.Key);
 				}
 			}
 			return list;
 		}
 	}
-}
+}

+ 84 - 84
Unity/Assets/Scripts/BehaviorTree/BehaviorNodeConfig.cs

@@ -1,97 +1,97 @@
-using UnityEngine;
+using System;
 using System.Collections.Generic;
-using System;
 using System.Reflection;
+using UnityEngine;
 
 namespace Model
 {
-    public class BehaviorNodeConfig : MonoBehaviour 
-    {
-        public int id;
+	public class BehaviorNodeConfig: MonoBehaviour
+	{
+		public int id;
 
-        public string name;
+		public string name;
 
-        public string describe;
+		public string describe;
 
-        public BehaviorNodeConfig(string name, string _desc,int _id = 0)
-        {
-            this.name = name;
-            describe = _desc;
-            id = _id;
-        }
+		public BehaviorNodeConfig(string name, string _desc, int _id = 0)
+		{
+			this.name = name;
+			describe = _desc;
+			id = _id;
+		}
 
-        public BehaviorTreeArgsDict GetArgsDict()
-        {
-            BehaviorTreeArgsDict dict = new BehaviorTreeArgsDict();
-            foreach (var item in gameObject.GetComponents<BTTypeBaseComponent>())
-            {
-                FieldInfo info = item.GetType().GetField("fieldValue");
-                ValueBase valueBase = new ValueBase();
-               if (item.GetType() == typeof(BTEnumComponent))
-               {
-                   
-                    valueBase.SetValueByType(typeof(Enum), info.GetValue(item));
-                }
-               else
-                {
-                    valueBase.SetValueByType(info.FieldType, info.GetValue(item));
-                }
-                
-                dict.Add(item.fieldName,valueBase);
-            }
-            return dict;
-        }
-        public void SetValue(Type type,string fieldName, object value)
-        {
-            foreach (BTTypeBaseComponent item in gameObject.GetComponents<BTTypeBaseComponent>())
-            {
-                if (fieldName == item.fieldName)
-                {
-                    object fieldValue = value;
-                    FieldInfo fieldValueinfo = item.GetType().GetField("fieldValue");
-                    if (BehaviorTreeArgsDict.IsEnumType(type))
-                    {
-                        fieldValue = value.ToString();
-                    }
-                    fieldValueinfo.SetValue(item, fieldValue);
-                }
-            }
-        }
-        public object GetValue(string fieldName)
-        {
-            object fieldValue = null;
-            foreach (BTTypeBaseComponent item in gameObject.GetComponents<BTTypeBaseComponent>())
-            {
-                if (fieldName == item.fieldName)
-                {
-                    FieldInfo fieldValueinfo = item.GetType().GetField("fieldValue");
-                    fieldValue = fieldValueinfo.GetValue(item);
-                }
-            }
-            return fieldValue;
-        }
-        public NodeProto ToNodeProto()
-        {
-            return  NodeConfigToNodeProto(this);
-        }
+		public BehaviorTreeArgsDict GetArgsDict()
+		{
+			BehaviorTreeArgsDict dict = new BehaviorTreeArgsDict();
+			foreach (var item in gameObject.GetComponents<BTTypeBaseComponent>())
+			{
+				FieldInfo info = item.GetType().GetField("fieldValue");
+				ValueBase valueBase = new ValueBase();
+				if (item.GetType() == typeof (BTEnumComponent))
+				{
+					valueBase.SetValueByType(typeof (Enum), info.GetValue(item));
+				}
+				else
+				{
+					valueBase.SetValueByType(info.FieldType, info.GetValue(item));
+				}
 
-        private static NodeProto NodeConfigToNodeProto(BehaviorNodeConfig nodeProto)
-        {
-            NodeProto nodeData = new NodeProto();
-            nodeData.nodeId = nodeProto.id;
-            nodeData.name = nodeProto.name;
-            nodeData.describe = nodeProto.describe;
-            nodeData.args_dict = nodeProto.GetArgsDict();
-            nodeData.children = new List<NodeProto>();
-            foreach (Transform child in nodeProto.gameObject.transform)
-            {
-                BehaviorNodeConfig nodeConfig = child.gameObject.GetComponent<BehaviorNodeConfig>();
-                NodeProto childData = NodeConfigToNodeProto(nodeConfig);
-                nodeData.children.Add(childData);
-            }
-            return nodeData;
-        }
+				dict.Add(item.fieldName, valueBase);
+			}
+			return dict;
+		}
 
+		public void SetValue(Type type, string fieldName, object value)
+		{
+			foreach (BTTypeBaseComponent item in gameObject.GetComponents<BTTypeBaseComponent>())
+			{
+				if (fieldName == item.fieldName)
+				{
+					object fieldValue = value;
+					FieldInfo fieldValueinfo = item.GetType().GetField("fieldValue");
+					if (BehaviorTreeArgsDict.IsEnumType(type))
+					{
+						fieldValue = value.ToString();
+					}
+					fieldValueinfo.SetValue(item, fieldValue);
+				}
+			}
+		}
 
-    }
+		public object GetValue(string fieldName)
+		{
+			object fieldValue = null;
+			foreach (BTTypeBaseComponent item in gameObject.GetComponents<BTTypeBaseComponent>())
+			{
+				if (fieldName == item.fieldName)
+				{
+					FieldInfo fieldValueinfo = item.GetType().GetField("fieldValue");
+					fieldValue = fieldValueinfo.GetValue(item);
+				}
+			}
+			return fieldValue;
+		}
+
+		public NodeProto ToNodeProto()
+		{
+			return NodeConfigToNodeProto(this);
+		}
+
+		private static NodeProto NodeConfigToNodeProto(BehaviorNodeConfig nodeProto)
+		{
+			NodeProto nodeData = new NodeProto();
+			nodeData.nodeId = nodeProto.id;
+			nodeData.name = nodeProto.name;
+			nodeData.describe = nodeProto.describe;
+			nodeData.args_dict = nodeProto.GetArgsDict();
+			nodeData.children = new List<NodeProto>();
+			foreach (Transform child in nodeProto.gameObject.transform)
+			{
+				BehaviorNodeConfig nodeConfig = child.gameObject.GetComponent<BehaviorNodeConfig>();
+				NodeProto childData = NodeConfigToNodeProto(nodeConfig);
+				nodeData.children.Add(childData);
+			}
+			return nodeData;
+		}
+	}
 }

+ 25 - 25
Unity/Assets/Scripts/BehaviorTree/BehaviorTree.cs

@@ -4,34 +4,34 @@ using Base;
 
 namespace Model
 {
-    public class BehaviorTree
-    {
-        private readonly Node node;
-        public BehaviorTreeConfig behaviorTreeConfig { get; set; }
-        public Scene Scene { get; }
+	public class BehaviorTree
+	{
+		private readonly Node node;
+		public BehaviorTreeConfig behaviorTreeConfig { get; set; }
+		public Scene Scene { get; }
 
-	    public string Discription
-	    {
-		    get
-		    {
-			    return this.node.Description;
-		    }
-	    }
+		public string Discription
+		{
+			get
+			{
+				return this.node.Description;
+			}
+		}
 
-        public BehaviorTree(Scene scene, Node node)
-        {
-	        this.Scene = scene;
-            this.node = node;
-        }
+		public BehaviorTree(Scene scene, Node node)
+		{
+			this.Scene = scene;
+			this.node = node;
+		}
 
-        public bool Run(BTEnv env)
-        {
-	        try
-	        {
+		public bool Run(BTEnv env)
+		{
+			try
+			{
 				bool ret = this.node.DoRun(this, env);
-                List<long> pathList = env.Get<List<long>>(BTEnvKey.NodePath);
-                Game.Scene.GetComponent<EventComponent>().Run(EventIdType.BehaviorTreeRunTreeEvent, this, pathList);
-                return ret;
+				List<long> pathList = env.Get<List<long>>(BTEnvKey.NodePath);
+				Game.Scene.GetComponent<EventComponent>().Run(EventIdType.BehaviorTreeRunTreeEvent, this, pathList);
+				return ret;
 			}
 			catch (Exception e)
 			{
@@ -40,5 +40,5 @@ namespace Model
 				return false;
 			}
 		}
-    }
+	}
 }

+ 615 - 600
Unity/Assets/Scripts/BehaviorTree/BehaviorTreeArgsDict.cs

@@ -1,607 +1,622 @@
-using Model;
-using System;
+using System;
 using System.Collections.Generic;
-using System.Linq;
 using Base;
 using UnityEngine;
 
 namespace Model
 {
-    [Serializable]
-    public class BehaviorTreeArgsDict :  Dictionary<string, ValueBase>
-    {
-        public void SetKeyValueComp(Type type, string fieldName, object value)
-        {
-            if (IsStringType(type))
-            {
-                SetStrValue(fieldName, (string)value);
-            }
-            else if (IsObjectType(type))
-            {
-                SetObjectValue(fieldName, type, (UnityEngine.Object)value);
-            }
-            else if (IsIntType(type))
-            {
-                int intValue = 0;
-                int.TryParse(value.ToString(), out intValue);
-                SetIntValue(fieldName, intValue);
-            }
-            else if (IsLongType(type))
-            {
-                long longValue = 0;
-                long.TryParse(value.ToString(), out longValue);
-                SetLongValue(fieldName, longValue);
-            }
-            else if (IsFloatType(type))
-            {
-                float floatValue = 0;
-                float.TryParse(value.ToString(), out floatValue);
-                SetFloatValue(fieldName, floatValue);
-            }
-            else if (IsDoubleType(type))
-            {
-                double doubleValue = 0;
-                double.TryParse(value.ToString(), out doubleValue);
-                SetDoubleValue(fieldName, doubleValue);
-            }
-            else if (IsBoolType(type))
-            {
-                bool boolValue = false;
-                bool.TryParse(value.ToString(), out boolValue);
-                SetBoolValue(fieldName, boolValue);
-            }
-            else if (IsStringArrType(type))
-            {
-                SetStrArrValue(fieldName, (string[])value);
-            }
-            else if (IsIntArrType(type))
-            {
-                SetIntArrValue(fieldName, (int[])value);
-            }
-            else if (IsLongArrType(type))
-            {
-                SetLongArrValue(fieldName, (long[])value);
-            }
-            else if (IsFloatArrType(type))
-            {
-                SetFloatArrValue(fieldName, (float[])value);
-            }
-            else if (IsDoubleArrType(type))
-            {
-                SetDoubleArrValue(fieldName, (double[])value);
-            }
-            else if (IsEnumType(type))
-            {
-                SetEnumValue(fieldName, value.ToString());
-            }
-            else if (IsObjectArrayType(type))
-            {
-                SetObjectArrayValue(fieldName, type, (UnityEngine.Object[])value);
-            }
-            else
-            {
-                Log.Error($"行为树节点暂时未支持此类型:{type}!");
-            }
-        }
-
-        private void SetConvertebleValue(string fieldName, float value)
-        {
-            if (this.ContainsKey(fieldName))
-            {
-                this[fieldName].Convertivle = value;
-            }
-            else
-            {
-                ValueBase valueBase = new ValueBase();
-                valueBase.Convertivle = value;
-                this.Add(fieldName, valueBase);
-            }
-        }
-
-        public object GetTreeDictValue(Type fieldType, string fieldName)
-        {
-            if (!this.ContainsKey(fieldName))
-            {
-                Log.Error($"fieldName:{fieldName} 不存在!!!!");
-                return null;
-            }
-            ValueBase obj = this[fieldName];
-            return obj.GetValueByType(fieldType);
-        }
-
-        /// <summary>
-        /// judge
-        /// </summary>
-        /// <param nodeName="type"></param>
-        /// <returns></returns>
-        public static bool IsStringType(Type type)
-        {
-            return typeof(string) == type;
-        }
-
-        public static bool IsBoolType(Type type)
-        {
-            return typeof(bool) == type;
-        }
-
-        public static bool IsIntType(Type type)
-        {
-            return typeof(int) == type;
-        }
-
-        public static bool IsLongType(Type type)
-        {
-            return typeof(long) == type;
-        }
-
-        public static bool IsFloatType(Type type)
-        {
-            return typeof(float) == type;
-        }
-
-        public static bool IsDoubleType(Type type)
-        {
-            return typeof(double) == type;
-        }
-
-        public static bool IsIntArrType(Type type)
-        {
-            return typeof(int[]) == type;
-        }
-
-        public static bool IsLongArrType(Type type)
-        {
-            return typeof(long[]) == type;
-        }
-
-        public static bool IsFloatArrType(Type type)
-        {
-            return typeof(float[]) == type;
-        }
-
-        public static bool IsDoubleArrType(Type type)
-        {
-            return typeof(double[]) == type;
-        }
-
-        public static bool IsStringArrType(Type type)
-        {
-            return typeof(string[]) == type;
-        }
-
-        public static bool IsObjectType(Type fieldType)
-        {
-            Type objecType = typeof(UnityEngine.Object);
-            if (fieldType == objecType || fieldType.IsSubclassOf(objecType))
-            {
-                return true;
-            }
-            return false;
-        }
-        public static bool IsObjectArrayType(Type fieldType)
-        {
-
-            if ( fieldType == typeof(UnityEngine.Object[]) || fieldType == typeof(GameObject[]) || fieldType == typeof(Material[]) ||
-                 fieldType == typeof(Texture[]) || fieldType == typeof(Texture2D[]) || fieldType == typeof(Texture3D[]) || 
-                 fieldType == typeof(Shader[]) || fieldType == typeof(AudioClip []) || fieldType == typeof(Sprite []))
-            {
-                return true;
-            }
-            return false;
-        }
-
-        public static bool IsConvertble(Type type)
-        {
-            return type == typeof(IConvertible);
-        }
-
-        public static bool IsAudioClipType(Type fieldType)
-        {
-            return fieldType == typeof(AudioClip);
-        }
-        public static bool IsMaterialType(Type fieldType)
-        {
-
-            return fieldType == typeof(Material);
-        }
-        public static bool IsGameObjectType(Type fieldType)
-        {
-
-            return fieldType == typeof(GameObject);
-        }
-        public static bool IsShaderType(Type fieldType)
-        {
-
-            return fieldType == typeof(Shader);
-        }
-        public static bool IsTextureType(Type fieldType)
-        {
-
-            return fieldType == typeof(Texture);
-        }
-        public static bool IsTexture2DType(Type fieldType)
-        {
-
-            return fieldType == typeof(Texture2D);
-        }
-        public static bool IsTexture3DType(Type fieldType)
-        {
-
-            return fieldType == typeof(Texture3D);
-        }
-        public static bool IsGameObjectArrayType(Type fieldType)
-        {
-            return fieldType == typeof(GameObject[]);
-        }
-        public static bool IsMaterialArrayType(Type fieldType)
-        {
-            return fieldType == typeof(Material[]);
-        }
-        public static bool IsTextureArrayType(Type fieldType)
-        {
-            return fieldType == typeof(Texture[]);
-        }
-        public static bool IsTexture2DArrayType(Type fieldType)
-        {
-            return fieldType == typeof(Texture2D[]);
-        }
-        public static bool IsTexture3DArrayType(Type fieldType)
-        {
-            return fieldType == typeof(Texture3D[]);
-        }
-        public static bool IsShaderArrayType(Type fieldType)
-        {
-            return fieldType == typeof(Shader[]);
-        }
-        public static bool IsAudioClipArrayType(Type fieldType)
-        {
-            return fieldType == typeof(AudioClip[]);
-        }
-        public static bool IsUnitConfigArrayType(Type fieldType)
-        {
-            return false;
-        }
-        public static bool IsSpriteArrayType(Type fieldType)
-        {
-            return fieldType == typeof(Sprite[]);
-        }
-        public static bool IsEnumType(Type fieldType)
-        {
-            Type enumType = typeof(Enum);
-            if (fieldType == enumType || fieldType.IsSubclassOf(enumType))
-            {
-                return true;
-            }
-            return false;
-        }
-
-        /// <summary>
-        /// Set Value
-        /// </summary>
-        /// <param nodeName="fieldName"></param>
-        /// <param nodeName="value"></param>
-        public void SetStrValue(string fieldName, string value)
-        {
-            if (this.ContainsKey(fieldName))
-            {
-                this[fieldName].StringValue = value;
-            }
-            else
-            {
-                ValueBase valueBase = new ValueBase();
-                valueBase.StringValue = value;
-                this.Add(fieldName, valueBase);
-            }
-        }
-
-        public void SetIntValue(string fieldName, int value)
-        {
-            if (this.ContainsKey(fieldName))
-            {
-                this[fieldName].Int32Value = value;
-            }
-            else
-            {
-                ValueBase valueBase = new ValueBase();
-                valueBase.Int32Value = value;
-                this.Add(fieldName, valueBase);
-            }
-        }
-
-        public void SetLongValue(string fieldName, long value)
-        {
-            if (this.ContainsKey(fieldName))
-            {
-                this[fieldName].Int64Value = value;
-            }
-            else
-            {
-                ValueBase valueBase = new ValueBase();
-                valueBase.Int64Value = value;
-                this.Add(fieldName, valueBase);
-            }
-        }
-
-        public void SetFloatValue(string fieldName, float value)
-        {
-            if (this.ContainsKey(fieldName))
-            {
-                this[fieldName].SingleValue = value;
-            }
-            else
-            {
-                ValueBase valueBase = new ValueBase();
-                valueBase.SingleValue = value;
-                this.Add(fieldName, valueBase);
-            }
-        }
-
-        public void SetDoubleValue(string fieldName, double value)
-        {
-            if (this.ContainsKey(fieldName))
-            {
-                this[fieldName].DoubleValue = value;
-            }
-            else
-            {
-                ValueBase valueBase = new ValueBase();
-                valueBase.DoubleValue = value;
-                this.Add(fieldName, valueBase);
-            }
-        }
-
-        public void SetBoolValue(string fieldName, bool value)
-        {
-            if (this.ContainsKey(fieldName))
-            {
-                this[fieldName].BooleanValue = value;
-            }
-            else
-            {
-                ValueBase valueBase = new ValueBase();
-                valueBase.BooleanValue = value;
-                this.Add(fieldName, valueBase);
-            }
-        }
-
-        public void SetStrArrValue(string fieldName, string[] value)
-        {
-            if (this.ContainsKey(fieldName))
-            {
-                this[fieldName].StringArray = value;
-            }
-            else
-            {
-                ValueBase valueBase = new ValueBase();
-                valueBase.StringArray = value;
-                this.Add(fieldName, valueBase);
-            }
-        }
-
-        public void SetIntArrValue(string fieldName, int[] value)
-        {
-            if (this.ContainsKey(fieldName))
-            {
-                this[fieldName].Int32Array = value;
-            }
-            else
-            {
-                ValueBase valueBase = new ValueBase();
-                valueBase.Int32Array = value;
-                this.Add(fieldName, valueBase);
-            }
-        }
-
-        public void SetLongArrValue(string fieldName, long[] value)
-        {
-            if (this.ContainsKey(fieldName))
-            {
-                this[fieldName].Int64Array = value;
-            }
-            else
-            {
-                ValueBase valueBase = new ValueBase();
-                valueBase.Int64Array = value;
-                this.Add(fieldName, valueBase);
-            }
-        }
-
-        public void SetFloatArrValue(string fieldName, float[] value)
-        {
-            if (this.ContainsKey(fieldName))
-            {
-                this[fieldName].SingleArray = value;
-            }
-            else
-            {
-                ValueBase valueBase = new ValueBase();
-                valueBase.SingleArray = value;
-                this.Add(fieldName, valueBase);
-            }
-        }
-
-        public void SetDoubleArrValue(string fieldName, double[] value)
-        {
-            if (this.ContainsKey(fieldName))
-            {
-                this[fieldName].DoubleArray = value;
-            }
-            else
-            {
-                ValueBase valueBase = new ValueBase();
-                valueBase.DoubleArray = value;
-                this.Add(fieldName, valueBase);
-            }
-        }
-
-        public void SetObjectValue(string fieldName,Type type, UnityEngine.Object value)
-        {
-            if (this.ContainsKey(fieldName))
-            {
-                this[fieldName]?.SetValueByType(type, value);
-            }
-            else
-            {
-                ValueBase valueBase = new ValueBase();
-                if (value != null)
-                {
-                    valueBase.SetValueByType(type, value);
-                }
-                this.Add(fieldName, valueBase);
-            }
-        }
-
-        public void SetEnumValue(string fieldName, string value)
-        {
-            if (this.ContainsKey(fieldName))
-            {
-                this[fieldName].enumValue = value;
-            }
-            else
-            {
-                ValueBase valueBase = new ValueBase();
-                valueBase.enumValue = value;
-                this.Add(fieldName, valueBase);
-            }
-        }
-        public void SetObjectArrayValue(string fieldName,Type type, UnityEngine.Object[] value)
-        {
-            if (this.ContainsKey(fieldName))
-            {
-                this[fieldName]?.SetValueByType(type, value);
-            }
-            else
-            {
-                ValueBase valueBase = new ValueBase();
-                if (value != null)
-                {
-                    valueBase.SetValueByType(type, value);
-                }
-                this.Add(fieldName, valueBase);
-            }
-        }
-
-        public static GameObject[] ConvertToGameObjectArray(UnityEngine.Object[] objectArray)
-        {
-            if (objectArray == null)
-            {
-                return null;
-            }
-            GameObject[] newObjectArray = new GameObject[objectArray.Length];
-            for (int i = 0; i < objectArray.Length; i++)
-            {
-                newObjectArray[i] =  (GameObject)objectArray[i];
-            }
-            return newObjectArray;
-        }
-        public static Material[] ConvertToMaterialArray(UnityEngine.Object[] objectArray)
-        {
-            if (objectArray == null)
-            {
-                return null;
-            }
-            Material[] newObjectArray = new Material[objectArray.Length];
-            for (int i = 0; i < objectArray.Length; i++)
-            {
-                newObjectArray[i] = (Material)objectArray[i];
-            }
-            return newObjectArray;
-        }
-        public static Texture[] ConvertToTextureArray(UnityEngine.Object[] objectArray)
-        {
-            if (objectArray == null)
-            {
-                return null;
-            }
-            Texture[] newObjectArray = new Texture[objectArray.Length];
-            for (int i = 0; i < objectArray.Length; i++)
-            {
-                newObjectArray[i] = (Texture)objectArray[i];
-            }
-            return newObjectArray;
-        }
-        public static Texture2D[] ConvertToTexture2DArray(UnityEngine.Object[] objectArray)
-        {
-            if (objectArray == null)
-            {
-                return null;
-            }
-            Texture2D[] newObjectArray = new Texture2D[objectArray.Length];
-            for (int i = 0; i < objectArray.Length; i++)
-            {
-                newObjectArray[i] = (Texture2D)objectArray[i];
-            }
-            return newObjectArray;
-        }
-        public static Texture3D[] ConvertToTexture3DArray(UnityEngine.Object[] objectArray)
-        {
-            if (objectArray == null)
-            {
-                return null;
-            }
-            Texture3D[] newObjectArray = new Texture3D[objectArray.Length];
-            for (int i = 0; i < objectArray.Length; i++)
-            {
-                newObjectArray[i] = (Texture3D)objectArray[i];
-            }
-            return newObjectArray;
-        }
-        public static Shader[] ConvertToShaderArray(UnityEngine.Object[] objectArray)
-        {
-            if (objectArray == null)
-            {
-                return null;
-            }
-            Shader[] newObjectArray = new Shader[objectArray.Length];
-            for (int i = 0; i < objectArray.Length; i++)
-            {
-                newObjectArray[i] = (Shader)objectArray[i];
-            }
-            return newObjectArray;
-        }
-        public static AudioClip[] ConvertToAudioClipArray(UnityEngine.Object[] objectArray)
-        {
-            if (objectArray == null)
-            {
-                return null;
-            }
-            AudioClip[] newObjectArray = new AudioClip[objectArray.Length];
-            for (int i = 0; i < objectArray.Length; i++)
-            {
-                newObjectArray[i] = (AudioClip)objectArray[i];
-            }
-            return newObjectArray;
-        }
-        public static Sprite [] ConvertToSpriteArray(UnityEngine.Object[] objectArray)
-        {
-            if (objectArray == null)
-            {
-                return null;
-            }
-            Sprite[] newObjectArray = new Sprite[objectArray.Length];
-            for (int i = 0; i < objectArray.Length; i++)
-            {
-                newObjectArray[i] = (Sprite)objectArray[i];
-            }
-            return newObjectArray;
-        }
-
-        public static bool SatisfyCondition(GameObject go, Type[] constraintTypes)
-        {
-            if (go == null || constraintTypes == null || constraintTypes.Length <= 0)
-            {
-                return true;
-            }
-            foreach (var constraint in constraintTypes)
-            {
-                if (go.GetComponent(constraint) == null)
-                {
-                    Log.Error($"此GameObject必须包含:{constraint}");
-                    return false;
-                }
-            }
-            return true;
-        }
-      
-    }
+	[Serializable]
+	public class BehaviorTreeArgsDict: Dictionary<string, ValueBase>
+	{
+		public void SetKeyValueComp(Type type, string fieldName, object value)
+		{
+			if (IsStringType(type))
+			{
+				SetStrValue(fieldName, (string) value);
+			}
+			else if (IsObjectType(type))
+			{
+				SetObjectValue(fieldName, type, (UnityEngine.Object) value);
+			}
+			else if (IsIntType(type))
+			{
+				int intValue = 0;
+				int.TryParse(value.ToString(), out intValue);
+				SetIntValue(fieldName, intValue);
+			}
+			else if (IsLongType(type))
+			{
+				long longValue = 0;
+				long.TryParse(value.ToString(), out longValue);
+				SetLongValue(fieldName, longValue);
+			}
+			else if (IsFloatType(type))
+			{
+				float floatValue = 0;
+				float.TryParse(value.ToString(), out floatValue);
+				SetFloatValue(fieldName, floatValue);
+			}
+			else if (IsDoubleType(type))
+			{
+				double doubleValue = 0;
+				double.TryParse(value.ToString(), out doubleValue);
+				SetDoubleValue(fieldName, doubleValue);
+			}
+			else if (IsBoolType(type))
+			{
+				bool boolValue = false;
+				bool.TryParse(value.ToString(), out boolValue);
+				SetBoolValue(fieldName, boolValue);
+			}
+			else if (IsStringArrType(type))
+			{
+				SetStrArrValue(fieldName, (string[]) value);
+			}
+			else if (IsIntArrType(type))
+			{
+				SetIntArrValue(fieldName, (int[]) value);
+			}
+			else if (IsLongArrType(type))
+			{
+				SetLongArrValue(fieldName, (long[]) value);
+			}
+			else if (IsFloatArrType(type))
+			{
+				SetFloatArrValue(fieldName, (float[]) value);
+			}
+			else if (IsDoubleArrType(type))
+			{
+				SetDoubleArrValue(fieldName, (double[]) value);
+			}
+			else if (IsEnumType(type))
+			{
+				SetEnumValue(fieldName, value.ToString());
+			}
+			else if (IsObjectArrayType(type))
+			{
+				SetObjectArrayValue(fieldName, type, (UnityEngine.Object[]) value);
+			}
+			else
+			{
+				Log.Error($"行为树节点暂时未支持此类型:{type}!");
+			}
+		}
+
+		private void SetConvertebleValue(string fieldName, float value)
+		{
+			if (this.ContainsKey(fieldName))
+			{
+				this[fieldName].Convertivle = value;
+			}
+			else
+			{
+				ValueBase valueBase = new ValueBase();
+				valueBase.Convertivle = value;
+				this.Add(fieldName, valueBase);
+			}
+		}
+
+		public object GetTreeDictValue(Type fieldType, string fieldName)
+		{
+			if (!this.ContainsKey(fieldName))
+			{
+				Log.Error($"fieldName:{fieldName} 不存在!!!!");
+				return null;
+			}
+			ValueBase obj = this[fieldName];
+			return obj.GetValueByType(fieldType);
+		}
+
+		/// <summary>
+		/// judge
+		/// </summary>
+		/// <param nodeName="type"></param>
+		/// <returns></returns>
+		public static bool IsStringType(Type type)
+		{
+			return typeof (string) == type;
+		}
+
+		public static bool IsBoolType(Type type)
+		{
+			return typeof (bool) == type;
+		}
+
+		public static bool IsIntType(Type type)
+		{
+			return typeof (int) == type;
+		}
+
+		public static bool IsLongType(Type type)
+		{
+			return typeof (long) == type;
+		}
+
+		public static bool IsFloatType(Type type)
+		{
+			return typeof (float) == type;
+		}
+
+		public static bool IsDoubleType(Type type)
+		{
+			return typeof (double) == type;
+		}
+
+		public static bool IsIntArrType(Type type)
+		{
+			return typeof (int[]) == type;
+		}
+
+		public static bool IsLongArrType(Type type)
+		{
+			return typeof (long[]) == type;
+		}
+
+		public static bool IsFloatArrType(Type type)
+		{
+			return typeof (float[]) == type;
+		}
+
+		public static bool IsDoubleArrType(Type type)
+		{
+			return typeof (double[]) == type;
+		}
+
+		public static bool IsStringArrType(Type type)
+		{
+			return typeof (string[]) == type;
+		}
+
+		public static bool IsObjectType(Type fieldType)
+		{
+			Type objecType = typeof (UnityEngine.Object);
+			if (fieldType == objecType || fieldType.IsSubclassOf(objecType))
+			{
+				return true;
+			}
+			return false;
+		}
+
+		public static bool IsObjectArrayType(Type fieldType)
+		{
+			if (fieldType == typeof (UnityEngine.Object[]) || fieldType == typeof (GameObject[]) || fieldType == typeof (Material[]) ||
+			    fieldType == typeof (Texture[]) || fieldType == typeof (Texture2D[]) || fieldType == typeof (Texture3D[]) || fieldType == typeof (Shader[]) ||
+			    fieldType == typeof (AudioClip[]) || fieldType == typeof (Sprite[]))
+			{
+				return true;
+			}
+			return false;
+		}
+
+		public static bool IsConvertble(Type type)
+		{
+			return type == typeof (IConvertible);
+		}
+
+		public static bool IsAudioClipType(Type fieldType)
+		{
+			return fieldType == typeof (AudioClip);
+		}
+
+		public static bool IsMaterialType(Type fieldType)
+		{
+			return fieldType == typeof (Material);
+		}
+
+		public static bool IsGameObjectType(Type fieldType)
+		{
+			return fieldType == typeof (GameObject);
+		}
+
+		public static bool IsShaderType(Type fieldType)
+		{
+			return fieldType == typeof (Shader);
+		}
+
+		public static bool IsTextureType(Type fieldType)
+		{
+			return fieldType == typeof (Texture);
+		}
+
+		public static bool IsTexture2DType(Type fieldType)
+		{
+			return fieldType == typeof (Texture2D);
+		}
+
+		public static bool IsTexture3DType(Type fieldType)
+		{
+			return fieldType == typeof (Texture3D);
+		}
+
+		public static bool IsGameObjectArrayType(Type fieldType)
+		{
+			return fieldType == typeof (GameObject[]);
+		}
+
+		public static bool IsMaterialArrayType(Type fieldType)
+		{
+			return fieldType == typeof (Material[]);
+		}
+
+		public static bool IsTextureArrayType(Type fieldType)
+		{
+			return fieldType == typeof (Texture[]);
+		}
+
+		public static bool IsTexture2DArrayType(Type fieldType)
+		{
+			return fieldType == typeof (Texture2D[]);
+		}
+
+		public static bool IsTexture3DArrayType(Type fieldType)
+		{
+			return fieldType == typeof (Texture3D[]);
+		}
+
+		public static bool IsShaderArrayType(Type fieldType)
+		{
+			return fieldType == typeof (Shader[]);
+		}
+
+		public static bool IsAudioClipArrayType(Type fieldType)
+		{
+			return fieldType == typeof (AudioClip[]);
+		}
+
+		public static bool IsUnitConfigArrayType(Type fieldType)
+		{
+			return false;
+		}
+
+		public static bool IsSpriteArrayType(Type fieldType)
+		{
+			return fieldType == typeof (Sprite[]);
+		}
+
+		public static bool IsEnumType(Type fieldType)
+		{
+			Type enumType = typeof (Enum);
+			if (fieldType == enumType || fieldType.IsSubclassOf(enumType))
+			{
+				return true;
+			}
+			return false;
+		}
+
+		/// <summary>
+		/// Set Value
+		/// </summary>
+		/// <param nodeName="fieldName"></param>
+		/// <param nodeName="value"></param>
+		public void SetStrValue(string fieldName, string value)
+		{
+			if (this.ContainsKey(fieldName))
+			{
+				this[fieldName].StringValue = value;
+			}
+			else
+			{
+				ValueBase valueBase = new ValueBase();
+				valueBase.StringValue = value;
+				this.Add(fieldName, valueBase);
+			}
+		}
+
+		public void SetIntValue(string fieldName, int value)
+		{
+			if (this.ContainsKey(fieldName))
+			{
+				this[fieldName].Int32Value = value;
+			}
+			else
+			{
+				ValueBase valueBase = new ValueBase();
+				valueBase.Int32Value = value;
+				this.Add(fieldName, valueBase);
+			}
+		}
+
+		public void SetLongValue(string fieldName, long value)
+		{
+			if (this.ContainsKey(fieldName))
+			{
+				this[fieldName].Int64Value = value;
+			}
+			else
+			{
+				ValueBase valueBase = new ValueBase();
+				valueBase.Int64Value = value;
+				this.Add(fieldName, valueBase);
+			}
+		}
+
+		public void SetFloatValue(string fieldName, float value)
+		{
+			if (this.ContainsKey(fieldName))
+			{
+				this[fieldName].SingleValue = value;
+			}
+			else
+			{
+				ValueBase valueBase = new ValueBase();
+				valueBase.SingleValue = value;
+				this.Add(fieldName, valueBase);
+			}
+		}
+
+		public void SetDoubleValue(string fieldName, double value)
+		{
+			if (this.ContainsKey(fieldName))
+			{
+				this[fieldName].DoubleValue = value;
+			}
+			else
+			{
+				ValueBase valueBase = new ValueBase();
+				valueBase.DoubleValue = value;
+				this.Add(fieldName, valueBase);
+			}
+		}
+
+		public void SetBoolValue(string fieldName, bool value)
+		{
+			if (this.ContainsKey(fieldName))
+			{
+				this[fieldName].BooleanValue = value;
+			}
+			else
+			{
+				ValueBase valueBase = new ValueBase();
+				valueBase.BooleanValue = value;
+				this.Add(fieldName, valueBase);
+			}
+		}
+
+		public void SetStrArrValue(string fieldName, string[] value)
+		{
+			if (this.ContainsKey(fieldName))
+			{
+				this[fieldName].StringArray = value;
+			}
+			else
+			{
+				ValueBase valueBase = new ValueBase();
+				valueBase.StringArray = value;
+				this.Add(fieldName, valueBase);
+			}
+		}
+
+		public void SetIntArrValue(string fieldName, int[] value)
+		{
+			if (this.ContainsKey(fieldName))
+			{
+				this[fieldName].Int32Array = value;
+			}
+			else
+			{
+				ValueBase valueBase = new ValueBase();
+				valueBase.Int32Array = value;
+				this.Add(fieldName, valueBase);
+			}
+		}
+
+		public void SetLongArrValue(string fieldName, long[] value)
+		{
+			if (this.ContainsKey(fieldName))
+			{
+				this[fieldName].Int64Array = value;
+			}
+			else
+			{
+				ValueBase valueBase = new ValueBase();
+				valueBase.Int64Array = value;
+				this.Add(fieldName, valueBase);
+			}
+		}
+
+		public void SetFloatArrValue(string fieldName, float[] value)
+		{
+			if (this.ContainsKey(fieldName))
+			{
+				this[fieldName].SingleArray = value;
+			}
+			else
+			{
+				ValueBase valueBase = new ValueBase();
+				valueBase.SingleArray = value;
+				this.Add(fieldName, valueBase);
+			}
+		}
+
+		public void SetDoubleArrValue(string fieldName, double[] value)
+		{
+			if (this.ContainsKey(fieldName))
+			{
+				this[fieldName].DoubleArray = value;
+			}
+			else
+			{
+				ValueBase valueBase = new ValueBase();
+				valueBase.DoubleArray = value;
+				this.Add(fieldName, valueBase);
+			}
+		}
+
+		public void SetObjectValue(string fieldName, Type type, UnityEngine.Object value)
+		{
+			if (this.ContainsKey(fieldName))
+			{
+				this[fieldName]?.SetValueByType(type, value);
+			}
+			else
+			{
+				ValueBase valueBase = new ValueBase();
+				if (value != null)
+				{
+					valueBase.SetValueByType(type, value);
+				}
+				this.Add(fieldName, valueBase);
+			}
+		}
+
+		public void SetEnumValue(string fieldName, string value)
+		{
+			if (this.ContainsKey(fieldName))
+			{
+				this[fieldName].enumValue = value;
+			}
+			else
+			{
+				ValueBase valueBase = new ValueBase();
+				valueBase.enumValue = value;
+				this.Add(fieldName, valueBase);
+			}
+		}
+
+		public void SetObjectArrayValue(string fieldName, Type type, UnityEngine.Object[] value)
+		{
+			if (this.ContainsKey(fieldName))
+			{
+				this[fieldName]?.SetValueByType(type, value);
+			}
+			else
+			{
+				ValueBase valueBase = new ValueBase();
+				if (value != null)
+				{
+					valueBase.SetValueByType(type, value);
+				}
+				this.Add(fieldName, valueBase);
+			}
+		}
+
+		public static GameObject[] ConvertToGameObjectArray(UnityEngine.Object[] objectArray)
+		{
+			if (objectArray == null)
+			{
+				return null;
+			}
+			GameObject[] newObjectArray = new GameObject[objectArray.Length];
+			for (int i = 0; i < objectArray.Length; i++)
+			{
+				newObjectArray[i] = (GameObject) objectArray[i];
+			}
+			return newObjectArray;
+		}
+
+		public static Material[] ConvertToMaterialArray(UnityEngine.Object[] objectArray)
+		{
+			if (objectArray == null)
+			{
+				return null;
+			}
+			Material[] newObjectArray = new Material[objectArray.Length];
+			for (int i = 0; i < objectArray.Length; i++)
+			{
+				newObjectArray[i] = (Material) objectArray[i];
+			}
+			return newObjectArray;
+		}
+
+		public static Texture[] ConvertToTextureArray(UnityEngine.Object[] objectArray)
+		{
+			if (objectArray == null)
+			{
+				return null;
+			}
+			Texture[] newObjectArray = new Texture[objectArray.Length];
+			for (int i = 0; i < objectArray.Length; i++)
+			{
+				newObjectArray[i] = (Texture) objectArray[i];
+			}
+			return newObjectArray;
+		}
+
+		public static Texture2D[] ConvertToTexture2DArray(UnityEngine.Object[] objectArray)
+		{
+			if (objectArray == null)
+			{
+				return null;
+			}
+			Texture2D[] newObjectArray = new Texture2D[objectArray.Length];
+			for (int i = 0; i < objectArray.Length; i++)
+			{
+				newObjectArray[i] = (Texture2D) objectArray[i];
+			}
+			return newObjectArray;
+		}
+
+		public static Texture3D[] ConvertToTexture3DArray(UnityEngine.Object[] objectArray)
+		{
+			if (objectArray == null)
+			{
+				return null;
+			}
+			Texture3D[] newObjectArray = new Texture3D[objectArray.Length];
+			for (int i = 0; i < objectArray.Length; i++)
+			{
+				newObjectArray[i] = (Texture3D) objectArray[i];
+			}
+			return newObjectArray;
+		}
+
+		public static Shader[] ConvertToShaderArray(UnityEngine.Object[] objectArray)
+		{
+			if (objectArray == null)
+			{
+				return null;
+			}
+			Shader[] newObjectArray = new Shader[objectArray.Length];
+			for (int i = 0; i < objectArray.Length; i++)
+			{
+				newObjectArray[i] = (Shader) objectArray[i];
+			}
+			return newObjectArray;
+		}
+
+		public static AudioClip[] ConvertToAudioClipArray(UnityEngine.Object[] objectArray)
+		{
+			if (objectArray == null)
+			{
+				return null;
+			}
+			AudioClip[] newObjectArray = new AudioClip[objectArray.Length];
+			for (int i = 0; i < objectArray.Length; i++)
+			{
+				newObjectArray[i] = (AudioClip) objectArray[i];
+			}
+			return newObjectArray;
+		}
+
+		public static Sprite[] ConvertToSpriteArray(UnityEngine.Object[] objectArray)
+		{
+			if (objectArray == null)
+			{
+				return null;
+			}
+			Sprite[] newObjectArray = new Sprite[objectArray.Length];
+			for (int i = 0; i < objectArray.Length; i++)
+			{
+				newObjectArray[i] = (Sprite) objectArray[i];
+			}
+			return newObjectArray;
+		}
+
+		public static bool SatisfyCondition(GameObject go, Type[] constraintTypes)
+		{
+			if (go == null || constraintTypes == null || constraintTypes.Length <= 0)
+			{
+				return true;
+			}
+			foreach (var constraint in constraintTypes)
+			{
+				if (go.GetComponent(constraint) == null)
+				{
+					Log.Error($"此GameObject必须包含:{constraint}");
+					return false;
+				}
+			}
+			return true;
+		}
+	}
 }

+ 35 - 18
Unity/Assets/Scripts/BehaviorTree/BehaviorTreeConfig.cs

@@ -1,23 +1,40 @@
 using UnityEngine;
-using System.Collections.Generic;
-using System;
 
 namespace Model
 {
-    public class BehaviorTreeConfig : MonoBehaviour
-    {
-        public  BehaviorNodeConfig RootNodeConfig;
-        private int mAutoId = 1;
-        public int AutoId{ get {return mAutoId++;}}
-        public int RootNodeId { get{ return RootNodeConfig == null ? 0 : RootNodeConfig.id; }}
-        public NodeProto RootNodeProto
-        {
-            get{ return RootNodeConfig == null ? null : RootNodeConfig.ToNodeProto();}
-        }
-        public void Clear()
-        {
-            DestroyImmediate(RootNodeConfig,true);
-            RootNodeConfig = null;
-        }
-    }
+	public class BehaviorTreeConfig: MonoBehaviour
+	{
+		public BehaviorNodeConfig RootNodeConfig;
+		private int mAutoId = 1;
+
+		public int AutoId
+		{
+			get
+			{
+				return mAutoId++;
+			}
+		}
+
+		public int RootNodeId
+		{
+			get
+			{
+				return RootNodeConfig == null? 0 : RootNodeConfig.id;
+			}
+		}
+
+		public NodeProto RootNodeProto
+		{
+			get
+			{
+				return RootNodeConfig == null? null : RootNodeConfig.ToNodeProto();
+			}
+		}
+
+		public void Clear()
+		{
+			DestroyImmediate(RootNodeConfig, true);
+			RootNodeConfig = null;
+		}
+	}
 }

+ 4 - 6
Unity/Assets/Scripts/BehaviorTree/BehaviorTreeType/BTTypeBaseComponent.cs

@@ -1,11 +1,9 @@
 using UnityEngine;
-using System.Collections.Generic;
-using System;
 
 namespace Model
 {
-    public class BTTypeBaseComponent : MonoBehaviour
-    {
-        public string fieldName;
-    }
+	public class BTTypeBaseComponent: MonoBehaviour
+	{
+		public string fieldName;
+	}
 }

+ 31 - 31
Unity/Assets/Scripts/BehaviorTree/BehaviorTreeType/BTTypeManager.cs

@@ -1,6 +1,6 @@
-using UnityEngine;
+using System;
 using System.Collections.Generic;
-using System;
+using UnityEngine;
 
 namespace Model
 {
@@ -8,34 +8,34 @@ namespace Model
 	{
 		public static Dictionary<Type, Type> BTTypeDict { get; } = new Dictionary<Type, Type>
 		{
-			{ typeof(int),          typeof(BTIntComponent)},
-			{ typeof(long),          typeof(BTInt64Component)},
-			{ typeof(string),       typeof(BTStringComponent)},
-			{ typeof(Enum),         typeof(BTEnumComponent)},
-			{ typeof(bool),         typeof(BTBoolComponent)},
-			{ typeof(float),        typeof(BTFloatComponent)},
-			{ typeof(double),       typeof(BTDoubleComponent)},
-			{ typeof(int[]),       typeof(BTArrayIntComponent)},
-			{ typeof(long[]),       typeof(BTArrayInt64Component)},
-			{ typeof(string[]),     typeof(BTArrayStringComponent)},
-			{ typeof(float[] ),     typeof(BTArrayFloatComponent)},
-			{ typeof(double[]),     typeof(BTArrayDoubleComponent)},
-			{ typeof(GameObject),   typeof(BTGameObjectComponent)},
-			{ typeof(AudioClip),    typeof(BTAudioClipComponent)},
-			{ typeof(Material),     typeof(BTMaterialComponent)},
-			{ typeof(Shader),       typeof(BTShaderComponent)},
-			{ typeof(Texture),      typeof(BTTextureComponent)},
-			{ typeof(Texture2D),    typeof(BTTexture2DComponent)},
-			{ typeof(Texture3D),    typeof(BTTexture3DComponent)},
-			{ typeof(Sprite),       typeof(BTSpriteComponent)},
-			{ typeof(GameObject[]), typeof(BTArrayGameObjectComponent)},
-			{ typeof(AudioClip[]),  typeof(BTArrayAudioClipComponent)},
-			{ typeof(Material[]),   typeof(BTArrayMaterialComponent)},
-			{ typeof(Shader[]),     typeof(BTArrayShaderComponent)},
-			{ typeof(Texture[]),    typeof(BTArrayTextureComponent)},
-			{ typeof(Texture2D[]),  typeof(BTArrayTexture2DComponent)},
-			{ typeof(Texture3D[]),  typeof(BTArrayTexture3DComponent)},
-			{ typeof(Sprite[]),     typeof(BTArraySpriteComponent)},
+			{ typeof (int), typeof (BTIntComponent) },
+			{ typeof (long), typeof (BTInt64Component) },
+			{ typeof (string), typeof (BTStringComponent) },
+			{ typeof (Enum), typeof (BTEnumComponent) },
+			{ typeof (bool), typeof (BTBoolComponent) },
+			{ typeof (float), typeof (BTFloatComponent) },
+			{ typeof (double), typeof (BTDoubleComponent) },
+			{ typeof (int[]), typeof (BTArrayIntComponent) },
+			{ typeof (long[]), typeof (BTArrayInt64Component) },
+			{ typeof (string[]), typeof (BTArrayStringComponent) },
+			{ typeof (float[]), typeof (BTArrayFloatComponent) },
+			{ typeof (double[]), typeof (BTArrayDoubleComponent) },
+			{ typeof (GameObject), typeof (BTGameObjectComponent) },
+			{ typeof (AudioClip), typeof (BTAudioClipComponent) },
+			{ typeof (Material), typeof (BTMaterialComponent) },
+			{ typeof (Shader), typeof (BTShaderComponent) },
+			{ typeof (Texture), typeof (BTTextureComponent) },
+			{ typeof (Texture2D), typeof (BTTexture2DComponent) },
+			{ typeof (Texture3D), typeof (BTTexture3DComponent) },
+			{ typeof (Sprite), typeof (BTSpriteComponent) },
+			{ typeof (GameObject[]), typeof (BTArrayGameObjectComponent) },
+			{ typeof (AudioClip[]), typeof (BTArrayAudioClipComponent) },
+			{ typeof (Material[]), typeof (BTArrayMaterialComponent) },
+			{ typeof (Shader[]), typeof (BTArrayShaderComponent) },
+			{ typeof (Texture[]), typeof (BTArrayTextureComponent) },
+			{ typeof (Texture2D[]), typeof (BTArrayTexture2DComponent) },
+			{ typeof (Texture3D[]), typeof (BTArrayTexture3DComponent) },
+			{ typeof (Sprite[]), typeof (BTArraySpriteComponent) }
 		};
 
 		public static Type GetBTType(string name)
@@ -51,7 +51,7 @@ namespace Model
 			{
 				if (BehaviorTreeArgsDict.IsEnumType(originType))
 				{
-					type = BTTypeDict[typeof(Enum)];
+					type = BTTypeDict[typeof (Enum)];
 				}
 				else
 				{

+ 4 - 4
Unity/Assets/Scripts/BehaviorTree/BehaviorTreeType/BaseType/BTArrayDoubleComponent.cs

@@ -1,7 +1,7 @@
 namespace Model
 {
-    public class BTArrayDoubleComponent : BTTypeBaseComponent
-    {
-        public double[] fieldValue;
-    }
+	public class BTArrayDoubleComponent: BTTypeBaseComponent
+	{
+		public double[] fieldValue;
+	}
 }

+ 4 - 4
Unity/Assets/Scripts/BehaviorTree/BehaviorTreeType/BaseType/BTArrayFloatComponent.cs

@@ -1,7 +1,7 @@
 namespace Model
 {
-    public class BTArrayFloatComponent : BTTypeBaseComponent
-    {
-        public float[] fieldValue;
-    }
+	public class BTArrayFloatComponent: BTTypeBaseComponent
+	{
+		public float[] fieldValue;
+	}
 }

+ 4 - 4
Unity/Assets/Scripts/BehaviorTree/BehaviorTreeType/BaseType/BTArrayInt64Component.cs

@@ -1,7 +1,7 @@
 namespace Model
 {
-    public class BTArrayInt64Component : BTTypeBaseComponent
-    {
-        public long[] fieldValue;
-    }
+	public class BTArrayInt64Component: BTTypeBaseComponent
+	{
+		public long[] fieldValue;
+	}
 }

+ 4 - 4
Unity/Assets/Scripts/BehaviorTree/BehaviorTreeType/BaseType/BTArrayIntComponent.cs

@@ -1,7 +1,7 @@
 namespace Model
 {
-    public class BTArrayIntComponent : BTTypeBaseComponent
-    {
-        public int[] fieldValue;
-    }
+	public class BTArrayIntComponent: BTTypeBaseComponent
+	{
+		public int[] fieldValue;
+	}
 }

+ 4 - 4
Unity/Assets/Scripts/BehaviorTree/BehaviorTreeType/BaseType/BTArrayStringComponent.cs

@@ -1,7 +1,7 @@
 namespace Model
 {
-    public class BTArrayStringComponent : BTTypeBaseComponent
-    {
-        public string[] fieldValue;
-    }
+	public class BTArrayStringComponent: BTTypeBaseComponent
+	{
+		public string[] fieldValue;
+	}
 }

+ 4 - 4
Unity/Assets/Scripts/BehaviorTree/BehaviorTreeType/BaseType/BTBoolComponent.cs

@@ -1,7 +1,7 @@
 namespace Model
 {
-    public class BTBoolComponent : BTTypeBaseComponent
-    {
-        public bool fieldValue;
-    }
+	public class BTBoolComponent: BTTypeBaseComponent
+	{
+		public bool fieldValue;
+	}
 }

+ 4 - 4
Unity/Assets/Scripts/BehaviorTree/BehaviorTreeType/BaseType/BTDoubleComponent.cs

@@ -1,7 +1,7 @@
 namespace Model
 {
-    public class BTDoubleComponent : BTTypeBaseComponent
-    {
-        public double fieldValue;
-    }
+	public class BTDoubleComponent: BTTypeBaseComponent
+	{
+		public double fieldValue;
+	}
 }

+ 5 - 6
Unity/Assets/Scripts/BehaviorTree/BehaviorTreeType/BaseType/BTEnumComponent.cs

@@ -1,8 +1,7 @@
-using System;
-namespace Model
+namespace Model
 {
-    public class BTEnumComponent : BTTypeBaseComponent
-    {
-        public string fieldValue;  // unity do not support enum Serialization
-    }
+	public class BTEnumComponent: BTTypeBaseComponent
+	{
+		public string fieldValue; // unity do not support enum Serialization
+	}
 }

+ 4 - 4
Unity/Assets/Scripts/BehaviorTree/BehaviorTreeType/BaseType/BTFloatComponent.cs

@@ -1,7 +1,7 @@
 namespace Model
 {
-    public class BTFloatComponent : BTTypeBaseComponent
-    {
-        public float fieldValue;
-    }
+	public class BTFloatComponent: BTTypeBaseComponent
+	{
+		public float fieldValue;
+	}
 }

+ 4 - 4
Unity/Assets/Scripts/BehaviorTree/BehaviorTreeType/BaseType/BTInt64Component.cs

@@ -1,7 +1,7 @@
 namespace Model
 {
-    public class BTInt64Component : BTTypeBaseComponent
-    {
-        public long fieldValue;
-    }
+	public class BTInt64Component: BTTypeBaseComponent
+	{
+		public long fieldValue;
+	}
 }

+ 4 - 4
Unity/Assets/Scripts/BehaviorTree/BehaviorTreeType/BaseType/BTIntComponent.cs

@@ -1,7 +1,7 @@
 namespace Model
 {
-    public class BTIntComponent : BTTypeBaseComponent
-    { 
-        public int fieldValue;
-    }
+	public class BTIntComponent: BTTypeBaseComponent
+	{
+		public int fieldValue;
+	}
 }

+ 4 - 4
Unity/Assets/Scripts/BehaviorTree/BehaviorTreeType/BaseType/BTStringComponent.cs

@@ -1,7 +1,7 @@
 namespace Model
 {
-    public class BTStringComponent : BTTypeBaseComponent
-    {
-        public string fieldValue;
-    }
+	public class BTStringComponent: BTTypeBaseComponent
+	{
+		public string fieldValue;
+	}
 }

+ 5 - 4
Unity/Assets/Scripts/BehaviorTree/BehaviorTreeType/UnityType/BTArrayAudioClipComponent.cs

@@ -1,8 +1,9 @@
 using UnityEngine;
+
 namespace Model
 {
-    public class BTArrayAudioClipComponent : BTTypeBaseComponent
-    {
-        public AudioClip [] fieldValue;
-    }
+	public class BTArrayAudioClipComponent: BTTypeBaseComponent
+	{
+		public AudioClip[] fieldValue;
+	}
 }

+ 5 - 4
Unity/Assets/Scripts/BehaviorTree/BehaviorTreeType/UnityType/BTArrayGameObjectComponent.cs

@@ -1,8 +1,9 @@
 using UnityEngine;
+
 namespace Model
 {
-    public class BTArrayGameObjectComponent : BTTypeBaseComponent
-    {
-        public GameObject[] fieldValue;
-    }
+	public class BTArrayGameObjectComponent: BTTypeBaseComponent
+	{
+		public GameObject[] fieldValue;
+	}
 }

+ 5 - 4
Unity/Assets/Scripts/BehaviorTree/BehaviorTreeType/UnityType/BTArrayMaterialComponent.cs

@@ -1,8 +1,9 @@
 using UnityEngine;
+
 namespace Model
 {
-    public class BTArrayMaterialComponent : BTTypeBaseComponent
-    {
-        public Material[] fieldValue;
-    }
+	public class BTArrayMaterialComponent: BTTypeBaseComponent
+	{
+		public Material[] fieldValue;
+	}
 }

+ 5 - 4
Unity/Assets/Scripts/BehaviorTree/BehaviorTreeType/UnityType/BTArrayShaderComponent.cs

@@ -1,8 +1,9 @@
 using UnityEngine;
+
 namespace Model
 {
-    public class BTArrayShaderComponent : BTTypeBaseComponent
-    {
-        public Shader[] fieldValue;
-    }
+	public class BTArrayShaderComponent: BTTypeBaseComponent
+	{
+		public Shader[] fieldValue;
+	}
 }

+ 5 - 4
Unity/Assets/Scripts/BehaviorTree/BehaviorTreeType/UnityType/BTArraySpriteComponent..cs

@@ -1,8 +1,9 @@
 using UnityEngine;
+
 namespace Model
 {
-    public class BTArraySpriteComponent : BTTypeBaseComponent
-    {
-        public Sprite[] fieldValue;
-    }
+	public class BTArraySpriteComponent: BTTypeBaseComponent
+	{
+		public Sprite[] fieldValue;
+	}
 }

+ 5 - 4
Unity/Assets/Scripts/BehaviorTree/BehaviorTreeType/UnityType/BTArrayTexture2DComponent..cs

@@ -1,8 +1,9 @@
 using UnityEngine;
+
 namespace Model
 {
-    public class BTArrayTexture2DComponent : BTTypeBaseComponent
-    {
-        public Texture2D[] fieldValue;
-    }
+	public class BTArrayTexture2DComponent: BTTypeBaseComponent
+	{
+		public Texture2D[] fieldValue;
+	}
 }

+ 5 - 4
Unity/Assets/Scripts/BehaviorTree/BehaviorTreeType/UnityType/BTArrayTexture3DComponent..cs

@@ -1,8 +1,9 @@
 using UnityEngine;
+
 namespace Model
 {
-    public class BTArrayTexture3DComponent : BTTypeBaseComponent
-    {
-        public Texture3D[] fieldValue;
-    }
+	public class BTArrayTexture3DComponent: BTTypeBaseComponent
+	{
+		public Texture3D[] fieldValue;
+	}
 }

+ 5 - 4
Unity/Assets/Scripts/BehaviorTree/BehaviorTreeType/UnityType/BTArrayTextureComponent.cs

@@ -1,8 +1,9 @@
 using UnityEngine;
+
 namespace Model
 {
-    public class BTArrayTextureComponent : BTTypeBaseComponent
-    {
-        public Texture[] fieldValue;
-    }
+	public class BTArrayTextureComponent: BTTypeBaseComponent
+	{
+		public Texture[] fieldValue;
+	}
 }

+ 5 - 4
Unity/Assets/Scripts/BehaviorTree/BehaviorTreeType/UnityType/BTAudioClipComponent.cs

@@ -1,8 +1,9 @@
 using UnityEngine;
+
 namespace Model
 {
-    public class BTAudioClipComponent : BTTypeBaseComponent
-    {
-        public AudioClip fieldValue;
-    }
+	public class BTAudioClipComponent: BTTypeBaseComponent
+	{
+		public AudioClip fieldValue;
+	}
 }

+ 5 - 4
Unity/Assets/Scripts/BehaviorTree/BehaviorTreeType/UnityType/BTGameObjectComponent.cs

@@ -1,8 +1,9 @@
 using UnityEngine;
+
 namespace Model
 {
-    public class BTGameObjectComponent : BTTypeBaseComponent
-    {
-        public GameObject fieldValue;
-    }
+	public class BTGameObjectComponent: BTTypeBaseComponent
+	{
+		public GameObject fieldValue;
+	}
 }

+ 5 - 4
Unity/Assets/Scripts/BehaviorTree/BehaviorTreeType/UnityType/BTMaterialComponent.cs

@@ -1,8 +1,9 @@
 using UnityEngine;
+
 namespace Model
 {
-    public class BTMaterialComponent : BTTypeBaseComponent
-    {
-        public Material fieldValue;
-    }
+	public class BTMaterialComponent: BTTypeBaseComponent
+	{
+		public Material fieldValue;
+	}
 }

+ 5 - 4
Unity/Assets/Scripts/BehaviorTree/BehaviorTreeType/UnityType/BTShaderComponent.cs

@@ -1,8 +1,9 @@
 using UnityEngine;
+
 namespace Model
 {
-    public class BTShaderComponent : BTTypeBaseComponent
-    {
-        public Shader fieldValue;
-    }
+	public class BTShaderComponent: BTTypeBaseComponent
+	{
+		public Shader fieldValue;
+	}
 }

+ 5 - 4
Unity/Assets/Scripts/BehaviorTree/BehaviorTreeType/UnityType/BTSpriteComponent.cs

@@ -1,8 +1,9 @@
 using UnityEngine;
+
 namespace Model
 {
-    public class BTSpriteComponent : BTTypeBaseComponent
-    {
-        public Sprite fieldValue;
-    }
+	public class BTSpriteComponent: BTTypeBaseComponent
+	{
+		public Sprite fieldValue;
+	}
 }

+ 5 - 4
Unity/Assets/Scripts/BehaviorTree/BehaviorTreeType/UnityType/BTTexture2DComponent.cs

@@ -1,8 +1,9 @@
 using UnityEngine;
+
 namespace Model
 {
-    public class BTTexture2DComponent : BTTypeBaseComponent
-    {
-        public Texture2D fieldValue;
-    }
+	public class BTTexture2DComponent: BTTypeBaseComponent
+	{
+		public Texture2D fieldValue;
+	}
 }

+ 5 - 4
Unity/Assets/Scripts/BehaviorTree/BehaviorTreeType/UnityType/BTTexture3DComponent.cs

@@ -1,8 +1,9 @@
 using UnityEngine;
+
 namespace Model
 {
-    public class BTTexture3DComponent : BTTypeBaseComponent
-    {
-        public Texture3D fieldValue;
-    }
+	public class BTTexture3DComponent: BTTypeBaseComponent
+	{
+		public Texture3D fieldValue;
+	}
 }

+ 5 - 4
Unity/Assets/Scripts/BehaviorTree/BehaviorTreeType/UnityType/BTTextureComponent.cs

@@ -1,8 +1,9 @@
 using UnityEngine;
+
 namespace Model
 {
-    public class BTTextureComponent : BTTypeBaseComponent
-    {
-        public Texture fieldValue;
-    }
+	public class BTTextureComponent: BTTypeBaseComponent
+	{
+		public Texture fieldValue;
+	}
 }

+ 35 - 36
Unity/Assets/Scripts/BehaviorTree/ClientNodeTypeProto.cs

@@ -1,46 +1,45 @@
 // 本文件由工具自动生成,请勿直接改动
-using MongoDB.Bson.Serialization.Attributes;
-using System.Collections.Generic;
-using MongoDB.Bson;
+
 using System;
+using System.Collections.Generic;
 
 namespace Model
 {
-    public class NodeFieldDesc
-    {
-        public Type type;
-        public string name;
-        public object value;
-        public string desc;
-        public Type attributeType;
-        public Type [] constraintTypes;
-        public Type envKeyType;
-    }
+	public class NodeFieldDesc
+	{
+		public Type type;
+		public string name;
+		public object value;
+		public string desc;
+		public Type attributeType;
+		public Type[] constraintTypes;
+		public Type envKeyType;
+	}
 
-    public class ClientNodeTypeProto: AConfig
+	public class ClientNodeTypeProto: AConfig
 	{
-	    public  string type = "";
-		public  string name = "";
+		public string type = "";
+		public string name = "";
 		//public  string show_name = "";
-		public  string describe = "";
-        public  string classify = "";
-        public  string style = "";
-		public  int child_limit = 0;
-		public  List<string> args_desc = new List<string>();
-        public  List<NodeFieldDesc> new_args_desc = new List<NodeFieldDesc>();
-        public  List<string> input_keys_desc = new List<string>();
-		public  List<string> output_keys_desc = new List<string>();
-        public  List<string> game_object_desc = new List<string>();
-        public bool isDeprecated;
-        public string deprecatedDesc;
+		public string describe = "";
+		public string classify = "";
+		public string style = "";
+		public int child_limit = 0;
+		public List<string> args_desc = new List<string>();
+		public List<NodeFieldDesc> new_args_desc = new List<NodeFieldDesc>();
+		public List<string> input_keys_desc = new List<string>();
+		public List<string> output_keys_desc = new List<string>();
+		public List<string> game_object_desc = new List<string>();
+		public bool isDeprecated;
+		public string deprecatedDesc;
 
-	    public ClientNodeTypeProto(): base(EntityType.Config)
-	    {
-	    }
+		public ClientNodeTypeProto(): base(EntityType.Config)
+		{
+		}
 
-	    public override string ToString()
-        {
-            return $"Type:{type}, Desc:{describe}";
-        }
-    }
-}
+		public override string ToString()
+		{
+			return $"Type:{type}, Desc:{describe}";
+		}
+	}
+}

+ 72 - 78
Unity/Assets/Scripts/BehaviorTree/Node.cs

@@ -1,96 +1,90 @@
-using System;
-using System.Collections.Generic;
+using System.Collections.Generic;
 
 namespace Model
 {
-    public abstract class Node
-    {
-        private readonly NodeProto nodeProto;
+	public abstract class Node
+	{
+		private long id;
 
-	    private long id;
-
-	    private string description;
+		private string description;
 
 		protected readonly List<Node> children = new List<Node>();
 
-        protected Node(NodeProto nodeProto)
-        {
-	        this.id = nodeProto.nodeId;
-	        this.description = nodeProto.describe;
-            this.nodeProto = nodeProto;
-        }
+		protected Node(NodeProto nodeProto)
+		{
+			this.id = nodeProto.nodeId;
+			this.description = nodeProto.describe;
+			this.NodeProto = nodeProto;
+		}
 
-        public Node[] GetChildren
-        {
-            get
-            {
-                return children.ToArray();
-            }
-        }
+		public Node[] GetChildren
+		{
+			get
+			{
+				return children.ToArray();
+			}
+		}
 
-        public NodeProto NodeProto
-        {
-            get { return nodeProto; }
-        }
+		public NodeProto NodeProto { get; }
 
-	    public string Description
-	    {
-		    get
-		    {
-			    return this.description;
-		    }
-		    set
-		    {
-			    this.description = value;
-		    }
-	    }
+		public string Description
+		{
+			get
+			{
+				return this.description;
+			}
+			set
+			{
+				this.description = value;
+			}
+		}
 
-        /// <summary>
-        /// 策划配置的id
-        /// </summary>
-        public long Id
-        {
-            get
-            {
-	            return this.id;
-            }
-	        set
-	        {
-		        this.id = value;
-	        }
-        }
+		/// <summary>
+		/// 策划配置的id
+		/// </summary>
+		public long Id
+		{
+			get
+			{
+				return this.id;
+			}
+			set
+			{
+				this.id = value;
+			}
+		}
+
+		/// <summary>
+		/// 节点的类型例如: NodeType.Not
+		/// </summary>
+		public string Type
+		{
+			get
+			{
+				return this.NodeProto.name;
+			}
+		}
 
-        /// <summary>
-        /// 节点的类型例如: NodeType.Not
-        /// </summary>
-        public string Type
-        {
-            get
-            {
-                return this.nodeProto.name;
-            }
-        }
-         
-        public void AddChild(Node child)
-        {
-            this.children.Add(child);
-        }
+		public void AddChild(Node child)
+		{
+			this.children.Add(child);
+		}
 
-	    public virtual void EndInit(Scene scene)
-	    {
-	    }
+		public virtual void EndInit(Scene scene)
+		{
+		}
 
-        public bool DoRun(BehaviorTree behaviorTree, BTEnv env)
-        {
-            if (!env.ContainKey(BTEnvKey.NodePath))
-            {
+		public bool DoRun(BehaviorTree behaviorTree, BTEnv env)
+		{
+			if (!env.ContainKey(BTEnvKey.NodePath))
+			{
 				env.Add(BTEnvKey.NodePath, new List<long>());
 			}
-     
-			env.Get<List<long>>(BTEnvKey.NodePath).Add(this.nodeProto.nodeId);
-            return this.Run(behaviorTree, env);
-        }
 
-	    protected abstract bool Run(BehaviorTree behaviorTree, BTEnv env);
-    }
+			env.Get<List<long>>(BTEnvKey.NodePath).Add(this.NodeProto.nodeId);
+			return this.Run(behaviorTree, env);
+		}
+
+		protected abstract bool Run(BehaviorTree behaviorTree, BTEnv env);
+	}
 }

+ 12 - 11
Unity/Assets/Scripts/BehaviorTree/NodeAttribute.cs

@@ -2,15 +2,16 @@
 
 namespace Model
 {
-    [AttributeUsage(AttributeTargets.Class)]
-    public class NodeAttribute : Attribute
-    {
-        public NodeClassifyType ClassifytType { get; private set; }
-        public string Desc { get; }
-        public NodeAttribute(NodeClassifyType classifyType,string desc = "")
-        {
-            this.ClassifytType = classifyType;
-            this.Desc = desc;
-        }
-    }
+	[AttributeUsage(AttributeTargets.Class)]
+	public class NodeAttribute: Attribute
+	{
+		public NodeClassifyType ClassifytType { get; private set; }
+		public string Desc { get; }
+
+		public NodeAttribute(NodeClassifyType classifyType, string desc = "")
+		{
+			this.ClassifytType = classifyType;
+			this.Desc = desc;
+		}
+	}
 }

+ 9 - 9
Unity/Assets/Scripts/BehaviorTree/NodeClassifyType.cs

@@ -1,12 +1,12 @@
 namespace Model
 {
-    public enum NodeClassifyType
-    {
-        Composite,
-        Decorator,
-        Action,
-        Condition,
-        Root,
-        DataTransform
-    }
+	public enum NodeClassifyType
+	{
+		Composite,
+		Decorator,
+		Action,
+		Condition,
+		Root,
+		DataTransform
+	}
 }

+ 10 - 9
Unity/Assets/Scripts/BehaviorTree/NodeDeprecatedAttribute.cs

@@ -2,13 +2,14 @@
 
 namespace Model
 {
-    [AttributeUsage(AttributeTargets.Class)]
-    public class NodeDeprecatedAttribute : Attribute
-    {
-        public string Desc { get; set; }
-        public NodeDeprecatedAttribute(string desc = "")   
-        {
-            Desc = desc;
-        }
-    }
+	[AttributeUsage(AttributeTargets.Class)]
+	public class NodeDeprecatedAttribute: Attribute
+	{
+		public string Desc { get; set; }
+
+		public NodeDeprecatedAttribute(string desc = "")
+		{
+			Desc = desc;
+		}
+	}
 }

+ 5 - 5
Unity/Assets/Scripts/BehaviorTree/NodeDesignerProto.cs

@@ -2,13 +2,13 @@ namespace Model
 {
 	public class NodeDesignerProto: AConfig
 	{
-        public string name;
-        public float x = 0;
-        public float y = 0;
-        public bool fold = false;
+		public string name;
+		public float x = 0;
+		public float y = 0;
+		public bool fold = false;
 
 		public NodeDesignerProto(): base(EntityType.Config)
 		{
 		}
 	}
-}
+}

+ 7 - 7
Unity/Assets/Scripts/BehaviorTree/NodeEngineObjectAttribute.cs

@@ -2,11 +2,11 @@
 
 namespace Model
 {
-    [AttributeUsage(AttributeTargets.Field)]
-    public class NodeEngineObjectAttribute : NodeFieldBaseAttribute
-    {
-        public NodeEngineObjectAttribute(string desc = "", object value = null) : base(desc, value)
-        {
-        }
-    }
+	[AttributeUsage(AttributeTargets.Field)]
+	public class NodeEngineObjectAttribute: NodeFieldBaseAttribute
+	{
+		public NodeEngineObjectAttribute(string desc = "", object value = null): base(desc, value)
+		{
+		}
+	}
 }

+ 14 - 13
Unity/Assets/Scripts/BehaviorTree/NodeFieldBaseAttribute.cs

@@ -2,17 +2,18 @@
 
 namespace Model
 {
-    [AttributeUsage(AttributeTargets.Field)]
-    public class NodeFieldBaseAttribute : Attribute
-    {
-        public Type envKeyType;
-        public string Desc { get; private set; }
-        public object DefaultValue { get; private set; }
-        public NodeFieldBaseAttribute(string desc = "", object value = null, Type _envKeyType = null)
-        {
-            this.Desc = desc;
-            this.DefaultValue = value;
-            this.envKeyType = _envKeyType;
-        }
-    }
+	[AttributeUsage(AttributeTargets.Field)]
+	public class NodeFieldBaseAttribute: Attribute
+	{
+		public Type envKeyType;
+		public string Desc { get; private set; }
+		public object DefaultValue { get; private set; }
+
+		public NodeFieldBaseAttribute(string desc = "", object value = null, Type _envKeyType = null)
+		{
+			this.Desc = desc;
+			this.DefaultValue = value;
+			this.envKeyType = _envKeyType;
+		}
+	}
 }

+ 10 - 9
Unity/Assets/Scripts/BehaviorTree/NodeFieldConstraintAttribute.cs

@@ -2,13 +2,14 @@
 
 namespace Model
 {
-    [AttributeUsage(AttributeTargets.Field)]
-    public class NodeFieldConstraintAttribute : Attribute
-    {
-        public Type [] Types { get; private set; }
-        public NodeFieldConstraintAttribute(params Type [] types)
-        {
-            this.Types = types;
-        }
-    }
+	[AttributeUsage(AttributeTargets.Field)]
+	public class NodeFieldConstraintAttribute: Attribute
+	{
+		public Type[] Types { get; private set; }
+
+		public NodeFieldConstraintAttribute(params Type[] types)
+		{
+			this.Types = types;
+		}
+	}
 }

+ 13 - 13
Unity/Assets/Scripts/BehaviorTree/NodeInputAttribute.cs

@@ -2,17 +2,17 @@
 
 namespace Model
 {
-    [AttributeUsage(AttributeTargets.Field)]
-    public class NodeInputAttribute : NodeFieldBaseAttribute
-    {
-        public NodeInputAttribute(string desc, Type _envKeyType) : base(desc, null, _envKeyType)
-        {
-//             if (_envKeyType == null)
-//             {
-//                 Log.Error($"{desc}_envKeyType can't be null");
-//                 return;
-//             }
-            this.envKeyType = _envKeyType;
-        }
-    }
+	[AttributeUsage(AttributeTargets.Field)]
+	public class NodeInputAttribute: NodeFieldBaseAttribute
+	{
+		public NodeInputAttribute(string desc, Type _envKeyType): base(desc, null, _envKeyType)
+		{
+			//             if (_envKeyType == null)
+			//             {
+			//                 Log.Error($"{desc}_envKeyType can't be null");
+			//                 return;
+			//             }
+			this.envKeyType = _envKeyType;
+		}
+	}
 }

+ 13 - 13
Unity/Assets/Scripts/BehaviorTree/NodeOutputAttribute.cs

@@ -2,17 +2,17 @@
 
 namespace Model
 {
-    [AttributeUsage(AttributeTargets.Field)]
-    public class NodeOutputAttribute : NodeFieldBaseAttribute
-    {
-        public NodeOutputAttribute(string desc, Type _envKeyType, string value = BTEnvKey.None) : base(desc, value, _envKeyType)
-        {
-//              if (_envKeyType == null)
-//              {
-//                 Log.Error($"_envKeyType can't be null");
-//                 return;
-//              }
-            envKeyType = _envKeyType;
-        }
-    }
+	[AttributeUsage(AttributeTargets.Field)]
+	public class NodeOutputAttribute: NodeFieldBaseAttribute
+	{
+		public NodeOutputAttribute(string desc, Type _envKeyType, string value = BTEnvKey.None): base(desc, value, _envKeyType)
+		{
+			//              if (_envKeyType == null)
+			//              {
+			//                 Log.Error($"_envKeyType can't be null");
+			//                 return;
+			//              }
+			envKeyType = _envKeyType;
+		}
+	}
 }

+ 7 - 7
Unity/Assets/Scripts/BehaviorTree/NodePropAttribute.cs

@@ -2,11 +2,11 @@
 
 namespace Model
 {
-    [AttributeUsage(AttributeTargets.Field)]
-    public class NodeFieldAttribute: NodeFieldBaseAttribute
-    {
-        public NodeFieldAttribute(string desc = "", object value = null): base(desc, value)
-        {
-        }
-    }
+	[AttributeUsage(AttributeTargets.Field)]
+	public class NodeFieldAttribute: NodeFieldBaseAttribute
+	{
+		public NodeFieldAttribute(string desc = "", object value = null): base(desc, value)
+		{
+		}
+	}
 }

+ 118 - 116
Unity/Assets/Scripts/BehaviorTree/NodeProto.cs

@@ -1,130 +1,132 @@
-using System.Collections.Generic;
-using System;
+using System;
+using System.Collections.Generic;
 using UnityEngine;
-using System.Reflection;
 
 namespace Model
 {
-    [Serializable]
-    public class StrValueBasePair
-    {
-        public string key;
-        public ValueBase value;
-    }
-    [Serializable] 
-    public class NodeProto : ISerializationCallbackReceiver
-    {
-        public int nodeId;
-     
-        public string name;
-     
-        public string describe = "";
+	[Serializable]
+	public class StrValueBasePair
+	{
+		public string key;
+		public ValueBase value;
+	}
 
-        public List<int> nodeIdList = new List<int>();
- 
-        public List<StrValueBasePair> args_list = new List<StrValueBasePair>();
+	[Serializable]
+	public class NodeProto: ISerializationCallbackReceiver
+	{
+		public int nodeId;
 
-        [NonSerialized]
-        public BehaviorTreeArgsDict args_dict = new BehaviorTreeArgsDict();
+		public string name;
 
-        [NonSerialized]
-        public List<NodeProto> children = new List<NodeProto>();
-         
-        public List<NodeProto> Children
-        {
-            get
-            {
-                return this.children;
-            }
-            set
-            {
-                this.children = value;
-            }
-        }
-         
-        public void SetValue<T>(string key,T value)
-        {
-            Type type = typeof(T);
-            object newValue = value;
-            if (type == typeof(Enum) || type.IsSubclassOf(typeof(Enum)))
-            {
-                type = typeof(string);
-                newValue = value.ToString();
-            }
-            int index = args_list.FindIndex(item => { return item.key == key; });
-            bool hasKey =  index != -1;
-            if (hasKey)
-            {
-                args_list[index].value.SetValueByType(typeof(T), newValue);
-            }
-            else
-            {
-                StrValueBasePair pair = new StrValueBasePair();
-                pair.key = key;
-                pair.value = new ValueBase();
-                pair.value.SetValueByType(typeof(T), newValue);
-                args_list.Add(pair);
-            }
-            if (!args_dict.ContainsKey(key))
-            {
-                args_dict.Add(key, new ValueBase());
-            }
-            args_dict[key].SetValueByType(typeof(T), newValue);
- 
-        }
-        public T GetValue<T>(string key)
-        {
-            T value = default(T);
-            foreach (var item in args_list)
-            {
-                if (item.key == key)
-                {
-                    value = (T)item.value.GetValueByType(typeof(T));
-                }
-            }
-            return value;
-        }
-        public void BuildChild(Dictionary<long, NodeProto> nodeDict)
-        {
-            this.children.Clear();
-            foreach (long nid in nodeIdList)
-            {
-                if (nodeDict.ContainsKey(nid))
-                {
-                    this.children.Add(nodeDict[nid]);
-                }
-            }
-            foreach (var child in this.children)
-            {
-                child.BuildChild(nodeDict);
-            }
-        }
-        public void OnAfterDeserialize()
-        {
-            this.args_dict.Clear();
-            foreach (var item in this.args_list)
-            {
-	            try
-	            {
-					this.args_dict.Add(item.key,item.value);
+		public string describe = "";
+
+		public List<int> nodeIdList = new List<int>();
+
+		public List<StrValueBasePair> args_list = new List<StrValueBasePair>();
+
+		[NonSerialized]
+		public BehaviorTreeArgsDict args_dict = new BehaviorTreeArgsDict();
+
+		[NonSerialized]
+		public List<NodeProto> children = new List<NodeProto>();
+
+		public List<NodeProto> Children
+		{
+			get
+			{
+				return this.children;
+			}
+			set
+			{
+				this.children = value;
+			}
+		}
+
+		public void SetValue<T>(string key, T value)
+		{
+			Type type = typeof (T);
+			object newValue = value;
+			if (type == typeof (Enum) || type.IsSubclassOf(typeof (Enum)))
+			{
+				type = typeof (string);
+				newValue = value.ToString();
+			}
+			int index = args_list.FindIndex(item => { return item.key == key; });
+			bool hasKey = index != -1;
+			if (hasKey)
+			{
+				args_list[index].value.SetValueByType(typeof (T), newValue);
+			}
+			else
+			{
+				StrValueBasePair pair = new StrValueBasePair();
+				pair.key = key;
+				pair.value = new ValueBase();
+				pair.value.SetValueByType(typeof (T), newValue);
+				args_list.Add(pair);
+			}
+			if (!args_dict.ContainsKey(key))
+			{
+				args_dict.Add(key, new ValueBase());
+			}
+			args_dict[key].SetValueByType(typeof (T), newValue);
+		}
+
+		public T GetValue<T>(string key)
+		{
+			T value = default(T);
+			foreach (var item in args_list)
+			{
+				if (item.key == key)
+				{
+					value = (T) item.value.GetValueByType(typeof (T));
+				}
+			}
+			return value;
+		}
+
+		public void BuildChild(Dictionary<long, NodeProto> nodeDict)
+		{
+			this.children.Clear();
+			foreach (long nid in nodeIdList)
+			{
+				if (nodeDict.ContainsKey(nid))
+				{
+					this.children.Add(nodeDict[nid]);
+				}
+			}
+			foreach (var child in this.children)
+			{
+				child.BuildChild(nodeDict);
+			}
+		}
+
+		public void OnAfterDeserialize()
+		{
+			this.args_dict.Clear();
+			foreach (var item in this.args_list)
+			{
+				try
+				{
+					this.args_dict.Add(item.key, item.value);
 				}
 				catch (Exception e)
 				{
 					throw new ConfigException($"key 已存在: {this.name} {this.nodeId} {item.key}", e);
 				}
 			}
-             
-        }
-        public void OnBeforeSerialize()
-        {
-            this.args_list.Clear();
-            foreach (var item in this.args_dict)
-            {
-                StrValueBasePair value = new StrValueBasePair();
-                value.key = item.Key;
-                value.value = item.Value;
-                this.args_list.Add(value);
-            }   
-        }
-    }
+		}
+
+		public void OnBeforeSerialize()
+		{
+			this.args_list.Clear();
+			foreach (var item in this.args_dict)
+			{
+				StrValueBasePair value = new StrValueBasePair();
+				value.key = item.Key;
+				value.value = item.Value;
+				this.args_list.Add(value);
+			}
+		}
+	}
 }

+ 181 - 182
Unity/Assets/Scripts/BehaviorTree/ValueBase.cs

@@ -1,193 +1,192 @@
 using System;
-using System.Collections.Generic;
 using System.Reflection;
 using UnityEngine;
 
 namespace Model
 {
-    [Serializable]
-    public class ValueBase
-    {
-        public IConvertible Convertivle;
-        public string enumValue;
-        public string StringValue;
-        public bool BooleanValue;
-        public int Int32Value;
-        public long Int64Value;
-        public float SingleValue;
-        public double DoubleValue;
-        public int[] Int32Array;
-        public long[] Int64Array;
-        public string[] StringArray;
-        public float[] SingleArray;
-        public double[] DoubleArray;
+	[Serializable]
+	public class ValueBase
+	{
+		public IConvertible Convertivle;
+		public string enumValue;
+		public string StringValue;
+		public bool BooleanValue;
+		public int Int32Value;
+		public long Int64Value;
+		public float SingleValue;
+		public double DoubleValue;
+		public int[] Int32Array;
+		public long[] Int64Array;
+		public string[] StringArray;
+		public float[] SingleArray;
+		public double[] DoubleArray;
 
-        public GameObject GameObjectValue;
-        public AudioClip AudioClipValue;
-        public Material MaterialValue;
-        public Shader ShaderValue;
-        public Texture TextureValue;
-        public Texture2D Texture2DValue;
-        public Texture3D Texture3DValue;
-        public Sprite SpriteValue;
+		public GameObject GameObjectValue;
+		public AudioClip AudioClipValue;
+		public Material MaterialValue;
+		public Shader ShaderValue;
+		public Texture TextureValue;
+		public Texture2D Texture2DValue;
+		public Texture3D Texture3DValue;
+		public Sprite SpriteValue;
 
-        public GameObject[] GameObjectArray;
-        public AudioClip[] AudioClipArray;
-        public Material[] MaterialArray;
-        public Shader[] ShaderArray;
-        public Texture [] TextureArray;
-        public Texture2D [] Texture2DArray;
-        public Texture3D [] Texture3DArray;
-        public Sprite [] SpriteArray;
-        public ValueBase()
-        {
-        }
+		public GameObject[] GameObjectArray;
+		public AudioClip[] AudioClipArray;
+		public Material[] MaterialArray;
+		public Shader[] ShaderArray;
+		public Texture[] TextureArray;
+		public Texture2D[] Texture2DArray;
+		public Texture3D[] Texture3DArray;
+		public Sprite[] SpriteArray;
 
-        public static ValueBase Clone(ValueBase source)
-        {
-            ValueBase v = new ValueBase();
-            FieldInfo[] infos = source.GetType().GetFields();
-            foreach (FieldInfo info in infos)
-            {
-                object value;
-                if (info.FieldType.IsSubclassOf(typeof(Array)))
-                {
-                    Array sourceArray = (Array)info.GetValue(source);
-                    if (sourceArray == null)
-                    {
-                        continue;
-                    }
-                    Array dest = Array.CreateInstance(info.FieldType.GetElementType(), sourceArray.Length);
-                    Array.Copy(sourceArray, dest, dest.Length);
-                    value = dest;
-                }
-                else
-                {
-                    value = info.GetValue(source);
-                }
-                info.SetValue(v, value);
-            }
-            return v;
-        }
+		public static ValueBase Clone(ValueBase source)
+		{
+			ValueBase v = new ValueBase();
+			FieldInfo[] infos = source.GetType().GetFields();
+			foreach (FieldInfo info in infos)
+			{
+				object value;
+				if (info.FieldType.IsSubclassOf(typeof (Array)))
+				{
+					Array sourceArray = (Array) info.GetValue(source);
+					if (sourceArray == null)
+					{
+						continue;
+					}
+					Array dest = Array.CreateInstance(info.FieldType.GetElementType(), sourceArray.Length);
+					Array.Copy(sourceArray, dest, dest.Length);
+					value = dest;
+				}
+				else
+				{
+					value = info.GetValue(source);
+				}
+				info.SetValue(v, value);
+			}
+			return v;
+		}
 
-        public object GetValueByType(Type type)
-        {
-            try
-            {
-                FieldInfo fieldInfo = GetFieldInfo(type);
-                if (BehaviorTreeArgsDict.IsEnumType(type))
-                {
-                    Enum value;
-                    if (string.IsNullOrEmpty(enumValue))
-                    {
-                        value = GetDefaultEnumValue(type);
-                    }
-                    else
-                    {
-                        value = (Enum)Enum.Parse(type, enumValue);
-                    }
-                    return value;
-                }
-                else if (BehaviorTreeArgsDict.IsStringType(type))
-                {
-                    if (string.IsNullOrEmpty(StringValue))
-                    {
-                        StringValue = enumValue;
-                        return StringValue;
-                    }
-                }
-                return fieldInfo.GetValue(this);
-            }
-            catch (Exception err)
-            {
-                throw new GameException($"行为树报错:{err}");
-            }
-        }
-        private Enum GetDefaultEnumValue(Type type)
-        {
-            Array array = Enum.GetValues(type);
-            Enum value = (Enum)array.GetValue(0);
-            return value;
-        }
-        public void SetValueByType(Type type,object value)
-        {
-            if (type == null)
-            {
-                return;
-            }
-            FieldInfo field = GetFieldInfo(type);
-            if (BehaviorTreeArgsDict.IsMaterialArrayType(field.FieldType))
-            {
-                field.SetValue(this, BehaviorTreeArgsDict.ConvertToMaterialArray((UnityEngine.Object [])value));
-            }
-            else if (BehaviorTreeArgsDict.IsGameObjectArrayType(field.FieldType))
-            {
-                field.SetValue(this, BehaviorTreeArgsDict.ConvertToGameObjectArray((UnityEngine.Object[])value));
-            }
-            else if (BehaviorTreeArgsDict.IsTextureArrayType(field.FieldType))
-            {
-                field.SetValue(this, BehaviorTreeArgsDict.ConvertToTextureArray((UnityEngine.Object[])value));
-            }
-            else if (BehaviorTreeArgsDict.IsTexture2DArrayType(field.FieldType))
-            {
-                field.SetValue(this, BehaviorTreeArgsDict.ConvertToTexture2DArray((UnityEngine.Object[])value));
-            }
-            else if (BehaviorTreeArgsDict.IsTexture3DArrayType(field.FieldType))
-            {
-                field.SetValue(this, BehaviorTreeArgsDict.ConvertToTexture3DArray((UnityEngine.Object[])value));
-            }
-            else if (BehaviorTreeArgsDict.IsShaderArrayType(field.FieldType))
-            {
-                field.SetValue(this, BehaviorTreeArgsDict.ConvertToShaderArray((UnityEngine.Object[])value));
-            }
-            else if (BehaviorTreeArgsDict.IsAudioClipArrayType(field.FieldType))
-            {
-                field.SetValue(this, BehaviorTreeArgsDict.ConvertToAudioClipArray((UnityEngine.Object[])value));
-            }
-            else if (BehaviorTreeArgsDict.IsSpriteArrayType(field.FieldType))
-            {
-                field.SetValue(this, BehaviorTreeArgsDict.ConvertToSpriteArray((UnityEngine.Object[])value));
-            }
-            else
-            {
-                field.SetValue(this, value);
-            }
-        }
+		public object GetValueByType(Type type)
+		{
+			try
+			{
+				FieldInfo fieldInfo = GetFieldInfo(type);
+				if (BehaviorTreeArgsDict.IsEnumType(type))
+				{
+					Enum value;
+					if (string.IsNullOrEmpty(enumValue))
+					{
+						value = GetDefaultEnumValue(type);
+					}
+					else
+					{
+						value = (Enum) Enum.Parse(type, enumValue);
+					}
+					return value;
+				}
+				if (BehaviorTreeArgsDict.IsStringType(type))
+				{
+					if (string.IsNullOrEmpty(this.StringValue))
+					{
+						this.StringValue = this.enumValue;
+						return this.StringValue;
+					}
+				}
+				return fieldInfo.GetValue(this);
+			}
+			catch (Exception err)
+			{
+				throw new GameException($"行为树报错:{err}");
+			}
+		}
 
-        private FieldInfo GetFieldInfo(Type type)
-        {
-            string fieldName;
-            if (BehaviorTreeArgsDict.IsEnumType(type))
-            {
-                fieldName = "enumValue";
-            }
-            else if (type.IsArray)
-            {
-                fieldName = type.GetElementType() + "Array";
-            }
-            else
-            {
-                fieldName = type.Name + "Value";
-            }
-            fieldName = RemovePrefix(fieldName);
-            FieldInfo fieldInfo = GetType().GetField(fieldName);
-            return fieldInfo;
-        }
-        private string RemovePrefix(string fieldName)
-        {
-            string enginePrefix = "UnityEngine.";
-            int engineIndex = fieldName.IndexOf(enginePrefix);
-            if (engineIndex != -1)
-            {
-                fieldName = fieldName.Remove(engineIndex, enginePrefix.Length);
-            }
-            string systemPrefix = "System.";
-            int systemIndex = fieldName.IndexOf(systemPrefix);
-            if (systemIndex != -1)
-            {
-                fieldName = fieldName.Remove(systemIndex, systemPrefix.Length);
-            }
-            return fieldName;
-        }
-    }
-}
+		private Enum GetDefaultEnumValue(Type type)
+		{
+			Array array = Enum.GetValues(type);
+			Enum value = (Enum) array.GetValue(0);
+			return value;
+		}
+
+		public void SetValueByType(Type type, object value)
+		{
+			if (type == null)
+			{
+				return;
+			}
+			FieldInfo field = GetFieldInfo(type);
+			if (BehaviorTreeArgsDict.IsMaterialArrayType(field.FieldType))
+			{
+				field.SetValue(this, BehaviorTreeArgsDict.ConvertToMaterialArray((UnityEngine.Object[]) value));
+			}
+			else if (BehaviorTreeArgsDict.IsGameObjectArrayType(field.FieldType))
+			{
+				field.SetValue(this, BehaviorTreeArgsDict.ConvertToGameObjectArray((UnityEngine.Object[]) value));
+			}
+			else if (BehaviorTreeArgsDict.IsTextureArrayType(field.FieldType))
+			{
+				field.SetValue(this, BehaviorTreeArgsDict.ConvertToTextureArray((UnityEngine.Object[]) value));
+			}
+			else if (BehaviorTreeArgsDict.IsTexture2DArrayType(field.FieldType))
+			{
+				field.SetValue(this, BehaviorTreeArgsDict.ConvertToTexture2DArray((UnityEngine.Object[]) value));
+			}
+			else if (BehaviorTreeArgsDict.IsTexture3DArrayType(field.FieldType))
+			{
+				field.SetValue(this, BehaviorTreeArgsDict.ConvertToTexture3DArray((UnityEngine.Object[]) value));
+			}
+			else if (BehaviorTreeArgsDict.IsShaderArrayType(field.FieldType))
+			{
+				field.SetValue(this, BehaviorTreeArgsDict.ConvertToShaderArray((UnityEngine.Object[]) value));
+			}
+			else if (BehaviorTreeArgsDict.IsAudioClipArrayType(field.FieldType))
+			{
+				field.SetValue(this, BehaviorTreeArgsDict.ConvertToAudioClipArray((UnityEngine.Object[]) value));
+			}
+			else if (BehaviorTreeArgsDict.IsSpriteArrayType(field.FieldType))
+			{
+				field.SetValue(this, BehaviorTreeArgsDict.ConvertToSpriteArray((UnityEngine.Object[]) value));
+			}
+			else
+			{
+				field.SetValue(this, value);
+			}
+		}
+
+		private FieldInfo GetFieldInfo(Type type)
+		{
+			string fieldName;
+			if (BehaviorTreeArgsDict.IsEnumType(type))
+			{
+				fieldName = "enumValue";
+			}
+			else if (type.IsArray)
+			{
+				fieldName = type.GetElementType() + "Array";
+			}
+			else
+			{
+				fieldName = type.Name + "Value";
+			}
+			fieldName = RemovePrefix(fieldName);
+			FieldInfo fieldInfo = GetType().GetField(fieldName);
+			return fieldInfo;
+		}
+
+		private string RemovePrefix(string fieldName)
+		{
+			string enginePrefix = "UnityEngine.";
+			int engineIndex = fieldName.IndexOf(enginePrefix);
+			if (engineIndex != -1)
+			{
+				fieldName = fieldName.Remove(engineIndex, enginePrefix.Length);
+			}
+			string systemPrefix = "System.";
+			int systemIndex = fieldName.IndexOf(systemPrefix);
+			if (systemIndex != -1)
+			{
+				fieldName = fieldName.Remove(systemIndex, systemPrefix.Length);
+			}
+			return fieldName;
+		}
+	}
+}

+ 2 - 2
Unity/Assets/Scripts/Component/BenchmarkComponent.cs

@@ -3,7 +3,7 @@ using Base;
 
 namespace Model
 {
-	public class BenchmarkComponent : Component
+	public class BenchmarkComponent: Component
 	{
 		private int k;
 
@@ -54,5 +54,5 @@ namespace Model
 
 			base.Dispose();
 		}
-    }
+	}
 }

+ 9 - 9
Unity/Assets/Scripts/Component/ChildrenComponent.cs

@@ -7,11 +7,11 @@ namespace Model
 	/// <summary>
 	/// 父子层级信息
 	/// </summary>
-    public class ChildrenComponent<T>: Component where T: Entity
-    {
+	public class ChildrenComponent<T>: Component where T : Entity
+	{
 		[BsonIgnore]
 		public T Parent { get; private set; }
-		
+
 		private readonly Dictionary<long, T> idChildren = new Dictionary<long, T>();
 
 		[BsonIgnore]
@@ -25,7 +25,7 @@ namespace Model
 
 		public void Add(T child)
 		{
-			child.GetComponent<ChildrenComponent<T>>().Parent = (T)this.Owner;
+			child.GetComponent<ChildrenComponent<T>>().Parent = (T) this.Owner;
 			this.idChildren.Add(child.Id, child);
 		}
 
@@ -73,26 +73,26 @@ namespace Model
 
 			this.Parent?.GetComponent<ChildrenComponent<T>>().Remove(this.Id);
 		}
-    }
+	}
 
 	public static class ChildrenHelper
 	{
-		public static void AddChild<T>(this T parent, T child) where T: Entity
+		public static void AddChild<T>(this T parent, T child) where T : Entity
 		{
 			parent.GetComponent<ChildrenComponent<T>>().Add(child);
 		}
 
-		public static void RemoveChild<T>(this T entity, long id) where T: Entity
+		public static void RemoveChild<T>(this T entity, long id) where T : Entity
 		{
 			entity.GetComponent<ChildrenComponent<T>>().Remove(id);
 		}
 
-		public static T GetChild<T>(this T entity, long id) where T: Entity
+		public static T GetChild<T>(this T entity, long id) where T : Entity
 		{
 			return entity.GetComponent<ChildrenComponent<T>>().Get(id);
 		}
 
-		public static T[] GetChildren<T>(this T entity) where T: Entity
+		public static T[] GetChildren<T>(this T entity) where T : Entity
 		{
 			return entity.GetComponent<ChildrenComponent<T>>().GetChildren();
 		}

+ 4 - 4
Unity/Assets/Scripts/Component/ClientConfigComponent.cs

@@ -3,9 +3,9 @@ using Base;
 
 namespace Model
 {
-	[EntityEvent(typeof(ClientConfigComponent))]
-	public class ClientConfigComponent : Component
-    {
+	[EntityEvent(typeof (ClientConfigComponent))]
+	public class ClientConfigComponent: Component
+	{
 		public StartConfig Config { get; private set; }
 
 		private void Awake()
@@ -25,5 +25,5 @@ namespace Model
 
 			this.Config.Dispose();
 		}
-    }
+	}
 }

+ 1 - 1
Unity/Assets/Scripts/Component/Config/ClientConfig.cs

@@ -17,4 +17,4 @@ namespace Model
 			}
 		}
 	}
-}
+}

+ 2 - 2
Unity/Assets/Scripts/Component/Config/InnerConfig.cs

@@ -3,7 +3,7 @@
 namespace Model
 {
 	[BsonIgnoreExtraElements]
-	public class InnerConfig : AConfigComponent
+	public class InnerConfig: AConfigComponent
 	{
 		public string Host { get; set; }
 		public int Port { get; set; }
@@ -17,4 +17,4 @@ namespace Model
 			}
 		}
 	}
-}
+}

+ 2 - 2
Unity/Assets/Scripts/Component/Config/OuterConfig.cs

@@ -3,7 +3,7 @@
 namespace Model
 {
 	[BsonIgnoreExtraElements]
-	public class OuterConfig : AConfigComponent
+	public class OuterConfig: AConfigComponent
 	{
 		public string Host { get; set; }
 		public int Port { get; set; }
@@ -17,4 +17,4 @@ namespace Model
 			}
 		}
 	}
-}
+}

+ 1 - 1
Unity/Assets/Scripts/Component/Config/RunServerConfig.cs

@@ -7,4 +7,4 @@ namespace Model
 	{
 		public string IP = "";
 	}
-}
+}

+ 0 - 1
Unity/Assets/Scripts/Component/ConfigComponent.cs

@@ -1,7 +1,6 @@
 using System;
 using System.Collections.Generic;
 using System.Reflection;
-using Base;
 
 namespace Model
 {

+ 31 - 30
Unity/Assets/Scripts/Component/EventComponent.cs

@@ -8,7 +8,7 @@ namespace Model
 	/// <summary>
 	/// 事件分发
 	/// </summary>
-	[EntityEvent(typeof(EventComponent))]
+	[EntityEvent(typeof (EventComponent))]
 	public class EventComponent: Component
 	{
 		private Dictionary<EventIdType, List<object>> allEvents;
@@ -27,11 +27,11 @@ namespace Model
 				Type[] types = assembly.GetTypes();
 				foreach (Type type in types)
 				{
-					object[] attrs = type.GetCustomAttributes(typeof(EventAttribute), false);
+					object[] attrs = type.GetCustomAttributes(typeof (EventAttribute), false);
 
 					foreach (object attr in attrs)
 					{
-						EventAttribute aEventAttribute = (EventAttribute)attr;
+						EventAttribute aEventAttribute = (EventAttribute) attr;
 
 						object obj = Activator.CreateInstance(type);
 						if (!this.allEvents.ContainsKey(aEventAttribute.Type))
@@ -200,31 +200,32 @@ namespace Model
 				}
 			}
 		}
-        public void Run<A, B, C, D, E,F>(EventIdType type, A a, B b, C c, D d, E e,F f)
-        {
-            List<object> iEvents = null;
-            if (!this.allEvents.TryGetValue(type, out iEvents))
-            {
-                return;
-            }
-
-            foreach (object obj in iEvents)
-            {
-                try
-                {
-                    var iEvent = obj as IEvent<A, B, C, D, E,F>;
-                    if (iEvent == null)
-                    {
-                        throw new Exception(
-                                $"event type: {type} is not IEvent<{typeof(A).Name}, {typeof(B).Name}, {typeof(C).Name}, {typeof(D).Name}, {typeof(E).Name}>");
-                    }
-                    iEvent.Run(a, b, c, d, e,f);
-                }
-                catch (Exception err)
-                {
-                    Log.Error(err.ToString());
-                }
-            }
-        }
-    }
+
+		public void Run<A, B, C, D, E, F>(EventIdType type, A a, B b, C c, D d, E e, F f)
+		{
+			List<object> iEvents = null;
+			if (!this.allEvents.TryGetValue(type, out iEvents))
+			{
+				return;
+			}
+
+			foreach (object obj in iEvents)
+			{
+				try
+				{
+					var iEvent = obj as IEvent<A, B, C, D, E, F>;
+					if (iEvent == null)
+					{
+						throw new Exception(
+								$"event type: {type} is not IEvent<{typeof (A).Name}, {typeof (B).Name}, {typeof (C).Name}, {typeof (D).Name}, {typeof (E).Name}>");
+					}
+					iEvent.Run(a, b, c, d, e, f);
+				}
+				catch (Exception err)
+				{
+					Log.Error(err.ToString());
+				}
+			}
+		}
+	}
 }

+ 4 - 4
Unity/Assets/Scripts/Component/GameObjectComponent.cs

@@ -2,14 +2,14 @@
 
 namespace Model
 {
-	[EntityEvent(typeof(GameObjectComponent))]
-	public class GameObjectComponent : Component
-    {
+	[EntityEvent(typeof (GameObjectComponent))]
+	public class GameObjectComponent: Component
+	{
 		public GameObject GameObject { get; private set; }
 
 		private void Awake(GameObject gameObject)
 		{
 			this.GameObject = gameObject;
 		}
-    }
+	}
 }

+ 6 - 7
Unity/Assets/Scripts/Component/KVComponent.cs

@@ -1,5 +1,4 @@
 using System.Collections.Generic;
-using Base;
 using MongoDB.Bson.Serialization.Attributes;
 
 namespace Model
@@ -7,16 +6,16 @@ namespace Model
 	/// <summary>
 	/// Key Value组件用于保存一些数据
 	/// </summary>
-    public class KVComponent : Component
-    {
+	public class KVComponent: Component
+	{
 		[BsonElement]
 		private readonly Dictionary<string, object> kv = new Dictionary<string, object>();
-		
+
 		public void Add(string key, object value)
 		{
 			this.kv.Add(key, value);
 		}
-		
+
 		public void Remove(string key)
 		{
 			this.kv.Remove(key);
@@ -29,7 +28,7 @@ namespace Model
 			{
 				return default(T);
 			}
-			return (T)k;
+			return (T) k;
 		}
 
 		public override void Dispose()
@@ -41,5 +40,5 @@ namespace Model
 
 			base.Dispose();
 		}
-    }
+	}
 }

+ 6 - 6
Unity/Assets/Scripts/Component/MessageDispatherComponent.cs

@@ -8,7 +8,7 @@ namespace Model
 	/// <summary>
 	/// 消息分发组件
 	/// </summary>
-	[EntityEvent(typeof(MessageDispatherComponent))]
+	[EntityEvent(typeof (MessageDispatherComponent))]
 	public class MessageDispatherComponent: Component
 	{
 		private AppType AppType;
@@ -35,13 +35,13 @@ namespace Model
 				Type[] types = assembly.GetTypes();
 				foreach (Type type in types)
 				{
-					object[] attrs = type.GetCustomAttributes(typeof(MessageAttribute), false);
+					object[] attrs = type.GetCustomAttributes(typeof (MessageAttribute), false);
 					if (attrs.Length == 0)
 					{
 						continue;
 					}
 
-					MessageAttribute messageAttribute = (MessageAttribute)attrs[0];
+					MessageAttribute messageAttribute = (MessageAttribute) attrs[0];
 					this.messageOpcode[type] = messageAttribute;
 					this.opcodeType[messageAttribute.Opcode] = type;
 				}
@@ -52,13 +52,13 @@ namespace Model
 				Type[] types = assembly.GetTypes();
 				foreach (Type type in types)
 				{
-					object[] attrs = type.GetCustomAttributes(typeof(MessageHandlerAttribute), false);
+					object[] attrs = type.GetCustomAttributes(typeof (MessageHandlerAttribute), false);
 					if (attrs.Length == 0)
 					{
 						continue;
 					}
 
-					MessageHandlerAttribute messageHandlerAttribute = (MessageHandlerAttribute)attrs[0];
+					MessageHandlerAttribute messageHandlerAttribute = (MessageHandlerAttribute) attrs[0];
 					if (!messageHandlerAttribute.Type.Is(this.AppType))
 					{
 						continue;
@@ -130,7 +130,7 @@ namespace Model
 				}
 			}
 		}
-		
+
 		public override void Dispose()
 		{
 			if (this.Id == 0)

+ 2 - 2
Unity/Assets/Scripts/Component/NetInnerComponent.cs

@@ -3,8 +3,8 @@ using Base;
 
 namespace Model
 {
-	[EntityEvent(typeof(NetInnerComponent))]
-	public class NetInnerComponent : NetworkComponent
+	[EntityEvent(typeof (NetInnerComponent))]
+	public class NetInnerComponent: NetworkComponent
 	{
 		private readonly Dictionary<string, Session> adressSessions = new Dictionary<string, Session>();
 

+ 2 - 2
Unity/Assets/Scripts/Component/NetOuterComponent.cs

@@ -2,8 +2,8 @@
 
 namespace Model
 {
-	[EntityEvent(typeof(NetOuterComponent))]
-	public class NetOuterComponent : NetworkComponent
+	[EntityEvent(typeof (NetOuterComponent))]
+	public class NetOuterComponent: NetworkComponent
 	{
 		private void Awake()
 		{

+ 1 - 2
Unity/Assets/Scripts/Component/NetworkComponent.cs

@@ -59,7 +59,6 @@ namespace Model
 
 		private async Task<Session> Accept()
 		{
-
 			AChannel channel = await this.Service.AcceptChannel();
 			Session session = new Session(this, channel);
 			channel.ErrorCallback += (c, e) => { this.Remove(session.Id); };
@@ -122,7 +121,7 @@ namespace Model
 			{
 				session.Dispose();
 			}
-			
+
 			this.Service.Dispose();
 		}
 	}

+ 15 - 14
Unity/Assets/Scripts/Component/ResourcesComponent.cs

@@ -3,6 +3,7 @@ using System.Collections.Generic;
 using UnityEngine;
 #if UNITY_EDITOR
 using UnityEditor;
+
 #endif
 
 namespace Model
@@ -17,10 +18,10 @@ namespace Model
 		private readonly Dictionary<string, AssetBundle> bundleCaches = new Dictionary<string, AssetBundle>();
 
 		public K GetUnitRefrenceById<K>(string unitId, EntityType entityType) where K : class
-        {
-            string assetBundleName = $"unit/{AssetBundleHelper.GetBundleNameById(unitId, entityType)}";
+		{
+			string assetBundleName = $"unit/{AssetBundleHelper.GetBundleNameById(unitId, entityType)}";
 			return GetAsset<K>(assetBundleName, unitId);
-        }
+		}
 
 		public K GetReference<K>(string bundle, string prefab, string key) where K : class
 		{
@@ -64,19 +65,19 @@ namespace Model
 			return resource as K;
 		}
 
-	    public override void Dispose()
-	    {
-		    if (this.Id == 0)
-		    {
-			    return;
-		    }
+		public override void Dispose()
+		{
+			if (this.Id == 0)
+			{
+				return;
+			}
 
-	        base.Dispose();
+			base.Dispose();
 
-	        foreach (var assetBundle in bundleCaches)
-	        {
-                assetBundle.Value?.Unload(true);
+			foreach (var assetBundle in bundleCaches)
+			{
+				assetBundle.Value?.Unload(true);
 			}
-        }
+		}
 	}
 }

+ 4 - 4
Unity/Assets/Scripts/Component/RobotComponent.cs

@@ -1,8 +1,8 @@
 namespace Model
 {
-	[EntityEvent(typeof(RobotComponent))]
-	public class RobotComponent : Component
-    {
+	[EntityEvent(typeof (RobotComponent))]
+	public class RobotComponent: Component
+	{
 		public override void Dispose()
 		{
 			if (this.Id == 0)
@@ -12,5 +12,5 @@
 
 			base.Dispose();
 		}
-    }
+	}
 }

+ 17 - 17
Unity/Assets/Scripts/Component/TimeComponent.cs

@@ -5,28 +5,28 @@ namespace Model
 	/// <summary>
 	/// 用于同步服务端和客户端时间
 	/// </summary>
-    public class TimeComponent : Component
-    {
+	public class TimeComponent: Component
+	{
 		private long syncTime;
 
-	    private long syncClientTime;
+		private long syncClientTime;
 
-	    public long SyncTime
-	    {
-		    get
-		    {
-			    return this.syncTime;
-		    }
-		    set
-		    {
-			    this.syncTime = value;
-			    this.syncClientTime = TimeHelper.ClientNow();
-		    }
-	    }
+		public long SyncTime
+		{
+			get
+			{
+				return this.syncTime;
+			}
+			set
+			{
+				this.syncTime = value;
+				this.syncClientTime = TimeHelper.ClientNow();
+			}
+		}
 
-	    public long Now()
+		public long Now()
 		{
 			return TimeHelper.ClientNow() - this.syncClientTime + syncTime;
 		}
-    }
+	}
 }

+ 5 - 21
Unity/Assets/Scripts/Component/TimerComponent.cs

@@ -12,7 +12,7 @@ namespace Model
 		public TaskCompletionSource<bool> tcs;
 	}
 
-	[EntityEvent(typeof(TimerComponent))]
+	[EntityEvent(typeof (TimerComponent))]
 	public class TimerComponent: Component
 	{
 		private readonly Dictionary<long, Timer> timers = new Dictionary<long, Timer>();
@@ -70,10 +70,7 @@ namespace Model
 			Timer timer = new Timer { Id = IdGenerater.GenerateId(), Time = tillTime, tcs = tcs };
 			this.timers[timer.Id] = timer;
 			this.timeId.Add(timer.Time, timer.Id);
-			cancellationToken.Register(() =>
-			{
-				this.Remove(timer.Id);
-			});
+			cancellationToken.Register(() => { this.Remove(timer.Id); });
 			return tcs.Task;
 		}
 
@@ -89,30 +86,17 @@ namespace Model
 		public Task WaitAsync(long time, CancellationToken cancellationToken)
 		{
 			TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>();
-			Timer timer = new Timer
-			{
-				Id = IdGenerater.GenerateId(),
-				Time = TimeHelper.Now() + time,
-				tcs = tcs
-			};
+			Timer timer = new Timer { Id = IdGenerater.GenerateId(), Time = TimeHelper.Now() + time, tcs = tcs };
 			this.timers[timer.Id] = timer;
 			this.timeId.Add(timer.Time, timer.Id);
-			cancellationToken.Register(() =>
-			{
-				this.Remove(timer.Id);
-			});
+			cancellationToken.Register(() => { this.Remove(timer.Id); });
 			return tcs.Task;
 		}
 
 		public Task WaitAsync(long time)
 		{
 			TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>();
-			Timer timer = new Timer
-			{
-				Id = IdGenerater.GenerateId(),
-				Time = TimeHelper.Now() + time,
-				tcs = tcs
-			};
+			Timer timer = new Timer { Id = IdGenerater.GenerateId(), Time = TimeHelper.Now() + time, tcs = tcs };
 			this.timers[timer.Id] = timer;
 			this.timeId.Add(timer.Time, timer.Id);
 			return tcs.Task;

+ 4 - 5
Unity/Assets/Scripts/Component/UIComponent.cs

@@ -2,7 +2,6 @@
 using System.Collections.Generic;
 using System.Linq;
 using System.Reflection;
-using Base;
 using UnityEngine;
 
 namespace Model
@@ -10,10 +9,10 @@ namespace Model
 	/// <summary>
 	/// 管理所有UI
 	/// </summary>
-	[EntityEvent(typeof(UIComponent))]
+	[EntityEvent(typeof (UIComponent))]
 	public class UIComponent: Component
 	{
-        private UI Root;
+		private UI Root;
 		private Dictionary<UIType, IUIFactory> UiTypes;
 		private readonly Dictionary<UIType, UI> uis = new Dictionary<UIType, UI>();
 
@@ -56,7 +55,7 @@ namespace Model
 				Type[] types = assembly.GetTypes();
 				foreach (Type type in types)
 				{
-					object[] attrs = type.GetCustomAttributes(typeof(UIFactoryAttribute), false);
+					object[] attrs = type.GetCustomAttributes(typeof (UIFactoryAttribute), false);
 					if (attrs.Length == 0)
 					{
 						continue;
@@ -120,7 +119,7 @@ namespace Model
 				ui.Dispose();
 			}
 		}
-		
+
 		public UI Get(UIType type)
 		{
 			UI ui;

+ 4 - 4
Unity/Assets/Scripts/Config/ACategory.cs

@@ -9,14 +9,14 @@ namespace Model
 	/// 管理该所有的配置
 	/// </summary>
 	/// <typeparam name="T"></typeparam>
-	public abstract class ACategory<T> : ICategory where T : AConfig
+	public abstract class ACategory<T>: ICategory where T : AConfig
 	{
 		protected Dictionary<long, T> dict;
 
 		public virtual void BeginInit()
 		{
 			this.dict = new Dictionary<long, T>();
-			
+
 			string configStr = ConfigHelper.GetText(typeof (T).Name);
 
 			foreach (string str in configStr.Split(new[] { "\n" }, StringSplitOptions.None))
@@ -42,7 +42,7 @@ namespace Model
 		{
 			get
 			{
-				return typeof(T);
+				return typeof (T);
 			}
 		}
 
@@ -57,7 +57,7 @@ namespace Model
 				T t;
 				if (!this.dict.TryGetValue(type, out t))
 				{
-					throw new KeyNotFoundException($"{typeof(T)} 没有找到配置, key: {type}");
+					throw new KeyNotFoundException($"{typeof (T)} 没有找到配置, key: {type}");
 				}
 				return t;
 			}

+ 3 - 3
Unity/Assets/Scripts/Config/AConfigComponent.cs

@@ -5,9 +5,9 @@ namespace Model
 	/// <summary>
 	/// 每个Config的基类
 	/// </summary>
-	[BsonKnownTypes(typeof(ClientConfig))]
-	[BsonKnownTypes(typeof(InnerConfig))]
-	[BsonKnownTypes(typeof(OuterConfig))]
+	[BsonKnownTypes(typeof (ClientConfig))]
+	[BsonKnownTypes(typeof (InnerConfig))]
+	[BsonKnownTypes(typeof (OuterConfig))]
 	public abstract class AConfigComponent: Component
 	{
 	}

+ 2 - 2
Unity/Assets/Scripts/Config/ConfigHelper.cs

@@ -9,7 +9,7 @@ namespace Model
 		{
 			try
 			{
-				string configStr = ((GameObject)Resources.Load("Config")).Get<TextAsset>(key).text;
+				string configStr = ((GameObject) Resources.Load("Config")).Get<TextAsset>(key).text;
 				return configStr;
 			}
 			catch (Exception)
@@ -18,4 +18,4 @@ namespace Model
 			}
 		}
 	}
-}
+}

Некоторые файлы не были показаны из-за большого количества измененных файлов