示例#1
0
        void IDrawableElement.OnGUI(Rect r, NGSpotlightWindow window, EntryRef k, int i)
        {
            if (MenuItemDrawer.style == null)
            {
                MenuItemDrawer.style              = new GUIStyle(EditorStyles.label);
                MenuItemDrawer.style.alignment    = TextAnchor.MiddleLeft;
                MenuItemDrawer.style.padding.left = 32;
                MenuItemDrawer.style.fontSize     = 15;
                MenuItemDrawer.style.richText     = true;
            }

            GUI.Box(r, "");

            if (Event.current.type == EventType.Repaint)
            {
                if (r.Contains(Event.current.mousePosition) == true)
                {
                    Utility.DrawUnfillRect(r, HQ.Settings != null ? HQ.Settings.Get <SpotlightSettings>().hoverSelectionColor : NGSpotlightWindow.HighlightedEntryColor);
                }
                else if (window.selectedEntry == i)
                {
                    Utility.DrawUnfillRect(r, HQ.Settings != null ? HQ.Settings.Get <SpotlightSettings>().outlineSelectionColor : NGSpotlightWindow.SelectedEntryColor);
                }
            }

            if (this.lastChange != window.changeCount)
            {
                this.lastChange            = window.changeCount;
                this.cachedHighlightedName = window.HighlightWeightContent(this.lowerPath, this.path, window.cleanLowerKeywords);
            }

            //GUI.DrawTexture(iconR, this.icon, ScaleMode.ScaleToFit);
            GUI.Label(r, this.cachedHighlightedName, MenuItemDrawer.style);

            if ((Event.current.type == EventType.KeyDown && window.selectedEntry == i && Event.current.keyCode == KeyCode.Return) ||
                (Event.current.type == EventType.MouseDown && r.Contains(Event.current.mousePosition) == true))
            {
                if (EditorApplication.ExecuteMenuItem(this.path) == true)
                {
                    NGSpotlightWindow.UseEntry(k);
                }
                window.Close();
                Event.current.Use();
            }
        }
