Exemple #1
0
 protected virtual void  OnGUI()
 {
     this.path = NGEditorGUILayout.OpenFolderField("Path", this.path);
     if (GUILayout.Button("Generate") == true)
     {
         this.Aaa();
     }
 }
Exemple #2
0
        public void     OnGUI(Rect r, int i, float minY, float maxY, Project master = null)
        {
            if (this.root == null || (master == null && this.watcher == null))
            {
                return;
            }

            GUI.Box(r, GUIContent.none, GeneralStyles.Toolbar);
            float w = r.width;

            r.height = 16F;

            Utility.content.text = master == null ? "[Master]" : "[Slave " + i + "]";
            r.width = GUI.skin.label.CalcSize(Utility.content).x;
            GUI.Label(r, Utility.content);
            r.x += r.width;

            r.width = w - r.width;
            if (master != null)
            {
                r.width -= 75F;
            }
            NGEditorGUILayout.ElasticLabel(r, this.root.path, '/');

            using (BgColorContentRestorer.Get(GeneralStyles.HighlightResultButton))
            {
                EditorGUI.BeginDisabledGroup(this.root.CanDisplay == false);
                {
                    if (master != null)
                    {
                        r.x    += r.width;
                        r.width = 75F;
                        if (GUI.Button(r, "Sync", GeneralStyles.ToolbarButton) == true)
                        {
                            this.SyncAll(master);
                        }
                    }
                }
                EditorGUI.EndDisabledGroup();
            }

            r.x     = 0F;
            r.y    += r.height;
            r.width = w;

            if (master != null)
            {
                this.root.OnGUI(r, minY, maxY, master.root);
            }
            else
            {
                this.root.OnGUI(r, minY, maxY, null);
            }
        }
Exemple #3
0
        public override void    OnGUI()
        {
            if (this.button == null)
            {
                this.button = new GUIStyle(GUI.skin.button);
            }

            float w = this.button.CalcSize(this.content).x;

            if (this.image == null)
            {
                this.button.padding.left = GUI.skin.button.padding.left;
            }
            else
            {
                this.button.padding.left = (int)this.hub.height;
                w += 12F;                 // Remove texture width, because Button calculates using the whole height.
            }

            Rect r = GUILayoutUtility.GetRect(w, this.hub.height, GUI.skin.button);

            if (Event.current.type == EventType.MouseDrag &&
                Utility.position2D != Vector2.zero &&
                DragAndDrop.GetGenericData(Utility.DragObjectDataName) != null &&
                (Utility.position2D - Event.current.mousePosition).sqrMagnitude >= Constants.MinStartDragDistance)
            {
                Utility.position2D = Vector2.zero;
                DragAndDrop.StartDrag("Drag Object");
                Event.current.Use();
            }
            else if (Event.current.type == EventType.MouseDown && r.Contains(Event.current.mousePosition) == true)
            {
                NGEditorGUILayout.PingObject(asset);

                Utility.position2D = Event.current.mousePosition;
                DragAndDrop.PrepareStartDrag();
                DragAndDrop.objectReferences = new Object[] { this.asset };
                DragAndDrop.SetGenericData(Utility.DragObjectDataName, 1);
            }

            GUI.Button(r, this.content, this.button);
            if (this.image != null)
            {
                r       = GUILayoutUtility.GetLastRect();
                r.x    += 4F;
                r.width = r.height;
                GUI.DrawTexture(r, this.image);
            }
        }
Exemple #4
0
        protected virtual void  OnGUI()
        {
            Rect r = this.position;

            r.x     = 0F;
            r.y     = 0F;
            r.yMax -= 32F;
            this.drawer.OnGUI(r);

            r.y     += r.height;
            r.height = 32F;

            GUILayout.BeginArea(r);
            {
                EditorGUILayout.BeginHorizontal();
                {
                    EditorGUILayout.BeginVertical();
                    {
                        GUILayout.Space(10F);
                        using (LabelWidthRestorer.Get(95F))
                        {
                            this.exportFile = NGEditorGUILayout.SaveFileField(LC.G("ExportFilePath"), this.exportFile, string.Empty, string.Empty);
                        }
                    }
                    EditorGUILayout.EndVertical();

                    GUILayout.Space(10F);

                    EditorGUI.BeginDisabledGroup(string.IsNullOrEmpty(this.exportFile));
                    {
                        using (BgColorContentRestorer.Get(GeneralStyles.HighlightActionButton))
                        {
                            if (GUILayout.Button(LC.G("Export"), GUILayoutOptionPool.Height(30F)) == true)
                            {
                                this.ExportLogs();
                            }
                        }
                    }
                    EditorGUI.EndDisabledGroup();
                }
                EditorGUILayout.EndHorizontal();
            }
            GUILayout.EndArea();
        }
Exemple #5
0
        public override void    OnGUIModule(Rect r, NGRemoteHierarchyWindow hierarchy)
        {
            using (LabelWidthRestorer.Get(110F))
            {
                r.height = Constants.SingleLineHeight;
                EditorGUI.BeginChangeCheck();
                this.useJPG = EditorGUI.Toggle(r, "Use JPG", this.useJPG);
                if (EditorGUI.EndChangeCheck() == true)
                {
                    NGEditorPrefs.SetBool(ScreenshotModuleEditor.UseJPGKeyPref, this.useJPG, true);

                    if (hierarchy.IsClientConnected() == true)
                    {
                        hierarchy.Client.AddPacket(new ClientModuleSetUseJPGPacket(this.useJPG));
                    }
                }
                r.y += r.height + 2F;

                EditorGUI.BeginChangeCheck();
                this.useCompression = EditorGUI.Toggle(r, "Use Compression", this.useCompression);
                if (EditorGUI.EndChangeCheck() == true)
                {
                    NGEditorPrefs.SetBool(ScreenshotModuleEditor.UseCompressionKeyPref, this.useCompression, true);

                    if (hierarchy.IsClientConnected() == true)
                    {
                        hierarchy.Client.AddPacket(new ClientModuleSetUseCompressionPacket(this.useCompression));
                    }
                }
                r.y += r.height + 2F;

                EditorGUI.BeginChangeCheck();
                r.width        = 210F;
                this.scaleMode = (ScaleMode)NGEditorGUILayout.EnumPopup(r, "Scale Mode", this.scaleMode);
                if (EditorGUI.EndChangeCheck() == true)
                {
                    NGEditorPrefs.SetInt(ScreenshotModuleEditor.ScaleModeKeyPref, (int)this.scaleMode, true);
                }
            }
        }
        private void    PreviewPath(Rect r, string fullPath)
        {
            bool exists = Directory.Exists(fullPath);

            if (exists == false)
            {
                r.xMin += 34F;
            }
            else
            {
                r.xMin += 16F;
            }

            Color restore = GeneralStyles.SmallLabel.normal.textColor;

            if (exists == false)
            {
                GeneralStyles.SmallLabel.normal.textColor = Color.yellow;
            }

            NGEditorGUILayout.ElasticLabel(r, fullPath, '/', GeneralStyles.SmallLabel);

            GeneralStyles.SmallLabel.normal.textColor = restore;

            r.width = 16F;

            if (exists == false)
            {
                r.x -= 16F;

                GUI.DrawTexture(r, UtilityResources.WarningIcon);
            }

            r.y -= 5F;
            r.x  = 5F;

            GUI.Label(r, "↳", GeneralStyles.Title1);
        }
