Exemple #1
0
        public void OpenEditor()
        {
            var nativeWindowSettings = new NativeWindowSettings()
            {
                Size             = new OpenTK.Mathematics.Vector2i(800, 600),
                Title            = "ZigZag Editor",
                AutoLoadBindings = true
            };

            m_nativeWindow = new NativeWindow(nativeWindowSettings);
            m_nativeWindow.Context.MakeCurrent();
            GLFW.SwapInterval(1);

            m_imguiContext = ImGui.CreateContext();
            ImGui.SetCurrentContext(m_imguiContext);
            ImGui.GetIO().ConfigFlags |= ImGuiConfigFlags.DockingEnable;

            unsafe
            {
                fixed(byte *ptr = Resources.Fonts.WorkSans_Regular)
                {
                    ImGui.GetIO().Fonts.AddFontFromMemoryTTF((IntPtr)ptr, Resources.Fonts.WorkSans_Regular.Length, 28);
                }
            }

            ImGuiPlatformIntegration.SetupKeys();
            ImGuiRendererIntegration.Initialize();
            ImGuiRendererIntegration.CreateFontsTexture();

            m_mainMenu                 = new MainMenu();
            m_hierarchyWindow          = new HierarchyWindow("Hierarchy");
            m_historyWindow            = new HistoryWindow("History");
            m_mainMenu.HierarchyWindow = m_hierarchyWindow;
            m_mainMenu.HistoryWindow   = m_historyWindow;
        }
Exemple #2
0
        // --------------------------------------------------------------------------------------------
        /// <summary>
        /// Gets the state of the item.
        /// </summary>
        /// <param name="manager">The manager.</param>
        /// <param name="id">The id.</param>
        /// <param name="stateMask">The state mask.</param>
        /// <returns></returns>
        // --------------------------------------------------------------------------------------------
        public __VSHIERARCHYITEMSTATE GetNodeState(IHierarchyManager manager, HierarchyId id,
                                                   __VSHIERARCHYITEMSTATE stateMask)
        {
            uint result;

            HierarchyWindow.GetNodeState(manager, (uint)id, (uint)stateMask, out result);
            return((__VSHIERARCHYITEMSTATE)(result));
        }
Exemple #3
0
 // --------------------------------------------------------------------------------------------
 /// <summary>
 /// Removes the specified hierachy from the hierarchy window
 /// </summary>
 /// <param name="hierarchy">Hierarchy to remove from the window</param>
 // --------------------------------------------------------------------------------------------
 public void RemoveUIHierarchy(IHierarchyManager hierarchy)
 {
     if (HierarchyWindow != null)
     {
         ErrorHandler.ThrowOnFailure(HierarchyWindow.RemoveUIHierarchy(hierarchy));
         _Hierarchies.Remove(hierarchy);
     }
 }