示例#2
0
        void IDrawableElement.OnGUI(Rect r, NGSpotlightWindow window, EntryRef k, int i)
        {
            // Init once.
            if (this.lastChange == -1)
            {
                this.asset = AssetDatabase.LoadAssetAtPath(this.path, typeof(Object));
            }

            if (this.asset == null)
            {
                NGSpotlightWindow.DeleteEntry(k.key, k.i);
                return;
            }

            if (DefaultAssetDrawer.style == null)
            {
                DefaultAssetDrawer.style           = new GUIStyle(EditorStyles.label);
                DefaultAssetDrawer.style.alignment = TextAnchor.MiddleLeft;
                DefaultAssetDrawer.style.fontSize  = 15;
                DefaultAssetDrawer.style.richText  = true;

                DefaultAssetDrawer.defaultIcon = InternalEditorUtility.GetIconForFile(".png");
            }

            if (this.iconIsPreview == true && this.asset != null && (this.icon == null || this.icon == DefaultAssetDrawer.defaultIcon))
            {
                this.icon = AssetPreview.GetAssetPreview(this.asset);
                window.Repaint();
            }

            if (this.icon == null)
            {
                this.icon = DefaultAssetDrawer.defaultIcon;
            }

            Rect iconR = r;

            iconR.width = iconR.height;

            GUI.Box(r, "");
            GUI.DrawTexture(iconR, this.icon, ScaleMode.ScaleToFit);

            if (this.lastChange != window.changeCount)
            {
                this.lastChange            = window.changeCount;
                this.cachedHighlightedName = window.HighlightWeightContent(this.lowerName, this.name, window.cleanLowerKeywords);
            }

            if (Event.current.type == EventType.Repaint)
            {
                if (r.Contains(Event.current.mousePosition) == true)
                {
                    Utility.DrawUnfillRect(r, HQ.Settings != null ? HQ.Settings.Get <SpotlightSettings>().hoverSelectionColor : NGSpotlightWindow.HighlightedEntryColor);
                }
                if (window.selectedEntry == i)
                {
                    Utility.DrawUnfillRect(r, HQ.Settings != null ? HQ.Settings.Get <SpotlightSettings>().outlineSelectionColor : NGSpotlightWindow.SelectedEntryColor);
                }
            }
            else if (Event.current.type == EventType.MouseDrag)
            {
                if (i.Equals(DragAndDrop.GetGenericData("i")) == true)
                {
                    DragAndDrop.StartDrag("Drag Asset");
                    Event.current.Use();
                }
            }
            else if (Event.current.type == EventType.MouseDown)
            {
                if (r.Contains(Event.current.mousePosition) == true)
                {
                    DragAndDrop.PrepareStartDrag();
                    DragAndDrop.SetGenericData("i", i);
                    DragAndDrop.objectReferences = new Object[] { this.asset };
                }
            }
            else if (Event.current.type == EventType.DragExited)
            {
                DragAndDrop.PrepareStartDrag();
            }

            if ((Event.current.type == EventType.KeyDown && window.selectedEntry == i && Event.current.keyCode == KeyCode.Return) ||
                (Event.current.type == EventType.MouseUp && r.Contains(Event.current.mousePosition) == true && i.Equals(DragAndDrop.GetGenericData("i")) == true))
            {
                if (Event.current.type == EventType.MouseUp && r.Contains(Event.current.mousePosition) == true)
                {
                    DragAndDrop.PrepareStartDrag();
                }

                if (window.selectedEntry == i || Event.current.button != 0)
                {
                    NGSpotlightWindow.UseEntry(k);
                    Selection.activeObject = this.asset;
                    window.Close();
                }
                else
                {
                    window.SelectEntry(i);
                }

                Event.current.Use();
            }

            r.xMin += iconR.width;
            GUI.Label(r, this.cachedHighlightedName, DefaultAssetDrawer.style);
        }
