コード例 #1
0
		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;
		}
コード例 #2
0
 public void SetRoot(BaseRoot root)
 {
     rootNode = root;
 }