private void DrawUIForAddingNodes() { //draw buttons for adding and subtracting the behavior list sequence: GUILayout.BeginHorizontal(); var sceneNodeTypesList = Assembly .GetAssembly(typeof(BehaviorNode)) .GetTypes() .Where(t => t.IsSubclassOf(typeof(BehaviorNode))).ToArray(); var sceneNodeTypesnames = sceneNodeTypesList.Select((t) => t.Name).ToArray(); typeIndex = EditorGUILayout.Popup("Type of node: ", typeIndex, sceneNodeTypesnames); if (GUILayout.Button("Add Node", GUILayout.Width(100))) { var config = GetBehaviorNodeSystemConfiguration(); if (config == null) { Debug.LogError("Could not find an editor config for BehviorNodeSystem."); return; } var assetCreator = new BehaviorNodeAssetCreator(config.GetPathToSaveNodeLists()); var newNode = assetCreator.CreateNodeAsset(behaviorListHolder.nodeListAsset, sceneNodeTypesList[typeIndex]); behaviorListHolder.nodeListAsset.list.Add(newNode); EditorUtility.SetDirty(behaviorListHolder); AssetDatabase.SaveAssets(); } GUILayout.EndHorizontal(); }
void CreateBehaviorListAsset() { var config = GetBehaviorNodeSystemConfiguration(); if (config == null) { Debug.LogError("Could not find an editor config for BehviorNodeSystem."); return; } var assetCreator = new BehaviorNodeAssetCreator(config.GetPathToSaveNodeLists()); behaviorListHolder.nodeListAsset = assetCreator.CreateNodeListAsset(); }
static void CreateNewBehaviorListAsset() { var config = GetBehaviorNodeSystemConfiguration(); if (config == null) { Debug.LogError("Could not find an editor config for BehviorNodeSystem."); return; } var assetCreator = new BehaviorNodeAssetCreator(config.GetPathToSaveNodeLists()); EditorGUIUtility.PingObject(assetCreator.CreateNodeListAsset()); }