示例#3
0
        void IDrawableElement.OnGUI(Rect r, NGSpotlightWindow window, EntryRef k, int i)
        {
            // Init once.
            if (this.lastChange == -1)
            {
                this.go = AssetDatabase.LoadAssetAtPath <GameObject>(this.path);
            }

            if (this.go == null)
            {
                NGSpotlightWindow.DeleteEntry(k.key, k.i);
                return;
            }

            if (PrefabDrawer.style == null)
            {
                PrefabDrawer.style           = new GUIStyle(EditorStyles.label);
                PrefabDrawer.style.alignment = TextAnchor.MiddleLeft;
                PrefabDrawer.style.fontSize  = 15;
                PrefabDrawer.style.richText  = true;
            }

            Rect iconR = r;

            iconR.width = iconR.height;

            GUI.Box(r, "");
            GUI.DrawTexture(iconR, UtilityResources.PrefabIcon, ScaleMode.ScaleToFit);

            if (this.lastChange != window.changeCount)
            {
                this.lastChange = window.changeCount;

                if (this.cachedHierarchy == null)
                {
                    if (this.go != null && this.go.transform.parent != null)
                    {
                        //this.cachedHierarchy = Utility.GetHierarchyStringified(this.go.transform.parent) + '/';
                        this.cachedHierarchy = "<color=teal><size=9>" + this.go.transform.parent.name + '/' + "</size></color>";
                    }
                    else
                    {
                        this.cachedHierarchy = string.Empty;
                    }
                }

                this.cachedHighlightedName = this.cachedHierarchy + window.HighlightWeightContent(this.lowerName, this.name, window.cleanLowerKeywords);
                //this.cachedHighlightedName = window.HighlightWeightContent(this.lowerName, this.name, window.cleanLowerKeywords);
            }

            if (Event.current.type == EventType.Repaint)
            {
                if (r.Contains(Event.current.mousePosition) == true)
                {
                    Utility.DrawUnfillRect(r, HQ.Settings != null ? HQ.Settings.Get <SpotlightSettings>().hoverSelectionColor : NGSpotlightWindow.HighlightedEntryColor);
                }
                else if (window.selectedEntry == i)
                {
                    Utility.DrawUnfillRect(r, HQ.Settings != null ? HQ.Settings.Get <SpotlightSettings>().outlineSelectionColor : NGSpotlightWindow.SelectedEntryColor);
                }
            }
            else if (Event.current.type == EventType.MouseDrag)
            {
                if (i.Equals(DragAndDrop.GetGenericData("i")) == true)
                {
                    DragAndDrop.StartDrag("Drag Asset");
                    Event.current.Use();
                }
            }
            else if (Event.current.type == EventType.MouseDown)
            {
                if (r.Contains(Event.current.mousePosition) == true)
                {
                    DragAndDrop.PrepareStartDrag();
                    DragAndDrop.SetGenericData("i", i);
                    DragAndDrop.objectReferences = new Object[] { this.go };
                }
            }
            else if (Event.current.type == EventType.DragExited)
            {
                DragAndDrop.PrepareStartDrag();
            }

            if ((Event.current.type == EventType.KeyDown && window.selectedEntry == i && Event.current.keyCode == KeyCode.Return) ||
                (Event.current.type == EventType.MouseUp && r.Contains(Event.current.mousePosition) == true && i.Equals(DragAndDrop.GetGenericData("i")) == true))
            {
                if (Event.current.type == EventType.MouseUp && r.Contains(Event.current.mousePosition) == true)
                {
                    DragAndDrop.PrepareStartDrag();
                }

                if (window.selectedEntry == i || Event.current.button != 0)
                {
                    NGSpotlightWindow.UseEntry(k);
                    Selection.activeGameObject = this.go;
                    window.Close();
                }
                else
                {
                    window.SelectEntry(i);
                }

                Event.current.Use();
            }

            r.xMin += iconR.width;
            GUI.Label(r, this.cachedHighlightedName, PrefabDrawer.style);
        }