Exemple #7
0
        protected virtual void  OnGUI()
        {
            EditorGUI.BeginChangeCheck();
            this.input = EditorGUILayout.TextField("Type", this.input);
            if (EditorGUI.EndChangeCheck() == true && this.input.Length > 2)
            {
                Utility.RegisterIntervalCallback(this.RefreshMatchingTypes, 100, 1);
            }

            Type t = Type.GetType(this.input);

            if (t != null)
            {
                if (GUILayout.Button("Analyze " + t.FullName))
                {
                    this.membersEmbedded.Clear();
                    this.type       = t;
                    this.fields     = t.GetFields(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public);
                    this.properties = t.GetProperties(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public);
                    this.methods    = t.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public);

                    for (int i = 0; i < this.fields.Length; i++)
                    {
                        if (this.SkipMember(this.fields[i]) == false)
                        {
                            this.membersEmbedded.Add(this.fields[i]);
                        }
                    }
                    for (int i = 0; i < this.properties.Length; i++)
                    {
                        if (this.SkipMember(this.properties[i]) == false)
                        {
                            this.membersEmbedded.Add(this.properties[i]);
                        }
                    }
                    for (int i = 0; i < this.methods.Length; i++)
                    {
                        if (this.methods[i].Name == "Finalize" ||
                            this.methods[i].Name == "GetHashCode" ||
                            this.methods[i].Name == "GetType" ||
                            this.methods[i].Name == "MemberwiseClone" ||
                            this.methods[i].Name == "ToString")
                        {
                            continue;
                        }

                        if (this.SkipMember(this.methods[i]) == false)
                        {
                            this.membersEmbedded.Add(this.methods[i]);
                        }
                    }
                }
            }

            this.scrollPositionAQN = EditorGUILayout.BeginScrollView(this.scrollPositionAQN, GUILayoutOptionPool.Height(Mathf.Min(this.matchingTypes.Count * 18F, 200F)));
            {
                for (int i = 0; i < this.matchingTypes.Count; i++)
                {
                    if (GUILayout.Button(this.matchingTypes[i].FullName) == true)
                    {
                        this.input = this.matchingTypes[i].AssemblyQualifiedName;
                    }
                }
            }
            EditorGUILayout.EndScrollView();

            this.scrollPositionMembers = EditorGUILayout.BeginScrollView(this.scrollPositionMembers);
            {
                if (this.type != null)
                {
                    if (string.IsNullOrEmpty(this.result) == false)
                    {
                        this.outputFilePath = NGEditorGUILayout.SaveFileField("File", this.outputFilePath);

                        if (GUILayout.Button("Write to file") == true)
                        {
                            File.WriteAllText(this.outputFilePath, this.result);
                        }

                        if (GUILayout.Button("Copy to clipboard") == true)
                        {
                            EditorGUIUtility.systemCopyBuffer = this.result;
                        }

                        if (this.result.Length < short.MaxValue / 2)
                        {
                            EditorGUILayout.TextArea(this.result, GUILayout.MaxHeight(150F));
                        }
                        else
                        {
                            EditorGUILayout.HelpBox("Result is too big to display.", MessageType.Warning);
                        }
                    }

                    if (GUILayout.Button("Generate") == true)
                    {
                        this.Generate();
                    }

                    EditorGUILayout.BeginHorizontal();
                    GUILayout.Label("Fields (" + this.fields.Length + ")");
                    if (GUILayout.Button("Toggle") == true)
                    {
                        this.ToggleMembers(this.fields);
                    }
                    GUILayout.FlexibleSpace();
                    EditorGUILayout.EndHorizontal();

                    ++EditorGUI.indentLevel;
                    this.DrawMembers(this.fields);
                    --EditorGUI.indentLevel;

                    EditorGUILayout.BeginHorizontal();
                    GUILayout.Label("Properties (" + this.properties.Length + ")");
                    if (GUILayout.Button("Toggle") == true)
                    {
                        this.ToggleMembers(this.properties);
                    }
                    GUILayout.FlexibleSpace();
                    EditorGUILayout.EndHorizontal();

                    ++EditorGUI.indentLevel;
                    this.DrawMembers(this.properties);
                    --EditorGUI.indentLevel;


                    EditorGUILayout.BeginHorizontal();
                    GUILayout.Label("Methods (" + this.methods.Length + ")");
                    if (GUILayout.Button("Toggle") == true)
                    {
                        this.ToggleMembers(this.methods);
                    }
                    GUILayout.FlexibleSpace();
                    EditorGUILayout.EndHorizontal();

                    ++EditorGUI.indentLevel;
                    this.DrawMembers(this.methods);
                    --EditorGUI.indentLevel;
                }
            }
            EditorGUILayout.EndScrollView();
        }
        private void    OnDrawSlave(Rect r, int index, bool isActive, bool isFocused)
        {
            if (this.showSlaves == false)
            {
                return;
            }

            SyncFoldersSettings settings = HQ.Settings.Get <SyncFoldersSettings>();
            Project             slave    = this.profile.slaves[index];
            float x     = r.x;
            float width = r.width;

            EditorGUI.BeginChangeCheck();
            r.y     += 2F;
            r.width  = NGSyncFoldersWindow.ToggleSlaveWidth;
            r.height = Constants.SingleLineHeight;

            string content = index < NGSyncFoldersWindow.CachedSlaveIndexes.Length ? NGSyncFoldersWindow.CachedSlaveIndexes[index] : "#" + (index + 1);
            bool   active  = EditorGUI.ToggleLeft(r, content, slave.active);

            if (EditorGUI.EndChangeCheck() == true)
            {
                Undo.RecordObject(settings, "Toggle slave");
                slave.active = active;
                HQ.InvalidateSettings();
                this.cachedSlaves = null;
            }
            r.x += r.width;

            EditorGUI.BeginDisabledGroup(slave.active == false);
            EditorGUI.BeginChangeCheck();
            r.width = width - NGSyncFoldersWindow.ToggleSlaveWidth - NGSyncFoldersWindow.DeleteButtonWidth - 5F;
            string folderPath = NGEditorGUILayout.OpenFolderField(r, "", slave.folderPath);

            if (EditorGUI.EndChangeCheck() == true)
            {
                Undo.RecordObject(settings, "Alter slave path");
                slave.folderPath = folderPath;
                HQ.InvalidateSettings();
            }
            EditorGUI.EndDisabledGroup();
            r.x += r.width + 5F;

            r.width   = NGSyncFoldersWindow.DeleteButtonWidth;
            r.y      -= 1F;
            r.height += 1F;
            if (GUI.Button(r, "X") == true)
            {
                Undo.RecordObject(settings, "Delete slave");
                this.profile.slaves.RemoveAt(index);
                HQ.InvalidateSettings();
                this.cachedSlaves = null;
                EditorGUIUtility.ExitGUI();
            }

            r.x      = 0F;
            r.y     += r.height + 2F;
            r.width  = x + width;
            r.height = Constants.SingleLineHeight;

            this.PreviewPath(r, slave.GetFullPath(this.profile.relativePath));
        }
        protected virtual void  OnGUI()
        {
            if (HQ.Settings == null)
            {
                GUILayout.Label(string.Format(LC.G("RequiringConfigurationFile"), NGSyncFoldersWindow.Title));
                if (GUILayout.Button(LC.G("ShowPreferencesWindow")) == true)
                {
                    Utility.ShowPreferencesWindowAt(Constants.PreferenceTitle);
                }
                return;
            }

            FreeLicenseOverlay.First(this, NGAssemblyInfo.Name + " Pro", NGSyncFoldersWindow.FreeAdContent);

            SyncFoldersSettings settings = HQ.Settings.Get <SyncFoldersSettings>();

            // Guarantee there is always one in the list.
            if (settings.syncProfiles.Count == 0)
            {
                settings.syncProfiles.Add(new Profile()
                {
                    name = "Profile 1"
                });
            }

            this.currentProfile = Mathf.Clamp(this.currentProfile, 0, settings.syncProfiles.Count - 1);
            this.profile        = settings.syncProfiles[this.currentProfile];

            Rect r = default(Rect);

            if (NGSyncFoldersWindow.cachePath == null)
            {
                NGSyncFoldersWindow.cachePath = Path.Combine(Application.persistentDataPath, Path.Combine(Constants.InternalPackageTitle, string.Format(NGSyncFoldersWindow.CachedHashedFile, this.currentProfile)));
            }

            this.slavesList.list  = this.profile.slaves;
            this.filtersList.list = this.profile.filters;

            r.width  = this.position.width;
            r.height = Constants.SingleLineHeight;
            GUI.Box(r, string.Empty, GeneralStyles.Toolbar);

            r.width = 20F;
            if (GUI.Button(r, "", GeneralStyles.ToolbarDropDown) == true)
            {
                GenericMenu menu = new GenericMenu();

                for (int i = 0; i < settings.syncProfiles.Count; i++)
                {
                    menu.AddItem(new GUIContent((i + 1) + " - " + settings.syncProfiles[i].name), i == this.currentProfile, this.SwitchProfile, i);
                }

                menu.AddSeparator("");
                menu.AddItem(new GUIContent(LC.G("Add")), false, this.AddProfile);
                menu.DropDown(r);

                GUI.FocusControl(null);
            }
            r.x += r.width + 4F;

            r.width = this.position.width - 20F - 100F - 4F;
            EditorGUI.BeginChangeCheck();
            r.y += 2F;
            string name = EditorGUI.TextField(r, this.profile.name, GeneralStyles.ToolbarTextField);

            if (EditorGUI.EndChangeCheck() == true)
            {
                Undo.RecordObject(settings, "Rename profile");
                this.profile.name = name;
                HQ.InvalidateSettings();
            }
            r.y -= 2F;
            r.x += r.width;

            r.width = 100F;
            EditorGUI.BeginDisabledGroup(settings.syncProfiles.Count <= 1);
            {
                if (GUI.Button(r, LC.G("Erase"), GeneralStyles.ToolbarButton) == true &&
                    ((Event.current.modifiers & Constants.ByPassPromptModifier) != 0 ||
                     EditorUtility.DisplayDialog(LC.G("NGSyncFolders_EraseSave"), string.Format(LC.G("NGSyncFolders_EraseSaveQuestion"), this.profile.name), LC.G("Yes"), LC.G("No")) == true))
                {
                    this.EraseProfile();
                    this.Focus();
                    return;
                }
            }
            EditorGUI.EndDisabledGroup();

            r.x     = 0F;
            r.y    += r.height + 5F;
            r.width = this.position.width;

            using (LabelWidthRestorer.Get(85F))
            {
                EditorGUI.BeginChangeCheck();
                string folderPath = NGEditorGUILayout.OpenFolderField(r, "Master Folder", this.profile.master.folderPath);
                if (EditorGUI.EndChangeCheck() == true)
                {
                    Undo.RecordObject(settings, "Alter master path");
                    this.profile.master.folderPath = folderPath;
                    HQ.InvalidateSettings();
                }
                r.y += r.height + NGSyncFoldersWindow.Spacing;

                EditorGUI.BeginChangeCheck();
                string relativePath = NGEditorGUILayout.OpenFolderField(r, "Relative Path", this.profile.relativePath, this.profile.master.folderPath, NGEditorGUILayout.FieldButtons.Open);
                if (EditorGUI.EndChangeCheck() == true)
                {
                    Undo.RecordObject(settings, "Alter relative path");
                    this.profile.relativePath = relativePath;
                    HQ.InvalidateSettings();
                }
                r.y += r.height + NGSyncFoldersWindow.Spacing;

                this.PreviewPath(r, this.profile.master.GetFullPath(this.profile.relativePath));
                r.y += r.height + NGSyncFoldersWindow.Spacing;

                r.height = this.slavesList.GetHeight();
                this.slavesList.DoList(r);

                if (this.showSlaves == false)
                {
                    r.y -= 16F;
                }

                r.y += r.height + NGSyncFoldersWindow.Spacing;
            }

            r.height = this.filtersList.GetHeight();
            this.filtersList.DoList(r);

            if (this.showFilters == false)
            {
                if (Event.current.type == EventType.Repaint)
                {
                    Rect r2 = r;
                    r2.y     += r2.height - 14F;
                    r2.height = 16F;
                    r2.width  = 16F;
                    EditorGUI.DrawRect(r2, EditorGUIUtility.isProSkin == true ? new Color(55F / 255F, 55F / 255F, 55F / 255F, 1F) : new Color(162F / 255F, 162F / 255F, 162F / 255F, 1F));
                }

                r.y -= 16F;
            }

            r.y += r.height + NGSyncFoldersWindow.Spacing;

            if (string.IsNullOrEmpty(this.cacheFileSize) == true)
            {
                this.UpdateCacheFileSize();
            }

            EditorGUI.BeginChangeCheck();
            r.width -= 200F;
            r.height = 20F;
            bool useCache = EditorGUI.Toggle(r, this.cacheFileSize, this.profile.useCache);

            if (EditorGUI.EndChangeCheck() == true)
            {
                Undo.RecordObject(settings, "Toggle use cache");
                this.profile.useCache = useCache;
                HQ.InvalidateSettings();
            }

            if (this.cacheFileSize != "Use Cache")
            {
                r.x += r.width;

                r.width = 100F;
                if (GUI.Button(r, "Open", "ButtonLeft") == true)
                {
                    EditorUtility.RevealInFinder(NGSyncFoldersWindow.cachePath);
                }
                r.x += r.width;
                if (GUI.Button(r, "Clear", "ButtonRight") == true)
                {
                    System.IO.File.Delete(NGSyncFoldersWindow.cachePath);
                    this.UpdateCacheFileSize();
                }
            }
            r.y += r.height + NGSyncFoldersWindow.Spacing;

            bool hasActiveSlaves = false;

            for (int i = 0; i < this.profile.slaves.Count; i++)
            {
                if (this.profile.slaves[i].active == true)
                {
                    hasActiveSlaves = true;
                    break;
                }
            }

            EditorGUI.BeginDisabledGroup(hasActiveSlaves == false);
            {
                using (BgColorContentRestorer.Get(GeneralStyles.HighlightActionButton))
                {
                    r.x      = 10F;
                    r.width  = 150F;
                    r.height = 32F;
                    if (GUI.Button(r, this.mode == ButtonMode.Scan ? "Scan" : "Scan & Watch", "Button" /*"ButtonLeft"*/) == true)
                    {
                        this.Scan();
                    }

                    //if (GUILayout.Button("☰", "ButtonRight", GUILayoutOptionPool.Height(32F), GUILayoutOptionPool.ExpandWidthFalse) == true)
                    //{
                    //	GenericMenu	menu = new GenericMenu();
                    //	menu.AddItem(new GUIContent("Scan"), this.mode == ButtonMode.Scan, () => this.mode = ButtonMode.Scan);
                    //	menu.AddItem(new GUIContent("Scan and Watch"), this.mode == ButtonMode.ScanAndWatch, () => this.mode = ButtonMode.ScanAndWatch);
                    //	menu.ShowAsContext();
                    //}
                }
            }
            EditorGUI.EndDisabledGroup();

            if (this.profile.master.IsScanned == true)
            {
                using (BgColorContentRestorer.Get(GeneralStyles.HighlightResultButton))
                {
                    r.x = this.position.width - r.width - 10F;
                    if (GUI.Button(r, "Sync All", "Button") == true)
                    {
                        this.SyncAll();
                    }
                    r.y += r.height + NGSyncFoldersWindow.Spacing;
                }
            }

            //if (this.mode == ButtonMode.ScanAndWatch)
            //	EditorGUILayout.HelpBox("Scan and Watch may induce huge freeze after a compilation when watching a lot of files. This mode is not recommended for programmers.", MessageType.Warning);

            if (this.profile.master.IsScanned == true)
            {
                r.x     = 0F;
                r.width = this.position.width;

                Rect bodyRect = r;
                bodyRect.height = this.position.height - r.y;

                Rect viewRect = new Rect {
                    height = this.profile.master.GetHeight()
                };

                for (int i = 0; i < this.profile.slaves.Count; i++)
                {
                    if (this.profile.slaves[i].active == true)
                    {
                        viewRect.height += this.profile.slaves[i].GetHeight(this.profile.master);
                    }
                }

                this.scrollPositionScan = GUI.BeginScrollView(bodyRect, this.scrollPositionScan, viewRect);
                {
                    r.y      = 0F;
                    r.height = this.profile.master.GetHeight();

                    if (viewRect.height > r.height)
                    {
                        r.width -= 15F;
                    }

                    if (r.yMax > this.scrollPositionScan.y)
                    {
                        this.profile.master.OnGUI(r, 0, this.scrollPositionScan.y, this.scrollPositionScan.y + bodyRect.height);
                    }

                    r.y += r.height;

                    for (int i = 0; i < this.profile.slaves.Count; i++)
                    {
                        if (this.profile.slaves[i].active == false)
                        {
                            continue;
                        }

                        r.height = this.profile.slaves[i].GetHeight(this.profile.master);

                        if (r.yMax > this.scrollPositionScan.y)
                        {
                            this.profile.slaves[i].OnGUI(r, i + 1, this.scrollPositionScan.y, this.scrollPositionScan.y + bodyRect.height, this.profile.master);
                        }

                        r.y += r.height;

                        if (r.y - this.scrollPositionScan.y > bodyRect.height)
                        {
                            break;
                        }
                    }
                }
                GUI.EndScrollView();
            }

            FreeLicenseOverlay.Last(NGAssemblyInfo.Name + " Pro");
        }
