示例#1
0
 private void SelectGameObject()
 {
     if (GUILayout.Button(FsmEditor.ActiveGameObject != null?FsmEditor.ActiveGameObject.name:"[None Selected]", EditorStyles.toolbarDropDown, GUILayout.Width(100)))
     {
         GenericMenu           toolsMenu  = new GenericMenu();
         List <ICodeBehaviour> behaviours = FsmEditorUtility.FindInScene <ICodeBehaviour>();
         foreach (ICodeBehaviour behaviour in behaviours)
         {
             GameObject mGameObject = behaviour.gameObject;
             toolsMenu.AddItem(new GUIContent(behaviour.name), false, delegate() {
                 FsmEditor.SelectGameObject(mGameObject);
             });
         }
         toolsMenu.ShowAsContext();
     }
 }
示例#2
0
		private void OnSelectionChange(){
			FsmEditor.SelectGameObject (Selection.activeGameObject);
		}
示例#3
0
        private void OnGUI()
        {
            GUILayout.BeginHorizontal(EditorStyles.toolbar);
            if (GUILayout.Button("Refresh", EditorStyles.toolbarButton))
            {
                FindFsms();
            }
            GUILayout.FlexibleSpace();
            FsmTool.Loaction mloc = (FsmTool.Loaction)EditorGUILayout.EnumPopup(location, EditorStyles.toolbarPopup, GUILayout.Width(100f));
            if (location != mloc)
            {
                location = mloc;
                FindFsms();
            }
            GUILayout.EndHorizontal();
            scroll = EditorGUILayout.BeginScrollView(scroll);
            for (int i = 0; i < fsms.Length; i++)
            {
                StateMachine fsm   = fsms[i];
                GUIStyle     style = FsmEditorStyles.elementBackground;
                if (i == index)
                {
                    style = new GUIStyle("MeTransitionSelectHead")
                    {
                        stretchHeight = false,
                    };
                    style.overflow = new RectOffset(-1, -2, -2, 2);
                }
                GUILayout.BeginVertical(style);
                GUILayout.Label(location == Loaction.Project? AssetDatabase.GetAssetPath(fsm):targets[i] + " : " + fsm.Name);

                Rect  elementRect = GUILayoutUtility.GetLastRect();
                Event ev          = Event.current;
                switch (ev.rawType)
                {
                case EventType.MouseDown:
                    if (elementRect.Contains(Event.current.mousePosition))
                    {
                        if (Event.current.button == 0)
                        {
                            DragAndDrop.objectReferences = new Object[1] {
                                fsm
                            };
                            dragIndex = i;
                            Event.current.Use();
                        }
                    }
                    break;

                case EventType.MouseUp:
                    if (elementRect.Contains(Event.current.mousePosition))
                    {
                        if (Event.current.button == 0)
                        {
                            index = i;
                            if (FsmEditor.instance == null)
                            {
                                FsmEditor.ShowWindow();
                            }
                            if (location == Loaction.Scene)
                            {
                                FsmEditor.SelectGameObject(targets[i]);
                            }
                            FsmEditor.SelectStateMachine(fsm);
                            Event.current.Use();
                        }
                    }
                    dragIndex = -1;
                    break;

                case EventType.MouseDrag:
                    if (dragIndex != -1)
                    {
                        DragAndDrop.StartDrag("Drag");
                        dragIndex = -1;
                        Event.current.Use();
                    }
                    break;
                }
                GUILayout.EndVertical();
            }
            EditorGUILayout.EndScrollView();
        }