Exemple #4
0
            internal static void HandleDragAndDrop(int instanceId, Rect selectionRect)
            {
                // HACK: Uses EditorApplication.hierarchyWindowItemOnGUI.
                // Only works when there is at least one item in the scene.
                var  current         = UnityEngine.Event.current;
                var  eventType       = current.type;
                bool isDraggingEvent = eventType == EventType.DragUpdated;
                bool isDropEvent     = eventType == EventType.DragPerform;

                UnityEditor.DragAndDrop.visualMode = DragAndDropVisualMode.Copy;

                if (isDraggingEvent || isDropEvent)
                {
                    var mouseOverWindow = EditorWindow.mouseOverWindow;
                    if (mouseOverWindow != null)
                    {
                        // One, existing, valid SkeletonDataAsset
                        var references = UnityEditor.DragAndDrop.objectReferences;
                        if (references.Length == 1)
                        {
                            var skeletonDataAsset = references[0] as SkeletonDataAsset;
                            if (skeletonDataAsset != null && skeletonDataAsset.GetSkeletonData(true) != null)
                            {
                                // Allow drag-and-dropping anywhere in the Hierarchy Window.
                                // HACK: string-compare because we can't get its type via reflection.
                                const string HierarchyWindow     = "UnityEditor.SceneHierarchyWindow";
                                const string GenericDataTargetID = "target";
                                if (HierarchyWindow.Equals(mouseOverWindow.GetType().ToString(), System.StringComparison.Ordinal))
                                {
                                    if (isDraggingEvent)
                                    {
                                        var mouseOverTarget = UnityEditor.EditorUtility.InstanceIDToObject(instanceId);
                                        if (mouseOverTarget)
                                        {
                                            DragAndDrop.SetGenericData(GenericDataTargetID, mouseOverTarget);
                                        }
                                        // Note: do not call current.Use(), otherwise we get the wrong drop-target parent.
                                    }
                                    else if (isDropEvent)
                                    {
                                        var       parentGameObject = DragAndDrop.GetGenericData(GenericDataTargetID) as UnityEngine.GameObject;
                                        Transform parent           = parentGameObject != null ? parentGameObject.transform : null;
                                        // when dragging into empty space in hierarchy below last node, last node would be parent.
                                        if (IsLastNodeInHierarchy(parent))
                                        {
                                            parent = null;
                                        }
                                        DragAndDropInstantiation.ShowInstantiateContextMenu(skeletonDataAsset, Vector3.zero, parent);
                                        UnityEditor.DragAndDrop.AcceptDrag();
                                        current.Use();
                                        return;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        /// <summary>
        /// Sets the hierarchy's expanded state to only contain the current selection.
        /// </summary>
        public static void FocusHierarchyViewToSelection(bool forceRepaint = false)
        {
            if (HierarchyWindow == null)
            {
                return;
            }

            object sceneHierarchy = SceneHierarchy;

            FocusGenericHierarchyWithProperty(sceneHierarchy, "treeView");
            if (forceRepaint)
            {
                HierarchyWindow.Repaint();
            }
        }
Exemple #6
0
 // --------------------------------------------------------------------------------------------
 /// <summary>
 /// Adds a new hierachy to the hierarchy window
 /// </summary>
 /// <param name="hierarchy">Hierarchy to add to the window</param>
 /// <param name="dontSelectNew">
 /// Flag indicating if the the new hierarchy should not be selected.
 /// </param>
 // --------------------------------------------------------------------------------------------
 public void AddUIHierarchy(IHierarchyManager hierarchy, bool dontSelectNew)
 {
     if (HierarchyWindow != null)
     {
         ErrorHandler.ThrowOnFailure(
             HierarchyWindow.AddUIHierarchy(hierarchy,
                                            dontSelectNew
                                    ? (uint)__VSADDHIEROPTIONS.ADDHIEROPT_DontSelectNewHierarchy
                                    : 0));
         _Hierarchies.Add(hierarchy);
         Site(hierarchy);
         if (_InitialHierarchy != null)
         {
             _InitialHierarchy = hierarchy;
         }
     }
 }
            internal static void HandleDragAndDrop(int instanceId, Rect selectionRect)
            {
                // HACK: Uses EditorApplication.hierarchyWindowItemOnGUI.
                // Only works when there is at least one item in the scene.
                var  current         = UnityEngine.Event.current;
                var  eventType       = current.type;
                bool isDraggingEvent = eventType == EventType.DragUpdated;
                bool isDropEvent     = eventType == EventType.DragPerform;

                if (isDraggingEvent || isDropEvent)
                {
                    var mouseOverWindow = EditorWindow.mouseOverWindow;
                    if (mouseOverWindow != null)
                    {
                        // One, existing, valid SkeletonDataAsset
                        var references = UnityEditor.DragAndDrop.objectReferences;
                        if (references.Length == 1)
                        {
                            var skeletonDataAsset = references[0] as SkeletonDataAsset;
                            if (skeletonDataAsset != null && skeletonDataAsset.GetSkeletonData(true) != null)
                            {
                                // Allow drag-and-dropping anywhere in the Hierarchy Window.
                                // HACK: string-compare because we can't get its type via reflection.
                                const string HierarchyWindow = "UnityEditor.SceneHierarchyWindow";
                                if (HierarchyWindow.Equals(mouseOverWindow.GetType().ToString(), System.StringComparison.Ordinal))
                                {
                                    if (isDraggingEvent)
                                    {
                                        UnityEditor.DragAndDrop.visualMode = DragAndDropVisualMode.Copy;
                                        current.Use();
                                    }
                                    else if (isDropEvent)
                                    {
                                        DragAndDropInstantiation.ShowInstantiateContextMenu(skeletonDataAsset, Vector3.zero);
                                        UnityEditor.DragAndDrop.AcceptDrag();
                                        current.Use();
                                        return;
                                    }
                                }
                            }
                        }
                    }
                }
            }
Exemple #8
0
        // --------------------------------------------------------------------------------------------
        /// <summary>
        /// Initializes the tool window with the specified style and initial hierarchy.
        /// </summary>
        // --------------------------------------------------------------------------------------------
        public override void OnToolWindowCreated()
        {
            base.OnToolWindowCreated();
            __UIHWINFLAGS flags = 0;

            // ReSharper disable AccessToModifiedClosure
            _Attributes.ForEach(attr => flags |= attr.StyleFlag);
            // ReSharper restore AccessToModifiedClosure
            SetUIWindowStyle(ref flags);
            object unkObj;

            _InitialHierarchy = CreateInitialHierarchy();
            if (_InitialHierarchy != null)
            {
                _Hierarchies.Add(_InitialHierarchy);
            }
            HierarchyWindow.Init(_InitialHierarchy, (uint)flags, out unkObj);
            Site(_InitialHierarchy);
        }
Exemple #9
0
        static void HierarchyDragAndDrop(int instanceId, Rect selectionRect)
        {
            var  current         = UnityEngine.Event.current;
            var  eventType       = current.type;
            bool isDraggingEvent = eventType == EventType.DragUpdated;
            bool isDropEvent     = eventType == EventType.DragPerform;

            if (isDraggingEvent || isDropEvent)
            {
                var mouseOverWindow = EditorWindow.mouseOverWindow;
                if (mouseOverWindow != null)
                {
                    // One, existing, valid SkeletonDataAsset
                    var references = DragAndDrop.objectReferences;
                    if (references.Length == 1)
                    {
                        GameObject gameObject = references[0] as GameObject;
                        if (gameObject != null && gameObject.scene.path == null && gameObject.GetComponent <GunSoundSetting>())
                        {
                            var          soundSetting    = gameObject.GetComponent <GunSoundSetting>();
                            const string HierarchyWindow = "UnityEditor.SceneHierarchyWindow";
                            if (HierarchyWindow.Equals(mouseOverWindow.GetType().ToString(), System.StringComparison.Ordinal))
                            {
                                if (isDraggingEvent)
                                {
                                    DragAndDrop.visualMode = DragAndDropVisualMode.Copy;
                                    current.Use();
                                }
                                else if (isDropEvent)
                                {
                                    ShowInstantiateContextMenu(soundSetting, Vector3.zero);
                                    DragAndDrop.AcceptDrag();
                                    current.Use();
                                    return;
                                }
                            }
                        }
                    }
                }
            }
        }
Exemple #10
0
 // --------------------------------------------------------------------------------------------
 /// <summary>
 /// Removes the bold higlights from the specified node with.
 /// </summary>
 /// <param name="node">Node to remove the highlight from</param>
 // --------------------------------------------------------------------------------------------
 public void UnBoldNode(HierarchyNode node)
 {
     HierarchyWindow.UnBoldNode(node.ManagerNode, (uint)node.HierarchyId);
 }
Exemple #11
0
 // --------------------------------------------------------------------------------------------
 /// <summary>
 /// Expands the specified hierarchy node.
 /// </summary>
 /// <param name="node">Node to expand</param>
 // --------------------------------------------------------------------------------------------
 public void CollapseNode(HierarchyNode node)
 {
     HierarchyWindow.CollapseNode(node.ManagerNode, (uint)node.HierarchyId);
 }
Exemple #12
0
 // --------------------------------------------------------------------------------------------
 /// <summary>
 /// Expands the specified hierarchy node.
 /// </summary>
 /// <param name="node">Node to expand</param>
 /// <param name="recursive">Set true to expand the node recursively</param>
 // --------------------------------------------------------------------------------------------
 public void ExpandNode(HierarchyNode node, bool recursive)
 {
     HierarchyWindow.ExpandNode(node.ManagerNode, (uint)node.HierarchyId, recursive);
 }
Exemple #13
0
 // --------------------------------------------------------------------------------------------
 /// <summary>
 /// Expands the specified hierarchy node.
 /// </summary>
 /// <param name="node">Node to expand</param>
 // --------------------------------------------------------------------------------------------
 public void ExpandParents(HierarchyNode node)
 {
     HierarchyWindow.ExpandParents(node.ManagerNode, (uint)node.HierarchyId);
 }
Exemple #14
0
 public int FindCommonSelectionRoot(out IVsUIHierarchy commonHier)
 {
     return(HierarchyWindow.FindCommonSelectionRoot(out commonHier));
 }
Exemple #15
0
 // --------------------------------------------------------------------------------------------
 /// <summary>
 /// Extends the current selection into a range with the specified node.
 /// </summary>
 /// <param name="node">Node to select</param>
 // --------------------------------------------------------------------------------------------
 public void ExtendSelectNode(HierarchyNode node)
 {
     HierarchyWindow.ExtendSelectNode(node.ManagerNode, (uint)node.HierarchyId);
 }
Exemple #16
0
 // --------------------------------------------------------------------------------------------
 /// <summary>
 /// Starts editing of the specified node label.
 /// </summary>
 /// <param name="node">Node to remove the highlight from</param>
 // --------------------------------------------------------------------------------------------
 public void EditNodeLabel(HierarchyNode node)
 {
     HierarchyWindow.EditNodeLabel(node.ManagerNode, (uint)node.HierarchyId);
 }
Exemple #17
0
 // --------------------------------------------------------------------------------------------
 /// <summary>
 /// Removes Cut highlighting from the specified node.
 /// </summary>
 /// <param name="node">Node to remove the highlight from</param>
 // --------------------------------------------------------------------------------------------
 public void UnCutHighlightNode(HierarchyNode node)
 {
     HierarchyWindow.CutHighlightNode(node.ManagerNode, (uint)node.HierarchyId);
 }