示例#1
0
        //create state editor and its state
        public static StateEditor CreateState(StateMachineEditor sm, Vector2 position)
        {
            StateEditor stateEd = CreateInstance <StateEditor>();

            stateEd.sm   = sm;
            stateEd.name = "New State Editor";
            sm.Add(stateEd);
            stateEd.state = CreateInstance <State>();
            AssetDatabase.AddObjectToAsset(stateEd.state, sm.stateMachine);
            stateEd.state.name = "New State";
            stateEd.back       = new List <SMElementEditor>();
            stateEd.next       = new List <SMElementEditor>();
            stateEd.position   = position;
            return(stateEd);
        }
        private void SMField()
        {
            GUI.backgroundColor = fieldColor;
            StateMachine smo = (StateMachine)EditorGUILayout.ObjectField("SM", sm ? sm.stateMachine : null, typeof(StateMachine), false);

            if (!smo)
            {
                sm = null;
            }
            else if (!sm || smo != sm.stateMachine)
            {
                sm = StateMachineEditor.GetCreateEditor(smo);
                varHandleEditor = Editor.CreateEditor(sm.varHandleEd);
            }
        }
示例#3
0
        private void SMField()
        {
            GUI.backgroundColor = fieldColor;
            StateMachine smo = (StateMachine)EditorGUILayout.ObjectField("SM", sm ? sm.stateMachine : null, typeof(StateMachine), false);

            if (smo && (!sm || smo != sm.stateMachine))
            {
                sm = null;

                foreach (var sme in Resources.FindObjectsOfTypeAll <StateMachineEditor>())
                {
                    if (sme.stateMachine == smo)
                    {
                        sm = sme; break;
                    }
                }

                if (sm == null)
                {
                    sm = StateMachineEditor.CreateEditor(smo);
                }
            }
        }