public void Draw()
    {
        _scrollPosition = EditorGUILayout.BeginScrollView(_scrollPosition, GUILayout.ExpandHeight(false));

        _context.Triggers.TriggerCollectionRoot.Draw(0);

        EditorGUILayout.EndScrollView();

        EditorGUILayout.Separator();

        if (GUILayout.Button("Create New Trigger"))
        {
            CreateNewTrigger(_context.TriggerRoot.gameObject, "New Trigger");
            _context.Refresh();
        }
        GUILayout.BeginHorizontal();
        GUILayout.Label("Identifier: ");
        _createTriggerName = GUILayout.TextField(_createTriggerName);
        GUILayout.EndHorizontal();
    }
Example #2
0
    private void DrawFolderNode()
    {
        Color defaultColor = GUI.skin.label.normal.textColor;

        GUI.skin.label.fontStyle        = GameObject.activeInHierarchy ? FontStyle.Normal : FontStyle.Italic;
        GUI.skin.label.normal.textColor = GameObject.activeInHierarchy ? defaultColor : new Color(0.55f, 0.55f, 0.55f, 1.0f);
        GameObject.SetActive(GUILayout.Toggle(GameObject.activeSelf, "", GUILayout.ExpandWidth(false)));


        if (this.GameObject == _overviewContext.CurrentlyRenaming)
        {
            GameObject.name = GUILayout.TextField(GameObject.name, GUILayout.ExpandWidth(false));
            if (Event.current.isKey && Event.current.keyCode == KeyCode.Return)
            {
                _overviewContext.CurrentlyRenaming = null;
                _context.Refresh();
                Event.current.Use();
            }
        }
        else
        {
            bool useEvent = false;
            GUI.SetNextControlName("FakeButton" + GameObject.GetInstanceID());
            GUILayout.Label(GameObject.name, GUI.skin.label, GUILayout.ExpandWidth(false));
            Rect labelRect = GUILayoutUtility.GetLastRect();
            if (Event.current.type == EventType.DragUpdated && labelRect.Contains(Event.current.mousePosition))
            {
                DragAndDrop.visualMode = DragAndDropVisualMode.Move;
                DragAndDrop.AcceptDrag();
                useEvent = true;
            }
            if (Event.current.type == EventType.DragPerform && labelRect.Contains(Event.current.mousePosition))
            {
                if (DragAndDrop.objectReferences.Length == 1 && DragAndDrop.objectReferences[0] is GameObject)
                {
                    GameObject dragged = DragAndDrop.objectReferences[0] as GameObject;
                    dragged.transform.parent = GameObject.transform;
                    _context.Refresh();
                    useEvent = true;
                }
            }
            if (Event.current.type == EventType.MouseDrag && labelRect.Contains(Event.current.mousePosition))
            {
                if (_buttonDown)
                {
                    DragAndDrop.PrepareStartDrag();
                    DragAndDrop.StartDrag("Draggingwtf?");
                    DragAndDrop.objectReferences = new UnityEngine.Object[] { GameObject };
                    useEvent = true;
                }
            }
            if (Event.current.type == EventType.MouseDown && labelRect.Contains(Event.current.mousePosition))
            {
                _buttonDown = true;
                GUI.FocusControl("FakeButton" + GameObject.GetInstanceID());
                useEvent = true;
            }
            if (_buttonDown && Event.current.type == EventType.MouseUp && labelRect.Contains(Event.current.mousePosition))
            {
                _buttonDown    = false;
                _buttonPressed = true;
                useEvent       = true;
            }
            if (_buttonPressed && Event.current.type == EventType.MouseUp && labelRect.Contains(Event.current.mousePosition))
            {
                _buttonPressed = false;
                if (Event.current.button == 1)
                {
                    Vector2 mousePosition = Event.current.mousePosition;
                    if (this == _context.Triggers.TriggerCollectionRoot)
                    {
                        EditorUtility.DisplayCustomMenu(new Rect(mousePosition.x, mousePosition.y - 300, 100, 300), _rootContextOptions, -1, RootContextMenuFunction, this);
                    }
                    else
                    {
                        EditorUtility.DisplayCustomMenu(new Rect(mousePosition.x, mousePosition.y - 300, 100, 300), _folderContextOptions, -1, FolderContextMenuFunction, this);
                    }
                }
                useEvent = true;
            }
            if (useEvent)
            {
                _context.Repaint = true;
                Event.current.Use();
            }
        }

        GUI.skin.label.fontStyle        = FontStyle.Normal;
        GUI.skin.label.normal.textColor = defaultColor;
    }