Esempio n. 1
0
 GenericMenu.MenuFunction AddTransition(FSMState state, FSMPredicate p)
 {
     return(() =>
     {
         Undo.RegisterCompleteObjectUndo(target, "Add Transition");
         var t = new FSMTransition();
         t.predicate.guid = p.guid;
         state.transitions.Add(t);
     });
 }
Esempio n. 2
0
        void ShowTransitionMenu(FSMState state)
        {
            var menu = new GenericMenu();

            menu.AddItem(new GUIContent("New Transition"), false, () =>
            {
                Undo.RecordObject(target, "New Transition");
                var p = new FSMPredicate()
                {
                    guid = target.NextGUID()
                };
                target.predicates.Insert(0, p);
                var t            = new FSMTransition();
                t.predicate.guid = p.guid;
                state.transitions.Add(t);
                OpenPredicateEditor(state.backgroundRect, state, p.guid);
            });
            foreach (var p in target.predicates)
            {
                menu.AddItem(new GUIContent($"Add Transition/{p.predicateName}"), false, AddTransition(state, p));
            }
            menu.ShowAsContext();
        }