GenericMenu.MenuFunction SetActionRef(ActionReference actionRef, int guid) { return(() => { Undo.RegisterCompleteObjectUndo(target, "Set Action"); actionRef.guid = guid; }); }
public void Load(FiniteStateMachine target, FSMState state, ActionReference actionRef) { var serializedObject = new SerializedObject(target); var actions = serializedObject.FindProperty("actions"); for (var i = 0; i < actions.arraySize; i++) { var p = actions.GetArrayElementAtIndex(i); if (p.FindPropertyRelative("guid").intValue == actionRef.guid) { property = p; break; } } }
void ShowContextMenu(FSMState state, ActionReference actionRef) { var menu = new GenericMenu(); menu.AddItem(new GUIContent("Edit"), false, () => { var w = GetWindow <ActionEditorWindow>(); w.ShowUtility(); w.Load(target, state, actionRef); }); menu.AddItem(new GUIContent("Delete"), false, () => { Undo.RegisterCompleteObjectUndo(target, "Remove Action"); actionRef.guid = 0; }); menu.AddSeparator(""); menu.AddItem(new GUIContent("Enabled?"), actionRef.enabled, () => { Undo.RegisterCompleteObjectUndo(target, "Toggle Action"); actionRef.enabled = !actionRef.enabled; }); menu.ShowAsContext(); }