public static void CreateNewBehaviorTree(MenuCommand menuCommand)
		{
			string path = AssetDatabase.GetAssetPath(Selection.activeObject);
			if (path == "") path = "Assets";
			else if (Path.GetExtension(path) != "")
			{
				path = path.Replace(Path.GetFileName(
					AssetDatabase.GetAssetPath(Selection.activeObject)), "");
			}

			string fullPath = AssetDatabase.GenerateUniqueAssetPath(path + "/New Behavior Tree.asset");

			BehaviorTree bt = ScriptableObject.CreateInstance<BehaviorTree>();
			// Add base root
			BaseRoot baseRoot = ScriptableObject.CreateInstance<BaseRoot>();
			baseRoot.editorPosition = new Vector2(0, 0);
			bt.SetRoot(baseRoot);
			// Add root
			Root root = ScriptableObject.CreateInstance<Root>();
			root.editorPosition = new Vector2(0, 96);
			baseRoot.ConnectChild(root);

			BTAsset btAsset = ScriptableObject.CreateInstance<BTAsset>();
			btAsset.Serialize(bt);

			AssetDatabase.CreateAsset(btAsset, fullPath);
			AssetDatabase.Refresh();
			// EditorUtility.FocusProjectWindow();
			Selection.activeObject = btAsset;
		}
Exemple #2
0
        void OnEnable()
        {
            BTAsset btAsset = serializedObject.targetObject as BTAsset;

            BTEditorManager.RefreshNodeTypes();
            BTEditorManager.Refresh(btAsset);
        }
        /// <summary>
        /// 刷新当前界面显示资源
        /// </summary>
        /// <param name="bt"></param>
        /// <param name="asset"></param>
        public static void Refresh(BTAsset asset)
        {
            SelectAsset = asset;
            asset.Deserialize();
            SelectTree.RefreshDebugID();

            if (onDisplayChanged != null)
            {
                onDisplayChanged();
            }
        }