static void AddActionWindow() { if (editingEvent == null) { addActionClicked = false; Debug.LogWarning("The event you are trying to add to is null"); } else if (editingEvent.eventName == null) { addActionClicked = false; Debug.LogWarning("The event you are trying to add to is null"); } GUILayout.Label("Add Action", "boldLabel"); List <string> options = new List <string>(); List <System.Type> types = ActionTracker.FindActions(); foreach (System.Type type in types) { options.Add(type.Name); } selectedNewAction = EditorGUILayout.Popup("Action to Add", selectedNewAction, options.ToArray()); GUILayout.BeginHorizontal(); if (GUILayout.Button("Cancel")) { addActionClicked = false; } if (GUILayout.Button("Add Action")) { addActionClicked = false; Action newAction = null; //TODO: automatically create the object? newAction = (Action)AssetDatabase.LoadAssetAtPath(EventSaver.TOOL_DATA_DIR + options[selectedNewAction] + ".asset", typeof(ScriptableObject)); if (newAction == null) { Debug.LogError("Could not load asset at: " + EventSaver.TOOL_DATA_DIR + options[selectedNewAction]); } newAction = ScriptableObject.Instantiate(newAction);//DISCUSS: memory leak or auto-collected? editingEvent.AddAction(newAction); Debug.Log("Created Action: " + newAction.ToString()); EventSaver.SaveEventAsObject(editingEvent); } GUILayout.EndHorizontal(); }
public static void CreateEvent(string _name) { // make sure to save old, shouldn't be neccessary anymore if (editingEvent != null) { if (editingEvent.eventName != null) { EventSaver.SaveEventAsObject(editingEvent); } } editingEvent = ScriptableObject.CreateInstance <SpellCreator.Event>(); editingEvent.eventName = _name; EventSaver.SaveEventAsObject(editingEvent); createEventText = ""; //FIX Make the new event the selected event }