Beispiel #1
0
 void NoneCallback(object handle)
 {
     switch (handle.ToString())
     {
     case "StateNode":
         XBehaviorEditor.GetInstance().AddState();
         break;
     }
 }
 public override void OnXGUI()
 {
     DoButton("Open In Fsm Editor", () => XBehaviorEditor.GetInstance().FSM = (XBehaviorFSM)target);
 }
Beispiel #3
0
        public void DrawEvents()
        {
            // draw event


            bool isFix = false;             //  GUILayoutUtility.GetRect(20,20) DeEquals Rect(20,20) at First time

            for (int pos = 0; pos < state.events.Count; pos++)
            {
                //  TODO loop in state.events.Count
                BeginHorizontal();
                if (CreateSpaceButton(state.events[pos].name))
                {
                    if (eventID == pos)
                    {
                        eventID = -1;
                        XBehaviorEditor.GetInstance().ClearTransition();
                    }
                    else
                    {
                        eventID = pos;
                    }
                }

                GUIStyle style = GUI.skin.horizontalSliderThumb;


                if (GUILayout.Button("", style))
                {
                    // selected joint node

                    if (eventID == pos)
                    {
                        eventID = -1;
                        XBehaviorEditor.GetInstance().ClearTransition();
                    }
                    else
                    {
                        eventID = pos;
                        XBehaviorEditor.GetInstance().SetBehaviorEvent(state.events[pos]);
                    }
                }


                if (jointRects.Count <= pos)
                {
                    jointRects.Add(new Rect());
                }
                jointRects[pos] = GUILayoutUtility.GetLastRect();

                if (eventID == pos && jointRects.Count > pos)
                {
                    EndHorizontal();
                    EditorGUI.DrawRect(jointRects[pos], Color.black);

                    BeginHorizontal();
                    state.events[pos].name = CreateStringField(state.events[pos].name);

                    if (CreateSpaceButton("Delete"))
                    {
                        state.events.RemoveAt(pos);
                        state.events.TrimExcess();
                        jointRects.RemoveAt(pos);
                        jointRects.TrimExcess();
                        eventID = -1;
                        return;
                    }
                }
                EndHorizontal();
            }
        }