Пример #1
0
 GenericMenu.MenuFunction SetActionRef(ActionReference actionRef, int guid)
 {
     return(() =>
     {
         Undo.RegisterCompleteObjectUndo(target, "Set Action");
         actionRef.guid = guid;
     });
 }
Пример #2
0
        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;
                }
            }
        }
Пример #3
0
        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();
        }