示例#4
0
        void IDrawableElement.OnGUI(Rect r, NGSpotlightWindow window, EntryRef k, int i)
        {
            if (CSharpDrawer.style == null)
            {
                CSharpDrawer.style           = new GUIStyle(EditorStyles.label);
                CSharpDrawer.style.alignment = TextAnchor.MiddleLeft;
                CSharpDrawer.style.fontSize  = 15;
                CSharpDrawer.style.richText  = true;
            }

            if (this.type == null)
            {
                var mn = AssetDatabase.LoadAssetAtPath <MonoScript>(this.path);
                if (mn)
                {
                    this.type = mn.GetClass();
                }
            }

            Rect iconR = r;

            iconR.width = iconR.height;

            GUI.Box(r, "");

            if (Event.current.type == EventType.Repaint)
            {
                if (r.Contains(Event.current.mousePosition) == true)
                {
                    Utility.DrawUnfillRect(r, HQ.Settings != null ? HQ.Settings.Get <SpotlightSettings>().hoverSelectionColor : NGSpotlightWindow.HighlightedEntryColor);
                }
                else if (window.selectedEntry == i)
                {
                    Utility.DrawUnfillRect(r, HQ.Settings != null ? HQ.Settings.Get <SpotlightSettings>().outlineSelectionColor : NGSpotlightWindow.SelectedEntryColor);
                }
            }
            else if (Event.current.type == EventType.MouseDrag)
            {
                if (i.Equals(DragAndDrop.GetGenericData("i")) == true)
                {
                    DragAndDrop.StartDrag("Drag Asset");
                    Event.current.Use();
                }
            }
            else if (Event.current.type == EventType.MouseDown)
            {
                if (r.Contains(Event.current.mousePosition) == true)
                {
                    DragAndDrop.PrepareStartDrag();
                    DragAndDrop.SetGenericData("i", i);
                    DragAndDrop.objectReferences = new Object[] { AssetDatabase.LoadAssetAtPath <Object>(this.path) };
                }
            }
            else if (Event.current.type == EventType.DragExited)
            {
                DragAndDrop.PrepareStartDrag();
            }

            GUI.DrawTexture(iconR, UtilityResources.CSharpIcon, ScaleMode.ScaleToFit);

            if (this.lastChange != window.changeCount)
            {
                this.lastChange            = window.changeCount;
                this.cachedHighlightedName = window.HighlightWeightContent(this.lowerName, this.name, window.cleanLowerKeywords);
            }

            float h  = Mathf.Floor(r.height * .66F);
            Rect  r3 = r;

            r3.height = h;
            r3.xMin  += iconR.width;
            r3.xMax  -= CSharpDrawer.OpenWidth;
            GUI.Label(r3, this.cachedHighlightedName, CSharpDrawer.style);

            if (this.type != null)
            {
                r3.y     += r3.height - 2F;
                r3.height = iconR.height - h + 4F;
                GUI.Label(r3, this.type.FullName, GeneralStyles.SmallLabel);
                r3.y = iconR.y;
            }

            Rect openR = r3;

            openR.height = iconR.height;
            openR.y     += (openR.height - h) * .5F;
            openR.height = h;
            openR.x     += openR.width;
            openR.width  = CSharpDrawer.OpenWidth;
            if (GUI.Button(openR, "Open") == true)
            {
                EditorUtility.OpenWithDefaultApp(this.path);
            }

            if ((Event.current.type == EventType.KeyDown && window.selectedEntry == i && Event.current.keyCode == KeyCode.Return) ||
                (Event.current.type == EventType.MouseUp && r.Contains(Event.current.mousePosition) == true && openR.Contains(Event.current.mousePosition) == false && i.Equals(DragAndDrop.GetGenericData("i")) == true))
            {
                if (Event.current.type == EventType.MouseUp && r.Contains(Event.current.mousePosition) == true && openR.Contains(Event.current.mousePosition) == false)
                {
                    DragAndDrop.PrepareStartDrag();
                }

                if (window.selectedEntry == i || Event.current.button != 0)
                {
                    NGSpotlightWindow.UseEntry(k);

                    Object file = AssetDatabase.LoadAssetAtPath <Object>(this.path);

                    if (Event.current.button == 0)
                    {
                        AssetDatabase.OpenAsset(file, 0);
                    }
                    else
                    {
                        Selection.activeObject = file;
                    }

                    window.Close();
                }
                else
                {
                    window.SelectEntry(i);
                }

                Event.current.Use();
            }
        }