Exemple #10
0
        protected virtual void  OnGUI()
        {
            FreeLicenseOverlay.First(this, NGAssemblyInfo.Name + " Pro", NGRenamerWindow.FreeAdContent);

            float halfWidth = this.position.width * .5F - 25F;

            this.errorPopup.OnGUILayout();

            for (int i = 0; i < this.filters.Count; i++)
            {
                EditorGUI.BeginDisabledGroup(NGLicensesManager.Check(i < NGRenamerWindow.MaxRenamerFilters, NGAssemblyInfo.Name + " Pro") == false);
                this.filters[i].OnHeaderGUI();
                if (this.filters[i].open == true)
                {
                    try
                    {
                        this.filters[i].OnGUI();
                    }
                    catch (Exception ex)
                    {
                        this.errorPopup.exception = ex;
                    }
                }
                EditorGUI.EndDisabledGroup();
            }

            if (this.objects.Count > 0 || this.paths.Count > 0 || Selection.activeObject != null)
            {
                using (BgColorContentRestorer.Get(GeneralStyles.HighlightActionButton))
                {
                    if (GUILayout.Button("Replace All") == true)
                    {
                        this.ReplaceAll();
                    }
                }

                if (this.objects.Count > 0)
                {
                    EditorGUILayout.BeginHorizontal(GeneralStyles.Toolbar);
                    {
                        GUILayout.Label("Assets (" + this.objects.Count + ")", GeneralStyles.Title1);
                    }
                    EditorGUILayout.EndHorizontal();

                    this.assetsScrollPosition = EditorGUILayout.BeginScrollView(this.assetsScrollPosition, GUILayoutOptionPool.ExpandHeightTrue);
                    {
                        for (int i = 0; i < this.objects.Count; i++)
                        {
                            NGRenamerWindow.drawingIndex = i;

                            EditorGUILayout.BeginHorizontal();
                            {
                                Texture2D icon = Utility.GetIcon(this.objects[i].GetInstanceID());

                                Rect r = GUILayoutUtility.GetRect(16F, 16F);
                                GUI.DrawTexture(r, icon);
                                r.width += halfWidth - 32F;
                                if (GUI.Button(r, "", GUI.skin.label) == true)
                                {
                                    NGEditorGUILayout.PingObject(this.objects[i]);
                                    return;
                                }

                                this.DrawElement(Path.GetFileName(this.objects[i].name), halfWidth - 32F, (s) => this.RenameAsset(this.objects[i], s));

                                if (GUILayout.Button("X", GeneralStyles.ToolbarCloseButton) == true)
                                {
                                    this.objects.RemoveAt(i);
                                    return;
                                }
                            }
                            EditorGUILayout.EndHorizontal();
                        }
                    }
                    EditorGUILayout.EndScrollView();

                    GUILayout.Space(5F);
                }

                for (int i = 0; i < this.paths.Count; i++)
                {
                    EditorGUILayout.BeginHorizontal(GeneralStyles.Toolbar);
                    {
                        Rect r = GUILayoutUtility.GetRect(0F, 24F, GUILayoutOptionPool.ExpandWidthTrue);
                        GUI.Label(r, "Path " + this.paths[i].path + " (" + (this.paths[i].directories.Length + this.paths[i].files.Length) + ")", GeneralStyles.Title1);

                        Utility.content.text    = "↻";
                        Utility.content.tooltip = "Refresh folder's content";
                        if (GUILayout.Button(Utility.content, GeneralStyles.ToolbarAltButton, GUILayoutOptionPool.Width(20F)) == true)
                        {
                            try
                            {
                                this.paths[i].Update();
                            }
                            catch (Exception ex)
                            {
                                this.errorPopup.exception = ex;
                            }
                            return;
                        }
                        Utility.content.tooltip = string.Empty;

                        if (GUILayout.Button("X", GeneralStyles.ToolbarCloseButton, GUILayoutOptionPool.Width(20F)) == true)
                        {
                            this.paths.RemoveAt(i);
                            return;
                        }
                    }
                    EditorGUILayout.EndHorizontal();

                    try
                    {
                        this.paths[i].scrollPosition = EditorGUILayout.BeginScrollView(this.paths[i].scrollPosition, GUILayoutOptionPool.ExpandHeightTrue);
                        {
                            for (int j = 0; j < this.paths[i].directories.Length; j++)
                            {
                                NGRenamerWindow.drawingIndex = j;

                                this.DrawElement(Path.GetFileName(this.paths[i].directories[j]), halfWidth, (s) => {
                                    try
                                    {
                                        // To ensure different letter case will work.
                                        string tmp = Path.Combine(this.paths[i].path, Path.GetRandomFileName());
                                        Directory.Move(this.paths[i].absolutePathDirectories[j], tmp);
                                        Directory.Move(tmp, Path.Combine(this.paths[i].path, s));
                                        this.paths[i].directories[j] = s;
                                    }
                                    catch (Exception ex)
                                    {
                                        Debug.LogException(ex);
                                    }
                                });
                            }

                            for (int j = 0; j < this.paths[i].files.Length; j++)
                            {
                                NGRenamerWindow.drawingIndex = j;

                                this.DrawElement(Path.GetFileName(this.paths[i].files[j]), halfWidth, (s) => {
                                    try
                                    {
                                        File.Move(this.paths[i].absolutePathFiles[j], Path.Combine(this.paths[i].path, s));
                                        this.paths[i].files[j] = s;
                                    }
                                    catch (Exception ex)
                                    {
                                        Debug.LogException(ex);
                                    }
                                });
                            }
                        }
                        EditorGUILayout.EndScrollView();
                    }
                    catch (Exception ex)
                    {
                        this.paths.RemoveAt(i);
                        Debug.LogException(ex);
                    }

                    GUILayout.Space(5F);
                }

                if (Selection.objects.Length > 0)
                {
                    EditorGUILayout.BeginHorizontal(GeneralStyles.Toolbar);
                    {
                        GUILayout.Label("Selection", GeneralStyles.Title1);
                    }
                    EditorGUILayout.EndHorizontal();

                    this.selectionScrollPosition = EditorGUILayout.BeginScrollView(this.selectionScrollPosition, GUILayoutOptionPool.ExpandHeightTrue);
                    {
                        for (int i = 0; i < Selection.objects.Length; i++)
                        {
                            NGRenamerWindow.drawingIndex = i;

                            this.DrawElement(Selection.objects[i].name, halfWidth, (s) => this.RenameAsset(Selection.objects[i], s));
                        }
                    }
                    EditorGUILayout.EndScrollView();
                }

                using (BgColorContentRestorer.Get(GeneralStyles.HighlightActionButton))
                {
                    if (GUILayout.Button("Replace All") == true)
                    {
                        this.ReplaceAll();
                    }
                }

                GUILayout.FlexibleSpace();
            }
            else
            {
                Rect r = GUILayoutUtility.GetRect(this.position.width, 16F, GUILayoutOptionPool.ExpandHeightTrue);

                r.x      += 2F;
                r.y      += 2F;
                r.width  -= 4F;
                r.height -= 4F;

                if (Event.current.type == EventType.Repaint)
                {
                    Utility.DrawUnfillRect(r, Color.grey);
                }

                GUI.Label(r, "Select assets from Hierarchy or Project\n\nDrop any files or folders from\n" + (Application.platform == RuntimePlatform.WindowsEditor ? "Explorer, " : (Application.platform == RuntimePlatform.OSXEditor ? "Finder, " : "")) + "Hierarchy or Project", GeneralStyles.CenterText);
            }

            if (Event.current.type == EventType.DragUpdated)
            {
                if (DragAndDrop.objectReferences.Length > 0 || DragAndDrop.paths.Length > 0)
                {
                    DragAndDrop.visualMode = DragAndDropVisualMode.Move;
                }
                else
                {
                    DragAndDrop.visualMode = DragAndDropVisualMode.Rejected;
                }
            }
            else if (Event.current.type == EventType.DragPerform)
            {
                DragAndDrop.AcceptDrag();

                try
                {
                    if (DragAndDrop.objectReferences.Length > 0)
                    {
                        for (int i = 0; i < DragAndDrop.objectReferences.Length; i++)
                        {
                            Object obj = DragAndDrop.objectReferences[i];

                            if (typeof(Behaviour).IsAssignableFrom(obj.GetType()) == true)
                            {
                                obj = (obj as Behaviour).gameObject;
                            }

                            if (this.objects.Contains(obj) == false)
                            {
                                this.objects.Add(obj);
                            }
                        }
                    }
                    else if (DragAndDrop.paths.Length > 0)
                    {
                        for (int i = 0; i < DragAndDrop.paths.Length; i++)
                        {
                            string path = DragAndDrop.paths[i];
                            if (Directory.Exists(path) == false)
                            {
                                path = new DirectoryInfo(path).Parent.FullName;
                            }

                            if (string.IsNullOrEmpty(path) == false && this.paths.Exists((p) => p.path == path) == false)
                            {
                                this.paths.Add(new PathFiles(path));
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    this.errorPopup.exception = ex;
                }

                Event.current.Use();
            }
            else if (Event.current.type == EventType.Repaint && DragAndDrop.visualMode == DragAndDropVisualMode.Move)
            {
                Utility.DropZone(new Rect(0F, 0F, this.position.width, this.position.height), "Drop folder or asset to rename");
            }

            FreeLicenseOverlay.Last(NGAssemblyInfo.Name + " Pro");
        }
Exemple #11
0
        private static void     OnGUISettings()
        {
            if (HQ.Settings == null)
            {
                return;
            }

            HierarchyEnhancerSettings settings = HQ.Settings.Get <HierarchyEnhancerSettings>();

            EditorGUI.BeginChangeCheck();
            EditorGUILayout.Space();
            using (BgColorContentRestorer.Get(settings.enable == true ? Color.green : Color.red))
            {
                EditorGUILayout.BeginVertical("ButtonLeft");
                {
                    EditorGUILayout.BeginHorizontal();
                    {
                        settings.enable = NGEditorGUILayout.Switch(LC.G("Enable"), settings.enable);
                    }
                    EditorGUILayout.EndHorizontal();
                    EditorGUILayout.LabelField(LC.G("NGHierarchyEnhancer_EnableDescription"), GeneralStyles.WrapLabel);
                }
                EditorGUILayout.EndVertical();
            }

            if (EditorGUI.EndChangeCheck() == true)
            {
                if (settings.enable == false)
                {
                    EditorApplication.hierarchyWindowItemOnGUI -= NGHierarchyEnhancer.DrawOverlay;
                }
                else
                {
                    EditorApplication.hierarchyWindowItemOnGUI += NGHierarchyEnhancer.DrawOverlay;
                }
                HQ.InvalidateSettings();
            }

            EditorGUI.BeginChangeCheck();
            EditorGUILayout.Space();
            EditorGUILayout.LabelField(LC.G("NGHierarchyEnhancer_MarginDescription"), GeneralStyles.WrapLabel);
            settings.margin = EditorGUILayout.FloatField(LC.G("NGHierarchyEnhancer_Margin"), settings.margin);

            EditorGUILayout.Space();
            EditorGUILayout.LabelField(LC.G("NGHierarchyEnhancer_HoldModifiersDescription"), GeneralStyles.WrapLabel);
            settings.holdModifiers = (EventModifiers)EditorGUILayout.MaskField(new GUIContent(LC.G("NGHierarchyEnhancer_HoldModifiers")), (int)settings.holdModifiers, NGHierarchyEnhancer.eventModifierNames);

            EditorGUILayout.Space();
            EditorGUILayout.LabelField(LC.G("NGHierarchyEnhancer_SelectionHoldModifiersDescription"), GeneralStyles.WrapLabel);
            settings.selectionHoldModifiers = (EventModifiers)EditorGUILayout.MaskField(new GUIContent(LC.G("NGHierarchyEnhancer_SelectionHoldModifiers")), (int)settings.selectionHoldModifiers, NGHierarchyEnhancer.eventModifierNames);
            if (EditorGUI.EndChangeCheck() == true)
            {
                HQ.InvalidateSettings();
            }

            EditorGUI.BeginChangeCheck();
            EditorGUILayout.Space();
            EditorGUILayout.LabelField(LC.G("NGHierarchyEnhancer_LayersDescription"), GeneralStyles.WrapLabel);

            float maxLabelWidth = NGHierarchyEnhancer.width;

            for (int i = 0; i < HierarchyEnhancerSettings.TotalLayers; i++)
            {
                string layerName = LayerMask.LayerToName(i);

                if (layerName == string.Empty)
                {
                    layerName = "Layer " + i;
                }

                Utility.content.text = layerName;
                float width = GUI.skin.label.CalcSize(Utility.content).x;
                if (maxLabelWidth < width + 20F)                 // Add width for the icon.
                {
                    maxLabelWidth = width + 20F;
                }
            }

            using (LabelWidthRestorer.Get(maxLabelWidth))
            {
                for (int i = 0; i < HierarchyEnhancerSettings.TotalLayers; i++)
                {
                    string layerName = LayerMask.LayerToName(i);

                    if (layerName == string.Empty)
                    {
                        layerName = "Layer " + i;
                    }

                    EditorGUILayout.BeginHorizontal();

                    // (Label + icon) + color picker
                    Rect r = GUILayoutUtility.GetRect(maxLabelWidth + 40F, 16F, GUI.skin.label);

                    Utility.content.text = layerName;
                    float width = GUI.skin.label.CalcSize(Utility.content).x;

                    settings.layers[i] = EditorGUI.ColorField(r, layerName, settings.layers[i]);
                    r.width            = maxLabelWidth;
                    EditorGUI.DrawRect(r, settings.layers[i]);

                    if (settings.layersIcon[i] != null)
                    {
                        r.x    += width + 2F;                      // Little space before the icon.
                        r.width = 16F;
                        GUI.DrawTexture(r, settings.layersIcon[i], ScaleMode.ScaleToFit);
                    }

                    settings.layersIcon[i] = EditorGUILayout.ObjectField(settings.layersIcon[i], typeof(Texture2D), false) as Texture2D;
                    EditorGUILayout.EndHorizontal();
                }
            }

            if (EditorGUI.EndChangeCheck() == true)
            {
                HQ.InvalidateSettings();
                if (NGHierarchyEnhancer.instance != null)
                {
                    NGHierarchyEnhancer.instance.Repaint();
                }
            }

            EditorGUI.BeginChangeCheck();
            EditorGUILayout.LabelField(LC.G("NGHierarchyEnhancer_WidthPerComponentDescription"), GeneralStyles.WrapLabel);
            settings.widthPerComponent = EditorGUILayout.FloatField(LC.G("NGHierarchyEnhancer_WidthPerComponent"), settings.widthPerComponent);
            if (EditorGUI.EndChangeCheck() == true)
            {
                if (settings.widthPerComponent < -1F)
                {
                    settings.widthPerComponent = -1F;
                }

                HQ.InvalidateSettings();
                if (NGHierarchyEnhancer.instance != null)
                {
                    NGHierarchyEnhancer.instance.Repaint();
                }
            }

            EditorGUI.BeginChangeCheck();
            EditorGUILayout.Space();
            EditorGUILayout.LabelField(LC.G("NGHierarchyEnhancer_DrawUnityComponentsDescription"), GeneralStyles.WrapLabel);
            settings.drawUnityComponents = EditorGUILayout.Toggle(LC.G("NGHierarchyEnhancer_DrawUnityComponents"), settings.drawUnityComponents);
            if (EditorGUI.EndChangeCheck() == true)
            {
                HQ.InvalidateSettings();
                if (NGHierarchyEnhancer.instance != null)
                {
                    NGHierarchyEnhancer.instance.Repaint();
                }
            }

            EditorGUILayout.Space();
            EditorGUILayout.LabelField(LC.G("NGHierarchyEnhancer_ComponentColorsDescription"), GeneralStyles.WrapLabel);

            if (reorder == null)
            {
                NGHierarchyEnhancer.colors  = new List <HierarchyEnhancerSettings.ComponentColor>(settings.componentData);
                NGHierarchyEnhancer.reorder = new ReorderableList(NGHierarchyEnhancer.colors, typeof(HierarchyEnhancerSettings.ComponentColor), true, false, true, true);
                NGHierarchyEnhancer.reorder.headerHeight         = 0F;
                NGHierarchyEnhancer.reorder.drawElementCallback += NGHierarchyEnhancer.DrawComponentType;
                NGHierarchyEnhancer.reorder.onReorderCallback   += (r) => NGHierarchyEnhancer.SerializeComponentColors();
                NGHierarchyEnhancer.reorder.onRemoveCallback    += (r) => {
                    r.list.RemoveAt(r.index);
                    NGHierarchyEnhancer.SerializeComponentColors();
                };
                NGHierarchyEnhancer.reorder.onAddCallback += (r) => {
                    colors.Add(new HierarchyEnhancerSettings.ComponentColor());
                    NGHierarchyEnhancer.SerializeComponentColors();
                };
            }

            reorder.DoLayoutList();
        }
        protected virtual void  OnGUI()
        {
            FreeLicenseOverlay.First(this, NGAssemblyInfo.Name + " Pro", NGShaderFinderWindow.FreeAdContent);

            Rect r = this.position;

            r.x      = 0F;
            r.y      = 0F;
            r.height = NGShaderFinderWindow.SearchButtonHeight;

            EditorGUI.BeginDisabledGroup(this.isSearching);
            {
                r.height = Constants.SingleLineHeight;
                using (LabelWidthRestorer.Get(100F))
                {
                    r.width = this.position.width - NGShaderFinderWindow.FindButtonWidth - NGShaderFinderWindow.FindButtonLeftSpacing;
                    EditorGUI.BeginChangeCheck();
                    Shader newTarget = EditorGUI.ObjectField(r, "Find Shader", this.targetShader, typeof(Shader), false) as Shader;
                    if (EditorGUI.EndChangeCheck() == true)
                    {
                        this.targetShader = newTarget;
                    }
                }
                r.y += r.height + NGShaderFinderWindow.Spacing;

                r.width         = NGShaderFinderWindow.TargetReplaceLabelWidth;
                this.canReplace = GUI.Toggle(r, this.canReplace, "Replace With");
                r.x            += r.width;

                EditorGUI.BeginDisabledGroup(!this.canReplace);
                {
                    r.width            = this.position.width - r.x - NGShaderFinderWindow.SwitchShaderButtonWidth - NGShaderFinderWindow.FindButtonWidth - NGShaderFinderWindow.FindButtonLeftSpacing;
                    this.replaceShader = EditorGUI.ObjectField(r, this.replaceShader, typeof(Shader), false) as Shader;
                }
                EditorGUI.EndDisabledGroup();

                r.x    += r.width;
                r.width = NGShaderFinderWindow.SwitchShaderButtonWidth;
                if (GUI.Button(r, "⇅", GeneralStyles.BigFontToolbarButton) == true)
                {
                    Shader tmp = this.replaceShader;
                    this.replaceShader = this.targetShader;
                    this.targetShader  = tmp;
                }

                r.yMin -= r.height + NGShaderFinderWindow.Spacing;
                r.width = NGShaderFinderWindow.FindButtonWidth;
                r.x     = this.position.width - NGShaderFinderWindow.FindButtonWidth;

                EditorGUI.BeginDisabledGroup(this.targetShader == null || this.isSearching == true);
                {
                    using (BgColorContentRestorer.Get(GeneralStyles.HighlightActionButton))
                    {
                        if (GUI.Button(r, "Find") == true)
                        {
                            this.FindReferences();
                        }
                    }
                }
                EditorGUI.EndDisabledGroup();

                r.y += r.height + NGShaderFinderWindow.Spacing;
            }
            EditorGUI.EndDisabledGroup();

            if (this.canReplace == true)
            {
                EditorGUI.BeginDisabledGroup(this.isSearching == true || this.hasResult == false);
                {
                    using (BgColorContentRestorer.Get(GeneralStyles.HighlightActionButton))
                    {
                        r.x     = 0F;
                        r.width = this.position.width * .5F;
                        if (GUI.Button(r, "Replace") == true)
                        {
                            this.ReplaceReferences(true);
                        }
                        r.x += r.width;

                        if (GUI.Button(r, "Set all") == true)
                        {
                            this.ReplaceReferences(false);
                        }
                        r.y += r.height + NGShaderFinderWindow.Spacing + NGShaderFinderWindow.Spacing;
                    }
                }
                EditorGUI.EndDisabledGroup();
            }

            r.x     = 0F;
            r.width = this.position.width;

            if (this.hasResult == true)
            {
                r.height = Constants.SingleLineHeight;
                GUI.Box(r, string.Empty, GeneralStyles.Toolbar);
                GUI.Label(r, this.resultsHeaderLabel);

                using (BgColorContentRestorer.Get(GeneralStyles.HighlightResultButton))
                {
                    r.xMin = r.xMax - NGShaderFinderWindow.ClearButtonWidth;
                    if (GUI.Button(r, "Clear", GeneralStyles.ToolbarButton) == true)
                    {
                        this.ClearResults();
                    }
                }
                r.y += r.height + NGShaderFinderWindow.Spacing;

                r.x     = 0F;
                r.width = this.position.width;

                Rect bodyRect = r;
                bodyRect.height = this.position.height - r.y;

                Rect viewRect = new Rect(0F, 0F, 0F, (Constants.SingleLineHeight + NGShaderFinderWindow.Spacing) * this.results.Count - NGShaderFinderWindow.Spacing);

                this.scrollPosition = GUI.BeginScrollView(bodyRect, this.scrollPosition, viewRect);
                {
                    float w = r.width - (viewRect.height > bodyRect.height ? 16F : 0F);

                    r.y      = 0F;
                    r.height = Constants.SingleLineHeight;

                    for (int i = 0; i < this.results.Count; i++)
                    {
                        if (r.y + r.height + NGShaderFinderWindow.Spacing <= this.scrollPosition.y)
                        {
                            r.y += r.height + NGShaderFinderWindow.Spacing;
                            continue;
                        }

                        r.x     = 0F;
                        r.width = w - NGShaderFinderWindow.PingButtonWidth;

                        EditorGUI.BeginChangeCheck();
                        Shader o = EditorGUI.ObjectField(r, this.resultsName[i], this.results[i].shader, typeof(Shader), false) as Shader;
                        if (EditorGUI.EndChangeCheck() == true)
                        {
                            Undo.RecordObject(this.results[i], "Replace Material shader");
                            this.results[i].shader = o;
                            EditorUtility.SetDirty(this.results[i]);
                        }

                        r.x    += r.width;
                        r.width = NGShaderFinderWindow.PingButtonWidth;
                        NGEditorGUILayout.PingObject(r, LC.G("Ping"), this.results[i]);
                        r.y += r.height + NGShaderFinderWindow.Spacing;

                        if (r.y - this.scrollPosition.y > bodyRect.height)
                        {
                            break;
                        }
                    }
                }
                GUI.EndScrollView();
            }

            FreeLicenseOverlay.Last(NGAssemblyInfo.Name + " Pro");
        }
Exemple #13
0
        private void    DrawSelection()
        {
            if (Selection.activeGameObject != this.selectionTarget)
            {
                this.selectionTarget = Selection.activeGameObject;

                if (Selection.activeGameObject != null)
                {
                    this.Diagnose(Selection.activeGameObject);
                }
                else
                {
                    this.target = null;
                }
            }

            if (this.target == null)
            {
                if (this.selectionTarget == null)
                {
                    GUILayout.Label("Select a prefab (or an instance of it) to diagnose", GeneralStyles.BigCenterText, GUILayoutOptionPool.ExpandHeightTrue);
                }
                else
                {
                    GUILayout.Label("No diagnostic available", GeneralStyles.BigCenterText, GUILayoutOptionPool.ExpandHeightTrue);
                }
                return;
            }

            if (this.selectedMissing >= 0)
            {
                EditorGUILayout.BeginHorizontal(GeneralStyles.Toolbar);
                {
                    EditorGUI.BeginDisabledGroup(this.selectedMissing <= 0);
                    {
                        if (GUILayout.Button("<<", GeneralStyles.ToolbarButton, GUILayoutOptionPool.MaxWidth(100F)) == true)
                        {
                            --this.selectedMissing;
                            this.Diagnose(this.missings[this.selectedMissing].gameObject);
                        }
                    }
                    EditorGUI.EndDisabledGroup();

                    NGEditorGUILayout.PingObject(this.missings[this.selectedMissing].path, this.missings[this.selectedMissing].gameObject, GeneralStyles.ToolbarButton);

                    EditorGUI.BeginDisabledGroup(this.selectedMissing >= this.missings.Count - 1);
                    {
                        if (GUILayout.Button(">>", GeneralStyles.ToolbarButton, GUILayoutOptionPool.MaxWidth(100F)) == true)
                        {
                            ++this.selectedMissing;
                            this.Diagnose(this.missings[this.selectedMissing].gameObject);
                        }
                    }
                    EditorGUI.EndDisabledGroup();
                }
                EditorGUILayout.EndHorizontal();
            }
            else
            {
                Utility.content.text  = this.target.name;
                Utility.content.image = Utility.GetIcon(this.target.GetInstanceID());
                EditorGUILayout.LabelField(Utility.content);
                Utility.content.image = null;
            }

            this.scrollPosition = EditorGUILayout.BeginScrollView(this.scrollPosition);
            {
                for (int i = 0; i < this.rawComponents.Count; i++)
                {
                    this.rawComponents[i].Draw(this);
                }
            }
            EditorGUILayout.EndScrollView();
        }
Exemple #14
0
        protected override void OnGUIHeader()
        {
            bool has = false;

            for (int i = 0; i < this.Hierarchy.ImportingAssetsParams.Count; i++)
            {
                if (this.Hierarchy.ImportingAssetsParams[i].localAsset == null &&
                    this.Hierarchy.ImportingAssetsParams[i].isSupported == true &&
                    this.Hierarchy.ImportingAssetsParams[i].originPath != null)
                {
                    has = true;
                    break;
                }
            }

            EditorGUILayout.BeginHorizontal(GeneralStyles.Toolbar);
            {
                if (GUILayout.Button("☰", "GV Gizmo DropDown", GUILayoutOptionPool.ExpandWidthFalse) == true)
                {
                    PopupWindow.Show(new Rect(0F, 16F, 0F, 0F), new OptionsPopup(this));
                }

                EditorGUI.BeginChangeCheck();
                NGEditorGUILayout.OutlineToggle("Prefabs", this.tab == Tab.Prefabs);
                if (EditorGUI.EndChangeCheck() == true)
                {
                    this.tab = Tab.Prefabs;
                }

                EditorGUI.BeginChangeCheck();
                NGEditorGUILayout.OutlineToggle("Assets", this.tab == Tab.Assets);
                if (EditorGUI.EndChangeCheck() == true)
                {
                    this.tab = Tab.Assets;
                }

                GUILayout.FlexibleSpace();

                if (has == true && this.Hierarchy.IsClientConnected() == true)
                {
                    if (GUILayout.Button("Set Auto to all", GeneralStyles.ToolbarButton) == true)
                    {
                        for (int i = 0; i < this.Hierarchy.ImportingAssetsParams.Count; i++)
                        {
                            if (this.Hierarchy.ImportingAssetsParams[i].localAsset == null &&
                                this.Hierarchy.ImportingAssetsParams[i].isSupported == true &&
                                this.Hierarchy.ImportingAssetsParams[i].originPath != null)
                            {
                                this.Hierarchy.ImportingAssetsParams[i].importMode = ImportMode.Auto;
                            }
                        }
                    }

                    GUILayout.Space(10F);

                    if (GUILayout.Button("Confirm all", GeneralStyles.ToolbarButton) == true)
                    {
                        for (int i = 0; i < this.Hierarchy.ImportingAssetsParams.Count; i++)
                        {
                            this.Hierarchy.ImportingAssetsParams[i].Confirm();
                        }
                    }
                }
            }
            EditorGUILayout.EndHorizontal();
        }
        private static void     OnGUISettings()
        {
            if (HQ.Settings == null)
            {
                return;
            }

            NavSettings settings = HQ.Settings.Get <NavSettings>();

            if (Application.platform != RuntimePlatform.WindowsEditor)
            {
                EditorGUILayout.LabelField(LC.G("NGNavSelection_OnlyAvailableOnWindows"), GeneralStyles.WrapLabel);
            }

            EditorGUI.BeginChangeCheck();
            EditorGUILayout.Space();
            using (BgColorContentRestorer.Get(settings.enable == true ? Color.green : Color.red))
            {
                EditorGUILayout.BeginVertical("ButtonLeft");
                {
                    EditorGUILayout.BeginHorizontal();
                    {
                        settings.enable = NGEditorGUILayout.Switch(LC.G("Enable"), settings.enable);
                    }
                    EditorGUILayout.EndHorizontal();
                    EditorGUILayout.LabelField(LC.G("NGNavSelection_EnableDescription"), GeneralStyles.WrapLabel);
                }
                EditorGUILayout.EndVertical();
            }

            if (EditorGUI.EndChangeCheck() == true)
            {
                if (settings.enable == false)
                {
                    Selection.selectionChanged -= NGNavSelectionWindow.UpdateSelection;
#if !UNITY_2017_2_OR_NEWER
                    EditorApplication.playmodeStateChanged -= NGNavSelectionWindow.OnPlayStateChanged;
#else
                    EditorApplication.playModeStateChanged -= NGNavSelectionWindow.OnPlayStateChanged;
#endif
                }
                else
                {
                    Selection.selectionChanged += NGNavSelectionWindow.UpdateSelection;
#if !UNITY_2017_2_OR_NEWER
                    EditorApplication.playmodeStateChanged += NGNavSelectionWindow.OnPlayStateChanged;
#else
                    EditorApplication.playModeStateChanged += NGNavSelectionWindow.OnPlayStateChanged;
#endif
                }
                HQ.InvalidateSettings();
            }

            EditorGUI.BeginChangeCheck();
            EditorGUILayout.Space();
            EditorGUILayout.LabelField(LC.G("NGNavSelection_MaxHistoricDescription"), GeneralStyles.WrapLabel);
            settings.maxHistoric = EditorGUILayout.IntField(LC.G("NGNavSelection_MaxHistoric"), settings.maxHistoric);
            if (EditorGUI.EndChangeCheck() == true)
            {
                settings.maxHistoric = Mathf.Clamp(settings.maxHistoric, 1, NGNavSelectionWindow.MaxHistoric);
                HQ.InvalidateSettings();
            }

            EditorGUI.BeginChangeCheck();
            EditorGUILayout.Space();
            EditorGUILayout.LabelField(LC.G("NGNavSelection_MaxDisplayHierarchyDescription"), GeneralStyles.WrapLabel);
            settings.maxDisplayHierarchy = EditorGUILayout.IntField(LC.G("NGNavSelection_MaxDisplayHierarchy"), settings.maxDisplayHierarchy);
            if (EditorGUI.EndChangeCheck() == true)
            {
                if (settings.maxDisplayHierarchy < -1)
                {
                    settings.maxDisplayHierarchy = -1;
                }
                HQ.InvalidateSettings();
            }
        }
Exemple #16
0
        private void    DrawPrefabs()
        {
            EditorGUILayout.BeginHorizontal();
            {
                for (int i = 0; i < this.Hierarchy.PendingPrefabs.Count; i++)
                {
                    EditorGUI.BeginChangeCheck();
                    NGEditorGUILayout.OutlineToggle(this.Hierarchy.PendingPrefabs[i].rootGameObject.gameObject.name, this.selectedPrefab == i);
                    if (EditorGUI.EndChangeCheck() == true)
                    {
                        this.selectedPrefab = i;
                    }
                }

                GUILayout.FlexibleSpace();
            }
            EditorGUILayout.EndHorizontal();

            if (this.selectedPrefab < this.Hierarchy.PendingPrefabs.Count)
            {
                PrefabConstruct prefab = this.Hierarchy.PendingPrefabs[this.selectedPrefab];

                GUILayout.Space(10F + 32F);

                Rect r = GUILayoutUtility.GetLastRect();

                r.xMin += 20F;
                r.width = 150F;
                if (GUI.Button(r, prefab.rootGameObject.gameObject.name) == true)
                {
                    this.Hierarchy.PingObject(prefab.rootGameObject.gameObject.instanceID);
                }

                r.x += r.width + 10F;

                if (prefab.constructionError != null)
                {
                    EditorGUI.HelpBox(r, prefab.constructionError, MessageType.Error);
                }
                else if (prefab.outputPath != null)
                {
                    if (GUI.Button(r, "Local Prefab", GeneralStyles.ToolbarDropDown) == true)
                    {
                        EditorGUIUtility.PingObject(AssetDatabase.LoadAssetAtPath(prefab.outputPath, typeof(Object)));
                    }
                }

                r.width = 20F;
                if (GUI.Button(r, GUIContent.none, GeneralStyles.ToolbarDropDown) == true)
                {
                }

                GUILayout.Space(11F);

                r = GUILayoutUtility.GetLastRect();

                r.y     += r.height - 1F;
                r.height = 1F;
                r.width  = this.position.width;
                EditorGUI.DrawRect(r, Color.cyan);
                r.y     += 1F;
                r.height = 20F;

                Rect rH = r;
                rH.width = Mathf.Round(rH.width * .33F);
                GUI.Label(rH, "Hierarchy");

                rH.y     += rH.height;
                rH.height = prefab.rootGameObject.GetHeight();

                Rect view = new Rect(0F, 0F, 0F, rH.height);

                this.hierarchyScrollPosition = GUI.BeginScrollView(rH, this.hierarchyScrollPosition, view);
                {
                    rH.y      = 0F;
                    rH.height = Constants.SingleLineHeight;
                    prefab.rootGameObject.DrawGameObject(rH, this);
                }
                GUI.EndScrollView();

                Rect rI = r;
                rI.x += rH.width;

                rI.width  = 1F;
                rI.height = this.position.height - rI.y;
                rI.y     += 1F;
                EditorGUI.DrawRect(rI, Color.cyan);
                rI.y -= 1F;
                rI.x += 1F;

                rI.width  = this.position.width - rH.xMax - 1F;
                rI.height = Constants.SingleLineHeight;
                GUI.Label(rI, "Inspector");

                rI.y     += rI.height;
                rI.height = this.position.height - rI.yMax;

                if (this.selectedGameObject != null)
                {
                    if (this.selectedGameObject.components != null)
                    {
                        if (this.selectedGameObject.components.Length > 0)
                        {
                            view.height = 0F;
                            for (int i = 0; i < this.selectedGameObject.components.Length; i++)
                            {
                                view.height += this.selectedGameObject.components[i].GetHeight(this, Hierarchy);
                            }
                        }
                        else
                        {
                            view.height = 32F;
                        }

                        this.inspectorScrollPosition = GUI.BeginScrollView(rI, this.inspectorScrollPosition, view);
                        {
                            rI.x = 0F;
                            rI.y = 0F;

                            if (this.selectedGameObject.components.Length > 0)
                            {
                                for (int i = 0; i < this.selectedGameObject.components.Length; i++)
                                {
                                    rI.height = this.selectedGameObject.components[i].GetHeight(this, Hierarchy);
                                    this.selectedGameObject.components[i].DrawComponent(rI, this, this.Hierarchy);
                                    rI.y += rI.height;
                                }
                            }
                            else
                            {
                                rI.height = 32F;
                                rI.xMin  += 5F;
                                rI.xMax  -= 5F;
                                EditorGUI.HelpBox(rI, "Does not contain a Component with importable assets.", MessageType.Info);
                            }
                        }
                        GUI.EndScrollView();
                    }
                    else
                    {
                        EditorGUI.HelpBox(rI, "Loading Components.", MessageType.Info);
                        GUI.Label(rI, GeneralStyles.StatusWheel);
                    }
                }
            }
        }
Exemple #17
0
        private void    DrawRecovery()
        {
            if (this.currentGameObject >= this.missings.Count)
            {
                EditorGUILayout.HelpBox("Recovery finished.", MessageType.Info);
                return;
            }

            EditorGUILayout.BeginHorizontal(GeneralStyles.Toolbar);
            {
                if (GUILayout.Button((this.currentGameObject + 1) + " / " + this.missings.Count + " ☰", "GV Gizmo DropDown", GUILayoutOptionPool.ExpandWidthFalse) == true)
                {
                    GenericMenu menu = new GenericMenu();

                    for (int i = 0; i < this.missings.Count; i++)
                    {
                        menu.AddItem(new GUIContent(this.missings[i].path), false, (n) => this.currentGameObject = (int)n, i);
                    }

                    menu.ShowAsContext();
                }

                GUILayout.FlexibleSpace();

                if (GUILayout.Button("Stop", GeneralStyles.ToolbarButton, GUILayoutOptionPool.Width(100F)) == true)
                {
                    this.isRecovering = false;
                    this.tab          = Tab.Project;
                    return;
                }
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal(GeneralStyles.Toolbar);
            {
                EditorGUI.BeginDisabledGroup(this.currentGameObject <= 0);
                {
                    if (GUILayout.Button("<<", GeneralStyles.ToolbarButton, GUILayoutOptionPool.Width(50F)) == true)
                    {
                        --this.currentGameObject;
                        this.isPausing = false;
                        this.skipFix   = true;
                    }
                }
                EditorGUI.EndDisabledGroup();

                NGEditorGUILayout.PingObject(this.missings[this.currentGameObject].path, this.missings[this.currentGameObject].gameObject, GeneralStyles.ToolbarButton);

                EditorGUI.BeginDisabledGroup(this.currentGameObject >= this.missings.Count - 1);
                {
                    if (GUILayout.Button(">>", GeneralStyles.ToolbarButton, GUILayoutOptionPool.Width(50F)) == true)
                    {
                        ++this.currentGameObject;
                        this.isPausing = false;
                        this.skipFix   = true;
                    }

                    if (GUILayout.Button("Skip", GeneralStyles.ToolbarButton, GUILayoutOptionPool.Width(100F)) == true)
                    {
                        ++this.currentGameObject;
                        this.isPausing = false;
                    }
                }
                EditorGUI.EndDisabledGroup();
            }
            EditorGUILayout.EndHorizontal();

            this.PostDiagnostic        += this.OnPostDiagnosticManualRecovery;
            this.scrollPositionRecovery = EditorGUILayout.BeginScrollView(this.scrollPositionRecovery);
            {
                for (int i = 0; i < this.rawComponents.Count; i++)
                {
                    this.rawComponents[i].Draw(this);
                }
            }
            EditorGUILayout.EndScrollView();
            this.PostDiagnostic -= this.OnPostDiagnosticManualRecovery;
        }
Exemple #18
0
        private void    DrawProject()
        {
            GUILayout.Space(5F);

            EditorGUILayout.BeginVertical("ButtonLeft");
            {
                this.openAutoRecovery = EditorGUILayout.Foldout(this.openAutoRecovery, "Recovery Settings (" + Enum.GetName(typeof(RecoveryMode), this.recoveryMode) + ")");

                if (this.openAutoRecovery == true)
                {
                    this.recoveryMode = (RecoveryMode)EditorGUILayout.EnumPopup("Recovery Mode", this.recoveryMode);

                    if (this.recoveryMode == RecoveryMode.Automatic)
                    {
                        this.promptOnPause       = EditorGUILayout.Toggle(this.promptOnPauseContent, this.promptOnPause);
                        this.useCache            = EditorGUILayout.Toggle(this.useCacheContent, this.useCache);
                        this.supaFast            = EditorGUILayout.Toggle(supaFastContent, this.supaFast);
                        this.recoveryLogFilePath = NGEditorGUILayout.SaveFileField("Recovery Log File", this.recoveryLogFilePath);
                    }

                    GUILayout.Space(5F);
                }
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            {
                using (BgColorContentRestorer.Get(GeneralStyles.HighlightActionButton))
                {
                    if (GUILayout.Button("Scan", GeneralStyles.BigButton) == true)
                    {
                        string[] assets = AssetDatabase.GetAllAssetPaths();

                        this.hasResult       = true;
                        this.selectedMissing = -1;
                        this.missings.Clear();

                        try
                        {
                            for (int i = 0; i < assets.Length; i++)
                            {
                                if (assets[i].EndsWith(".prefab") == false)
                                {
                                    continue;
                                }

                                if (EditorUtility.DisplayCancelableProgressBar(NGMissingScriptRecoveryWindow.NormalTitle, "Scanning " + assets[i], (float)i / (float)assets.Length) == true)
                                {
                                    break;
                                }

                                Object[] content = AssetDatabase.LoadAllAssetsAtPath(assets[i]);

                                for (int j = 0; j < content.Length; j++)
                                {
                                    GameObject go = content[j] as GameObject;

                                    if (go != null)
                                    {
                                        Component[] components = go.GetComponents <Component>();

                                        for (int k = 0; k < components.Length; k++)
                                        {
                                            if (components[k] == null)
                                            {
                                                this.missings.Add(new MissingGameObject(go));
                                                break;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        finally
                        {
                            EditorUtility.ClearProgressBar();
                        }

                        return;
                    }
                }

                GUILayout.FlexibleSpace();

                if (this.cachedComponentFixes.Count > 0)
                {
                    if (GUILayout.Button("Clear Recovery Cache (" + this.cachedComponentFixes.Count + " elements)", GeneralStyles.BigButton) == true)
                    {
                        this.cachedComponentFixes.Clear();
                    }
                }
            }
            EditorGUILayout.EndHorizontal();

            if (this.hasResult == true)
            {
                EditorGUILayout.BeginHorizontal(GeneralStyles.Toolbar);
                {
                    GUILayout.Label("Result");

                    GUILayout.FlexibleSpace();

                    if (GUILayout.Button("X", GeneralStyles.ToolbarCloseButton) == true)
                    {
                        this.hasResult = false;
                    }
                }
                EditorGUILayout.EndHorizontal();

                if (this.missings.Count == 0)
                {
                    GUILayout.Label("No missing script found.");
                }
                else
                {
                    this.scrollPositionResult = EditorGUILayout.BeginScrollView(this.scrollPositionResult);
                    {
                        for (int i = 0; i < this.missings.Count; i++)
                        {
                            EditorGUILayout.BeginHorizontal();
                            {
                                NGEditorGUILayout.PingObject(this.missings[i].path, this.missings[i].gameObject, GeneralStyles.LeftButton);

                                if (GUILayout.Button("Fix", GUILayoutOptionPool.Width(75F)) == true)
                                {
                                    this.selectedMissing = i;
                                    this.tab             = 0;
                                    this.Diagnose(this.missings[i].gameObject);
                                }
                            }
                            EditorGUILayout.EndHorizontal();
                        }
                    }
                    EditorGUILayout.EndScrollView();

                    GUILayout.FlexibleSpace();

                    EditorGUILayout.BeginHorizontal();
                    {
                        GUILayout.FlexibleSpace();

                        if (this.recoveryMode == RecoveryMode.Automatic)
                        {
                            EditorGUILayout.HelpBox("Backup your project before\ndoing any automatic recovery.", MessageType.Warning);
                        }

                        using (BgColorContentRestorer.Get(GeneralStyles.HighlightResultButton))
                        {
                            if (GUILayout.Button("Start Recovery", GeneralStyles.BigButton) == true)
                            {
                                Utility.StartBackgroundTask(this.RecoveryTask());
                            }
                        }
                    }
                    EditorGUILayout.EndHorizontal();
                }
            }
        }
Exemple #19
0
        protected virtual void  OnGUI()
        {
            EditorGUILayout.BeginHorizontal(GeneralStyles.Toolbar);
            {
                if (GUILayout.Button("Open", GeneralStyles.ToolbarButton, GUILayoutOptionPool.Width(100F)) == true)
                {
                    this.OpenReplay();
                }

                for (int i = 0; i < this.replays.Count; i++)
                {
                    EditorGUI.BeginChangeCheck();
                    NGEditorGUILayout.OutlineToggle(this.replays[i].name, i == this.currentReplay);
                    if (EditorGUI.EndChangeCheck() == true)
                    {
                        if (Event.current.button == 2)
                        {
                            this.replays.RemoveAt(i);
                            return;
                        }
                        else if (Event.current.button == 1)
                        {
                            GenericMenu menu = new GenericMenu();

                            menu.AddItem(new GUIContent("Delete"), false, (d) => this.replays.RemoveAt((int)d), i);
                            menu.ShowAsContext();
                            return;
                        }
                        else
                        {
                            if (this.currentReplay >= 0 && this.currentReplay < this.replays.Count)
                            {
                                this.replays[this.currentReplay].Pause();
                            }

                            this.currentReplay = i;
                        }
                    }
                }

                GUILayout.FlexibleSpace();
            }
            EditorGUILayout.EndHorizontal();

            if (this.replays.Count == 0)
            {
                if (GUILayout.Button("No replay loaded yet, please open one.", GeneralStyles.BigCenterText, GUILayoutOptionPool.ExpandHeightTrue) == true)
                {
                    this.OpenReplay();
                }
            }

            if (this.currentReplay >= 0 && this.currentReplay < this.replays.Count)
            {
                Replay replay = this.replays[this.currentReplay];

                EditorGUILayout.BeginHorizontal(GeneralStyles.Toolbar);
                {
                    if (replay.canSave == true)
                    {
                        if (GUILayout.Button("Save", GeneralStyles.ToolbarButton, GUILayoutOptionPool.Width(100F)) == true)
                        {
                            string filepath = EditorUtility.SaveFilePanel("Save Replay", ".", PlayerSettings.productName + "_" + DateTime.Now.ToString("yyyyMMdd_HHmmss"), NGReplayWindow.ReplayExtension);

                            if (string.IsNullOrEmpty(filepath) == false)
                            {
                                if (replay.Save(filepath) == false)
                                {
                                    InternalNGDebug.LogError("An error occurred. Replay could not been saved at \"" + filepath + "\".");
                                }
                                else
                                {
                                    InternalNGDebug.Log("Replay saved at \"" + filepath + "\".");
                                }
                            }
                        }
                    }

                    if (GUILayout.Button("<", GeneralStyles.ToolbarButton, GUILayoutOptionPool.Width(35F)) == true)
                    {
                        replay.Pause();
                        replay.Set(replay.cursorTime - .1F);
                    }
                    if (GUILayout.Button(">", GeneralStyles.ToolbarButton, GUILayoutOptionPool.Width(35F)) == true)
                    {
                        replay.Pause();
                        replay.Set(replay.cursorTime + .1F);
                    }

                    if (replay.playing == false)
                    {
                        if (GUILayout.Button("►", GeneralStyles.ToolbarButton, GUILayoutOptionPool.Width(75F)) == true)
                        {
                            replay.Play();
                        }
                    }
                    else
                    {
                        if (GUILayout.Button("▮▮", GeneralStyles.ToolbarButton, GUILayoutOptionPool.Width(75F)) == true)
                        {
                            replay.Pause();
                        }
                    }

                    if (GUILayout.Button("■", GeneralStyles.ToolbarButton, GUILayoutOptionPool.Width(75F)) == true)
                    {
                        replay.Stop();
                    }

                    GUILayout.FlexibleSpace();

                    using (LabelWidthRestorer.Get(50F))
                    {
                        replay.speed = EditorGUILayout.FloatField("Speed", replay.speed, GUILayoutOptionPool.Width(75F));
                    }

                    EditorGUI.BeginChangeCheck();
                    Utility.content.text    = " ∞ ";
                    Utility.content.tooltip = "Repeat";
                    GUILayout.Toggle(replay.repeat, Utility.content, GeneralStyles.ToolbarButton);
                    if (EditorGUI.EndChangeCheck() == true)
                    {
                        replay.repeat = !replay.repeat;
                    }

                    for (int i = 0; i < replay.modules.Count; i++)
                    {
                        replay.modules[i].OnGUIOptions(this);
                    }

                    Rect r2 = GUILayoutUtility.GetRect(new GUIContent("Modules"), GeneralStyles.ToolbarDropDown);
                    if (GUI.Button(r2, "Modules", GeneralStyles.ToolbarDropDown) == true)
                    {
                        GenericMenu menu = new GenericMenu();

                        for (int i = 0; i < replay.modules.Count; i++)
                        {
                            if (replay.modules[i].moduleID == ScreenshotModule.ModuleID)
                            {
                                continue;
                            }

                            menu.AddItem(new GUIContent(replay.modules[i].name), replay.modules[i].active, this.ToggleModule, replay.modules[i]);
                        }

                        menu.DropDown(r2);
                    }

                    if (Conf.DebugMode != Conf.DebugState.None)
                    {
                        EditorGUI.BeginChangeCheck();
                        GUILayout.Toggle(this.showDBG, "DBG", GeneralStyles.ToolbarButton);
                        if (EditorGUI.EndChangeCheck() == true)
                        {
                            this.showDBG = !this.showDBG;
                        }
                    }
                }
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                {
                    EditorGUI.BeginChangeCheck();
                    float t = EditorGUILayout.Slider(replay.cursorTime, 0F, replay.maxTime);
                    if (EditorGUI.EndChangeCheck() == true)
                    {
                        replay.Pause();
                        replay.Set(t, true);
                    }

                    GUILayout.Label("/ " + replay.maxTime, GUILayoutOptionPool.ExpandWidthFalse);
                }
                EditorGUILayout.EndHorizontal();

                Rect r = GUILayoutUtility.GetRect(0F, 0F, GUILayoutOptionPool.ExpandWidthTrue, GUILayoutOptionPool.ExpandHeightTrue);

                for (int i = 0; i < replay.modules.Count; i++)
                {
                    if (replay.modules[i].active == true)
                    {
                        replay.modules[i].OnGUIReplay(r);
                    }
                }

                if (Conf.DebugMode != Conf.DebugState.None && this.showDBG == true)
                {
                    EditorGUILayout.LabelField("Time Offset", replay.realTimeOffset.ToString());

                    for (int i = 0; i < replay.modules.Count; i++)
                    {
                        if (replay.modules[i].active == true)
                        {
                            replay.modules[i].OnGUIDBG();
                        }
                    }
                }
            }
        }
Exemple #20
0
        private void    DrawComponent(ComponentContainer container)
        {
            Editor e = Editor.CreateEditor(container.component);

            EditorGUILayout.BeginHorizontal();
            {
                GUILayout.Space(2F);

                Rect r = GUILayoutUtility.GetRect(0F, 16F, GUILayoutOptionPool.Width(20F));

                GUI.DrawTexture(r, container.gameObjectIcon);

                NGEditorGUILayout.PingObject(container.component.name, container.component.gameObject, GUILayoutOptionPool.Height(16F));

                container.useDefaultEditor = GUILayout.Toggle(container.useDefaultEditor, new GUIContent("No Custom Editor", "Use default editor."), GeneralStyles.ToolbarToggle, GUILayoutOptionPool.ExpandWidthFalse);
            }
            EditorGUILayout.EndHorizontal();

            GUILayout.Space(4F);

            EditorGUILayout.BeginHorizontal();
            {
                GUILayout.Space(2F);

                Rect r = GUILayoutUtility.GetRect(0F, 16F, GUILayoutOptionPool.Width(20F));

                if (container.componentIcons[container.workingComponentIndex] != null)
                {
                    GUI.DrawTexture(r, container.componentIcons[container.workingComponentIndex]);
                }

                GUILayout.Space(5F);

                r = GUILayoutUtility.GetRect(0F, 16F, GUILayoutOptionPool.Width(16F));

                int enabled = EditorUtility.GetObjectEnabled(container.component);
                if (enabled != -1)
                {
                    EditorGUI.BeginChangeCheck();
                    EditorGUI.Toggle(r, enabled == 1);
                    if (EditorGUI.EndChangeCheck() == true)
                    {
                        EditorUtility.SetObjectEnabled(container.component, enabled != 1);
                    }
                }

                EditorGUI.BeginChangeCheck();
                int n = EditorGUILayout.Popup(container.workingComponentIndex, container.componentNames);
                if (EditorGUI.EndChangeCheck() == true)
                {
                    Component[] components = container.component.gameObject.GetComponents <Component>();

                    if (n < components.Length)
                    {
                        container.Init(components[n]);
                    }
                }
            }
            EditorGUILayout.EndHorizontal();

            // Exception for Transform, its Editor messes the GUI up.
            if (container.useDefaultEditor == true || container.component is Transform)
            {
                e.DrawDefaultInspector();
            }
            else
            {
                e.OnInspectorGUI();
            }
        }
Exemple #21
0
        private void    DrawBuildSceneRow(Rect r, EditorBuildSettingsScene scene, int i)
        {
            float w = r.width - 4F;

            if (Event.current.type == EventType.Repaint && r.Contains(Event.current.mousePosition) == true)
            {
                if (DragAndDrop.visualMode == DragAndDropVisualMode.Move)
                {
                    float h = r.height;
                    r.height = 1F;
                    EditorGUI.DrawRect(r, Color.green);
                    r.height = h;
                }
            }
            else if (Event.current.type == EventType.DragUpdated && r.Contains(Event.current.mousePosition) == true)
            {
                bool one = false;

                for (int j = 0; j < DragAndDrop.paths.Length; j++)
                {
                    if (DragAndDrop.paths[j].EndsWith(".unity", StringComparison.OrdinalIgnoreCase) == true)
                    {
                        one = true;
                        break;
                    }
                }

                if (one == true)
                {
                    DragAndDrop.visualMode = DragAndDropVisualMode.Move;
                }
                else
                {
                    DragAndDrop.visualMode = DragAndDropVisualMode.Rejected;
                }
            }
            else if (Event.current.type == EventType.DragPerform && r.Contains(Event.current.mousePosition) == true)
            {
                if (DragAndDrop.paths.Length > 0)
                {
                    DragAndDrop.AcceptDrag();

                    List <EditorBuildSettingsScene> scenes = new List <EditorBuildSettingsScene>(EditorBuildSettings.scenes);

                    for (int j = 0; j < DragAndDrop.paths.Length; j++)
                    {
                        if (DragAndDrop.paths[j].EndsWith(".unity", StringComparison.OrdinalIgnoreCase) == true)
                        {
                            scenes.Insert(i++, new EditorBuildSettingsScene(DragAndDrop.paths[j], true));
                        }
                    }

                    EditorBuildSettings.scenes = scenes.ToArray();

                    Event.current.Use();
                }
            }

            EditorGUI.BeginDisabledGroup(!File.Exists(scene.path));
            {
                r.x    += 4F;
                r.width = 20F;
                EditorGUI.BeginChangeCheck();
                bool enabled = GUI.Toggle(r, scene.enabled, string.Empty);
                if (EditorGUI.EndChangeCheck() == true)
                {
                    EditorBuildSettingsScene[] scenes = EditorBuildSettings.scenes.Clone() as EditorBuildSettingsScene[];

                    scenes[i] = new EditorBuildSettingsScene(scene.path, enabled);
                    EditorBuildSettings.scenes = scenes;
                }

                string path;

                if (this.shrinkedPaths.TryGetValue(scene.path, out path) == false)
                {
                    int start  = 0;
                    int length = scene.path.Length;

                    if (scene.path.StartsWith("Assets/") == true)
                    {
                        start   = "Assets/".Length;
                        length -= start;
                    }

                    if (scene.path.EndsWith(".unity", StringComparison.OrdinalIgnoreCase) == true)
                    {
                        length -= ".unity".Length;
                    }

                    path = scene.path.Substring(start, length);
                    this.shrinkedPaths.Add(scene.path, path);
                }

                r.x += r.width;
                if (scene.enabled == true)
                {
                    Utility.content.text = this.enabledScenesCounter.ToCachedString();
                    float indexWidth = GUI.skin.label.CalcSize(Utility.content).x;
                    r.width = w - r.x - indexWidth;
                    NGEditorGUILayout.ElasticLabel(r, path, '/');

                    r.x    += r.width;
                    r.width = indexWidth;
                    GUI.Label(r, this.enabledScenesCounter.ToCachedString());
                    ++this.enabledScenesCounter;
                }
                else
                {
                    r.width = w - r.x;
                    GUI.Label(r, path);
                }
            }
            EditorGUI.EndDisabledGroup();
        }
        public void     DrawAssetImportParams(Rect r2, ImportAssetsWindow importAssetsWindow)
        {
            this.updateWindow = importAssetsWindow;
            //string	gameObjectName = parameter.gameObjectName;

            //if (gameObjectName == null)
            //	gameObjectName = parameter.gameObjectName = this.hierarchy.GetGameObjectName(parameter.gameObjectInstanceID);

            float w = r2.width;

            r2.height = Constants.SingleLineHeight;
            //Rect	r2 = GUILayoutUtility.GetRect(22F, Constants.SingleLineHeight);
            bool canRemember = this.localAsset == null &&
                               this.isSupported == true;

            if (Event.current.type == EventType.MouseDown)
            {
                if (canRemember == true)
                {
                    r2.width -= AssetImportParameters.RememberLabelWidth + AssetImportParameters.RememberSpacing + AssetImportParameters.LocationButtonWidth;
                }
                else
                {
                    r2.width -= AssetImportParameters.LocationButtonWidth;
                }

                //if (r2.Contains(Event.current.mousePosition) == true)
                //{
                //	this.hierarchy.PingObject(this.gameObjectInstanceID);
                //	Event.current.Use();
                //}

                if (canRemember == true)
                {
                    r2.width += AssetImportParameters.RememberLabelWidth + AssetImportParameters.RememberSpacing + AssetImportParameters.LocationButtonWidth;
                }
                else
                {
                    r2.width += AssetImportParameters.LocationButtonWidth;
                }
            }

            GUI.Box(r2, string.Empty, GeneralStyles.Toolbar);

            //if (Event.current.type == EventType.Repaint)
            //{
            //	Rect	r3 = r2;
            //	r3.width = 1F;
            //	r3.height = r3.height * 4F + 6F;

            //	//EditorGUI.DrawRect(r3, Color.cyan);
            //}

            r2.width = ImportAssetsWindow.GameObjectIconWidth;
            GUI.DrawTexture(r2, AssetPreview.GetMiniTypeThumbnail(this.type), ScaleMode.ScaleToFit);
            r2.x += r2.width;

            string name = this.name ?? (this.name = this.hierarchy.GetResourceName(this.type, this.instanceID));

            if (name == null)
            {
                GUI.Label(r2, GeneralStyles.StatusWheel);
                r2.x += r2.width;

                r2.width = w - r2.x;
                GUI.Label(r2, this.type.Name);
                importAssetsWindow.Repaint();
            }
            else
            {
                r2.width = w - r2.x;
                GUI.Label(r2, this.type.Name + " : " + this.name);
            }

            r2.x     = r2.width + ImportAssetsWindow.GameObjectIconWidth - AssetImportParameters.RememberLabelWidth - AssetImportParameters.RememberSpacing - AssetImportParameters.LocationButtonWidth;
            r2.width = AssetImportParameters.RememberLabelWidth;
            if (canRemember == true)
            {
                this.remember = GUI.Toggle(r2, this.remember, "Remember", GeneralStyles.ToolbarToggle);
            }

            r2.x    += r2.width + AssetImportParameters.RememberSpacing;
            r2.width = AssetImportParameters.LocationButtonWidth;
            if (GUI.Button(r2, "Locations (" + this.originPath.Count + ")", GeneralStyles.ToolbarButton) == true)
            {
                PopupWindow.Show(r2, new AssetLocationsWindow(this.hierarchy, this.originPath));
                //importAssets2.importingAssetsParams.Remove(this);
            }

            r2.y    += r2.height + 2F;
            r2.x     = 5F;
            r2.width = w - r2.x;

            using (LabelWidthRestorer.Get(120F))
            {
                int pathsCount = this.originPath.Count;
                //if (pathsCount == 1)
                //	EditorGUI.LabelField(r2, "Component Path", this.originPath[0]);
                //else if (pathsCount > 1)
                //{
                //	EditorGUI.LabelField(r2, "Component Path", string.Empty);

                //	r2.xMin += EditorGUIUtility.labelWidth;
                //	if (GUI.Button(r2, "Many (" + pathsCount + ")", GeneralStyles.ToolbarDropDown) == true)
                //	{
                //	}
                //	r2.xMin -= EditorGUIUtility.labelWidth;
                //}
                r2.y += /*r2.height + */ 2F;

                if (this.localAsset != null)
                {
                    EditorGUI.ObjectField(r2, "Asset", this.localAsset, this.type, false);
                }
                else if (this.isSupported == false)
                {
                    r2.height = 24F;
                    r2.xMin  += 5F;
                    r2.xMax  -= 5F;
                    EditorGUI.HelpBox(r2, "Not supported.", MessageType.Warning);
                }
                else
                {
                    bool hasError = this.importMode == ImportMode.None;

                    //EditorGUILayout.BeginHorizontal();
                    {
                        using (LabelWidthRestorer.Get(100F))
                        {
                            if (pathsCount > 0)
                            {
                                EditorGUI.BeginDisabledGroup(this.parametersConfirmed == true);
                                {
                                    //r2.width = 182F/* - EditorGUI.indentLevel * 15F*/;
                                    this.importMode = (ImportMode)EditorGUI.EnumPopup(r2, "Import Mode", this.importMode);
                                    r2.y           += r2.height;
                                }
                                EditorGUI.EndDisabledGroup();
                            }

                            //EditorGUILayout.BeginVertical();
                            {
                                EditorGUI.BeginDisabledGroup(this.parametersConfirmed == true);
                                {
                                    if (this.importMode == ImportMode.Auto)
                                    {
                                        if (this.name == null)
                                        {
                                            this.name = this.hierarchy.GetResourceName(this.type, this.instanceID);
                                        }

                                        if (this.autoPath == null && this.name != null)
                                        {
                                            IObjectImporter importer = RemoteUtility.GetImportAssetTypeSupported(this.type);

                                            if (importer != null)
                                            {
                                                string path     = this.prefabPath;
                                                string filename = string.Join("_", this.name.Split(Path.GetInvalidFileNameChars())) + importer.GetExtension();

                                                if (string.IsNullOrEmpty(this.hierarchy.specificSharedSubFolder) == false)
                                                {
                                                    path = this.hierarchy.specificSharedSubFolder;
                                                }

                                                //if (this.hierarchy.rawCopyAssetsToSubFolder == true)
                                                //	path += "/" + .gameObjectName;
                                                //else if (this.hierarchy.prefixAsset == true)
                                                //	filename = string.Join("_", (parameter.gameObjectName).Split(Path.GetInvalidFileNameChars())) + '_' + filename;

                                                this.autoPath = path + "/" + filename;
                                            }
                                        }

                                        if (/*parameter.gameObjectName != null && */ this.name != null)
                                        {
                                            if (this.autoPath == null)
                                            {
                                                r2.height = 24F;
                                                hasError  = true;
                                                EditorGUI.HelpBox(r2, "Asset type is not supported, will not be imported.", MessageType.Warning);
                                                r2.y += r2.height;
                                            }
                                            else
                                            {
                                                EditorGUI.BeginChangeCheck();
                                                this.autoPath = NGEditorGUILayout.SaveFileField(r2, "Output Path", this.autoPath);
                                                if (EditorGUI.EndChangeCheck() == true)
                                                {
                                                    Uri  pathUri;
                                                    bool isValidUri = Uri.TryCreate(this.autoPath, UriKind.Relative, out pathUri);
                                                    bool v          = isValidUri && pathUri != null /* && pathUri.IsLoopback*/;

                                                    //FileInfo fi = null;
                                                    //try
                                                    //{
                                                    //	fi = new FileInfo(parameter.autoPath);
                                                    //}
                                                    //catch (System.ArgumentException) { }
                                                    //catch (PathTooLongException) { }
                                                    //catch (System.NotSupportedException) { }

                                                    if (v == false)
                                                    {
                                                        //if (ReferenceEquals(fi, null))
                                                        this.autoPathError = "Path is invalid.";
                                                    }
                                                    // file name is not valid
                                                    else
                                                    {
                                                        this.autoPathError = null;
                                                    }
                                                    // file name is valid... May check for existence by calling fi.Exists.
                                                }
                                                r2.y += r2.height;

                                                if (string.IsNullOrEmpty(this.autoPathError) == false)
                                                {
                                                    r2.height = 24F;
                                                    EditorGUI.HelpBox(r2, this.autoPathError, MessageType.Error);
                                                    r2.y += r2.height;
                                                }
                                            }
                                        }
                                        else
                                        {
                                            Utility.content.text = "Waiting for server...";
                                            EditorGUI.LabelField(r2, Utility.content, GeneralStyles.StatusWheel);
                                            r2.y += r2.height;

                                            importAssetsWindow.Repaint();
                                        }
                                    }
                                    else if (this.importMode == ImportMode.UseGUID)
                                    {
                                        EditorGUI.BeginChangeCheck();
                                        Object o = EditorGUI.ObjectField(r2, "Asset", this.guidAsset, this.type, false);
                                        if (EditorGUI.EndChangeCheck() == true)
                                        {
                                            this.guidAsset = o;
                                            this.guid      = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(o));
                                        }
                                        r2.y += r2.height;

                                        EditorGUI.LabelField(r2, "GUID", this.guid ?? "None");
                                        r2.y += r2.height;

                                        if (string.IsNullOrEmpty(this.guid) == true)
                                        {
                                            hasError = true;
                                        }
                                    }
                                    else if (this.importMode == ImportMode.RawCopy)
                                    {
                                        EditorGUI.BeginChangeCheck();
                                        string path = NGEditorGUILayout.SaveFileField(r2, "Output Path", this.outputPath);
                                        if (EditorGUI.EndChangeCheck() == true)
                                        {
                                            if (path.StartsWith(Application.dataPath) == true)
                                            {
                                                this.outputPath = path.Substring(Application.dataPath.Length - "Assets".Length);
                                            }
                                            else if (path.StartsWith("Assets") == true)
                                            {
                                                this.outputPath = path;
                                            }
                                        }
                                        r2.y += r2.height;

                                        if (string.IsNullOrEmpty(path) == false &&
                                            path.StartsWith(Application.dataPath) == false &&
                                            path.StartsWith("Assets") == false)
                                        {
                                            hasError  = true;
                                            r2.height = 24F;
                                            EditorGUI.HelpBox(r2, "Path must be in Assets folder.", MessageType.Warning);
                                            r2.y += r2.height;
                                        }
                                    }
                                }
                                EditorGUI.EndDisabledGroup();

                                r2.y     += 2F;
                                r2.height = Constants.SingleLineHeight;

                                if (this.parametersConfirmed == true)
                                {
                                    if (this.importErrorMessage != null)
                                    {
                                        r2.xMin  += 5F;
                                        r2.height = 32F;
                                        EditorGUI.HelpBox(r2, "Import failed : " + this.importErrorMessage, MessageType.Error);
                                    }
                                    else if (this.copyAsset != null && (this.importMode == ImportMode.RawCopy || this.importMode == ImportMode.Auto))
                                    {
                                        EditorGUI.ObjectField(r2, "Created Asset", this.copyAsset, this.type, false);
                                    }
                                    else if (this.totalBytes > 0)
                                    {
                                        r2.xMin += 5F;

                                        if (this.bytesReceived == this.totalBytes)
                                        {
                                            EditorGUI.ProgressBar(r2, 1F, "Creating asset...");
                                        }
                                        else
                                        {
                                            float  rate = (float)this.bytesReceived / (float)this.totalBytes;
                                            string cacheFileSize;

                                            if (this.totalBytes >= 1024 * 1024)
                                            {
                                                cacheFileSize = ((float)(this.bytesReceived / (1024F * 1024F))).ToString("N1") + " / " + ((float)(this.totalBytes / (1024F * 1024F))).ToString("N1") + " MiB";
                                            }
                                            else if (this.totalBytes >= 1024)
                                            {
                                                cacheFileSize = ((float)(this.bytesReceived / 1024F)).ToString("N1") + " / " + ((float)(this.totalBytes / 1024F)).ToString("N1") + " KiB";
                                            }
                                            else
                                            {
                                                cacheFileSize = this.bytesReceived + " / " + this.totalBytes + " B";
                                            }

                                            EditorGUI.ProgressBar(r2, rate, cacheFileSize + " (" + (rate * 100F).ToString("0.0") + "%)");
                                            importAssetsWindow.Repaint();
                                        }
                                    }
                                }
                                else
                                {
                                    EditorGUI.BeginDisabledGroup(hasError);
                                    {
                                        r2.width = 100F;
                                        r2.x     = w - r2.width - 10F;

                                        if (GUI.Button(r2, "Confirm") == true)
                                        {
                                            this.Confirm();
                                            importAssetsWindow.Repaint();
                                        }
                                    }
                                    EditorGUI.EndDisabledGroup();
                                }
                            }
                        }

                        if (Conf.DebugMode != Conf.DebugState.None && this.importErrorMessage != null && GUI.Button(r2, "Retry Import") == true)
                        {
                            this.ResetImport();
                        }
                    }
                }
            }
        }