示例#5
0
        void IDrawableElement.OnGUI(Rect r, NGSpotlightWindow window, EntryRef k, int i)
        {
            if (SceneDrawer.style == null)
            {
                SceneDrawer.style                  = new GUIStyle(EditorStyles.label);
                SceneDrawer.style.alignment        = TextAnchor.MiddleLeft;
                SceneDrawer.style.padding.left     = 32;
                SceneDrawer.style.fontSize         = 15;
                SceneDrawer.style.richText         = true;
                SceneDrawer.buttonStyle            = new GUIStyle("ButtonLeft");
                SceneDrawer.menuStyle              = new GUIStyle("DropDownButton");
                SceneDrawer.menuStyle.fixedHeight  = NGSpotlightWindow.RowHeight / 1.5F;
                SceneDrawer.menuStyle.padding.left = 0;
                SceneDrawer.menuStyle.margin.left  = 0;
                SceneDrawer.menuStyle.border.left  = 0;
            }

            Rect iconR = r;

            iconR.width = iconR.height;

            GUI.Box(r, "");

            if (Event.current.type == EventType.Repaint)
            {
                if (r.Contains(Event.current.mousePosition) == true)
                {
                    Utility.DrawUnfillRect(r, HQ.Settings != null ? HQ.Settings.Get <SpotlightSettings>().hoverSelectionColor : NGSpotlightWindow.HighlightedEntryColor);
                }
                else if (window.selectedEntry == i)
                {
                    Utility.DrawUnfillRect(r, HQ.Settings != null ? HQ.Settings.Get <SpotlightSettings>().outlineSelectionColor : NGSpotlightWindow.SelectedEntryColor);
                }
            }
            else if (Event.current.type == EventType.MouseDrag)
            {
                if (i.Equals(DragAndDrop.GetGenericData("i")) == true)
                {
                    DragAndDrop.StartDrag("Drag Asset");
                    Event.current.Use();
                }
            }
            else if (Event.current.type == EventType.MouseDown)
            {
                if (r.Contains(Event.current.mousePosition) == true)
                {
                    DragAndDrop.PrepareStartDrag();
                    DragAndDrop.SetGenericData("i", i);
                    DragAndDrop.objectReferences = new Object[] { AssetDatabase.LoadAssetAtPath <Object>(this.path) };
                }
            }
            else if (Event.current.type == EventType.DragExited)
            {
                DragAndDrop.PrepareStartDrag();
            }

            GUI.DrawTexture(iconR, UtilityResources.UnityIcon, ScaleMode.ScaleToFit);

            if (this.lastChange != window.changeCount)
            {
                this.lastChange            = window.changeCount;
                this.cachedHighlightedName = window.HighlightWeightContent(this.lowerName, this.name, window.cleanLowerKeywords);
            }

            r.width -= SceneDrawer.OpenWidth + SceneDrawer.DropdownWidth;
            GUI.Label(r, this.cachedHighlightedName, SceneDrawer.style);

            if ((Event.current.type == EventType.KeyDown && window.selectedEntry == i && Event.current.keyCode == KeyCode.Return) ||
                (Event.current.type == EventType.MouseUp && r.Contains(Event.current.mousePosition) == true && i.Equals(DragAndDrop.GetGenericData("i")) == true))
            {
                if (Event.current.type == EventType.MouseUp && r.Contains(Event.current.mousePosition) == true)
                {
                    DragAndDrop.PrepareStartDrag();
                }

                if (window.selectedEntry == i || Event.current.button != 0)
                {
                    NGSpotlightWindow.UseEntry(k);

                    if (Event.current.button == 0)
                    {
                        this.LoadScene(window, this.path, 0);
                    }
                    else
                    {
                        Selection.activeObject = AssetDatabase.LoadAssetAtPath <Object>(this.path);
                    }

                    window.Close();
                }
                else
                {
                    window.SelectEntry(i);
                }

                Event.current.Use();
            }

            r.height = Mathf.Floor(r.height * .66F);
            r.y     += (iconR.height - r.height) * .5F;
            r.x     += r.width;
            r.width  = SceneDrawer.OpenWidth;
            if (GUI.Button(r, "Open", SceneDrawer.buttonStyle) == true)
            {
                this.LoadScene(window, this.path, 0);
            }

            r.x    += r.width;
            r.width = SceneDrawer.DropdownWidth;
            if (GUI.Button(r, "", SceneDrawer.menuStyle) == true)
            {
                GenericMenu menu = new GenericMenu();

                menu.AddItem(new GUIContent("Load single"), false, this.LoadScene, window);
                menu.AddItem(new GUIContent("Load additive"), false, this.LoadSceneAdditive, window);
                menu.AddItem(new GUIContent("Load additive without loading"), false, this.LoadSceneAdditiveWithoutLoading, window);
                if (AssetDatabase.LoadAssetAtPath(this.path, typeof(Object)) != null)
                {
                    menu.AddItem(new GUIContent("Ping"), false, this.PingScene);
                }

                menu.DropDown(r);
            }
        }