Ejemplo n.º 1
0
        protected virtual void  OnDisable()
        {
            InternalNGDebug.VerboseLog("NGHub.OnDisable," + this.initialized + "," + this.dockedAsMenu);
            if (this.initialized == false)
            {
                return;
            }

            if (this.dockedAsMenu == true)
            {
                NGEditorPrefs.SetInt(NGHubWindow.ForceRecreateKeyPref + "_" + Application.dataPath, (int)DockState.ProperlyDisabled);
            }

            HQ.SettingsChanged     -= this.OnSettingsChanged;
            Undo.undoRedoPerformed -= this.RestoreComponents;

            Utility.DirectSaveEditorPref(this.backgroundColor, typeof(Color), NGHubWindow.BackgroundColorKeyPref);

            this.initialized = false;

            for (int i = 0; i < this.components.Count; i++)
            {
                this.components[i].Uninit();
            }
        }
Ejemplo n.º 2
0
        public override void    Save(string path)
        {
            Vector2 c = (Vector2)this.value;

            NGEditorPrefs.SetFloat(path + ".x", (float)c.x);
            NGEditorPrefs.SetFloat(path + ".y", (float)c.y);
        }
Ejemplo n.º 3
0
        static NGNavSelectionWindow()
        {
            try
            {
                if (Application.platform == RuntimePlatform.WindowsEditor)
                {
                    EditorApplication.update += NGNavSelectionWindow.HandleMouseInputs;
                }
                NGEditorApplication.EditorExit += NGNavSelectionWindow.SaveHistoric;
                HQ.SettingsChanged             += NGNavSelectionWindow.OnSettingsChanged;

                // It must me delayed! Most Object are correctly fetched, except folders and maybe others.
                EditorApplication.delayCall += () =>
                {
                    // HACK Prevents double call bug.
                    if (NGNavSelectionWindow.historic.Count != 0)
                    {
                        return;
                    }

                    NGNavSelectionWindow.lastHash  = NGEditorPrefs.GetInt(NGNavSelectionWindow.LastHashPrefKey, 0);
                    NGNavSelectionWindow.isPlaging = EditorApplication.isPlaying;

                    string autoSave = NGEditorPrefs.GetString(NGNavSelectionWindow.AutoSavePrefKey, string.Empty, true);

                    if (autoSave != string.Empty)
                    {
                        string[] selections = autoSave.Split(',');
                        int      lastHash   = 0;

                        for (int i = 0; i < selections.Length; i++)
                        {
                            string[] IDs   = selections[i].Split(';');
                            int[]    array = new int[IDs.Length];

                            for (int j = 0; j < IDs.Length; j++)
                            {
                                array[j] = int.Parse(IDs[j]);
                            }

                            AssetsSelection selection = new AssetsSelection(array);

                            if (selection.refs.Count > 0)
                            {
                                int hash = selection.GetSelectionHash();

                                if (lastHash != hash)
                                {
                                    lastHash = hash;
                                    NGNavSelectionWindow.historic.Add(selection);
                                }
                            }
                        }
                    }
                };
            }
            catch
            {
            }
        }
Ejemplo n.º 4
0
        private static void     UpdateLastScenes()
        {
            string lastScene = EditorSceneManager.GetActiveScene().path;

            if (string.IsNullOrEmpty(lastScene) == true)
            {
                return;
            }

            string rawScenes = NGEditorPrefs.GetString(NGScenesWindow.RecentScenesKey, string.Empty, true);

            if (string.IsNullOrEmpty(rawScenes) == false)
            {
                string[]      scenes = rawScenes.Split(NGScenesWindow.SceneSeparator);
                List <string> list   = new List <string>(scenes.Length + 1);

                list.Add(lastScene);
                for (int i = 0; i < scenes.Length; i++)
                {
                    if (scenes[i] != lastScene && File.Exists(scenes[i]) == true)
                    {
                        list.Add(scenes[i]);
                    }
                }

                NGEditorPrefs.SetString(NGScenesWindow.RecentScenesKey, string.Join(NGScenesWindow.SceneSeparator.ToString(), list.ToArray()), true);
            }
            else
            {
                NGEditorPrefs.SetString(NGScenesWindow.RecentScenesKey, EditorSceneManager.GetActiveScene().name, true);
            }
        }
Ejemplo n.º 5
0
        protected virtual void  OnEnable()
        {
            Metrics.UseTool(17);             // NGSyncFolders

            NGChangeLogWindow.CheckLatestVersion(NGAssemblyInfo.Name);

            Utility.RegisterWindow(this);
            Utility.LoadEditorPref(this, NGEditorPrefs.GetPerProjectPrefix());
            Utility.RestoreIcon(this, NGSyncFoldersWindow.TitleColor);

            this.slavesList = new ReorderableList(null, typeof(Project), true, true, this.showSlaves, false);
            this.slavesList.drawHeaderCallback  = this.OnDrawHeaderSlaves;
            this.slavesList.elementHeight       = this.showSlaves == true ? NGSyncFoldersWindow.SlaveHeight : 0F;
            this.slavesList.drawElementCallback = this.OnDrawSlave;
            this.slavesList.onAddCallback       = this.OnAddSlave;

            this.filtersList = new ReorderableList(null, typeof(string), true, true, this.showFilters, false);
            this.filtersList.drawHeaderCallback  = this.OnDrawHeaderFilters;
            this.filtersList.elementHeight       = this.showFilters == true ? NGSyncFoldersWindow.FilterHeight : 0F;
            this.filtersList.drawElementCallback = this.OnDrawFilter;
            this.filtersList.onAddCallback       = this.OnAddFilter;

            //this.profile.master.WatchFileChanged += this.ReplicateOnSlaves;

            this.minSize        = new Vector2(370F, 200F);
            this.wantsMouseMove = true;

            HQ.SettingsChanged += this.Repaint;
            Utility.RegisterIntervalCallback(this.Repaint, 250);
            Undo.undoRedoPerformed += this.RepaintAndClearCaches;
        }
Ejemplo n.º 6
0
        public override void    Save(string path)
        {
            Rect c = (Rect)this.value;

            NGEditorPrefs.SetFloat(path + ".x", (float)c.x);
            NGEditorPrefs.SetFloat(path + ".y", (float)c.y);
            NGEditorPrefs.SetFloat(path + ".w", (float)c.width);
            NGEditorPrefs.SetFloat(path + ".h", (float)c.height);
        }
Ejemplo n.º 7
0
        public override void    Load(string path)
        {
            Vector2 v = (Vector2)this.value;

            v.x = NGEditorPrefs.GetFloat(path + ".x");
            v.y = NGEditorPrefs.GetFloat(path + ".y");

            this.value = v;
        }
Ejemplo n.º 8
0
        public override void    Load(string path)
        {
            Double result;

            if (Double.TryParse(NGEditorPrefs.GetString(path), out result) == true)
            {
                this.value = result;
            }
        }
Ejemplo n.º 9
0
        public override void    Save(string path)
        {
            Color c = (Color)this.value;

            NGEditorPrefs.SetFloat(path + ".r", (float)c.r);
            NGEditorPrefs.SetFloat(path + ".g", (float)c.g);
            NGEditorPrefs.SetFloat(path + ".b", (float)c.b);
            NGEditorPrefs.SetFloat(path + ".a", (float)c.a);
        }
Ejemplo n.º 10
0
        public override void    Save(string path)
        {
            Quaternion c = (Quaternion)this.value;

            NGEditorPrefs.SetFloat(path + ".x", (float)c.x);
            NGEditorPrefs.SetFloat(path + ".y", (float)c.y);
            NGEditorPrefs.SetFloat(path + ".z", (float)c.z);
            NGEditorPrefs.SetFloat(path + ".w", (float)c.w);
        }
Ejemplo n.º 11
0
        protected virtual void  OnEnable()
        {
            this.autoPublish = NGEditorPrefs.GetBool(SubmissionWindow.AutoPublishKeyPref, this.autoPublish);

            EditorApplication.delayCall += () =>
            {
                this.comments = NGEditorPrefs.GetString(SubmissionWindow.AutoPublishKeyPref + this.assetName, this.comments);
                this.Repaint();
            };
        }
Ejemplo n.º 12
0
        protected virtual void  OnDisable()
        {
            for (int i = 0; i < this.filters.Count; i++)
            {
                Utility.SaveEditorPref(this.filters[i], NGEditorPrefs.GetPerProjectPrefix());
            }

            Selection.selectionChanged -= this.UpdateSelection;
            Undo.undoRedoPerformed     -= this.Repaint;
        }
Ejemplo n.º 13
0
        public override void    Load(string path)
        {
            Quaternion v = (Quaternion)this.value;

            v.x = NGEditorPrefs.GetFloat(path + ".x");
            v.y = NGEditorPrefs.GetFloat(path + ".y");
            v.z = NGEditorPrefs.GetFloat(path + ".z");
            v.w = NGEditorPrefs.GetFloat(path + ".w");

            this.value = v;
        }
Ejemplo n.º 14
0
        public override void    Load(string path)
        {
            Color v = (Color)this.value;

            v.r = NGEditorPrefs.GetFloat(path + ".r");
            v.g = NGEditorPrefs.GetFloat(path + ".g");
            v.b = NGEditorPrefs.GetFloat(path + ".b");
            v.a = NGEditorPrefs.GetFloat(path + ".a");

            this.value = v;
        }
Ejemplo n.º 15
0
        public override void    Load(string path)
        {
            Rect v = (Rect)this.value;

            v.x      = NGEditorPrefs.GetFloat(path + ".x");
            v.y      = NGEditorPrefs.GetFloat(path + ".y");
            v.width  = NGEditorPrefs.GetFloat(path + ".w");
            v.height = NGEditorPrefs.GetFloat(path + ".h");

            this.value = v;
        }
Ejemplo n.º 16
0
 static NGHubWindow()
 {
     // In the case of NG Hub as dock, the layout won't load it at the second restart. Certainly due to the window's state as Popup, but it does not explain why it only occurs at the second restart.
     EditorApplication.delayCall += () =>
     {
         int forceRecreate = NGEditorPrefs.GetInt(NGHubWindow.ForceRecreateKeyPref + "_" + Application.dataPath, 0);
         NGDiagnostic.Log(NGHubWindow.Title, "ForceRecreate", forceRecreate);
         if (forceRecreate == (int)DockState.ProperlyDisabled && Resources.FindObjectsOfTypeAll <NGHubWindow>().Length == 0)
         {
             NGHubWindow.OpenAsDock();
         }
     };
 }
Ejemplo n.º 17
0
        protected virtual void  OnDisable()
        {
            Utility.UnregisterWindow(this);
            //this.profile.master.WatchFileChanged -= this.ReplicateOnSlaves;

            //this.profile.master.Dispose();
            //for (int i = 0; i < this.profile.slaves.Count; i++)
            //	this.profile.slaves[i].Dispose();

            Utility.SaveEditorPref(this, NGEditorPrefs.GetPerProjectPrefix());
            HQ.SettingsChanged -= this.Repaint;
            Utility.UnregisterIntervalCallback(this.Repaint);
            Undo.undoRedoPerformed -= this.RepaintAndClearCaches;
        }
Ejemplo n.º 18
0
        public LogsExporterDrawer(EditorWindow window, List <Row> rows)
        {
            this.window       = window;
            this.rows         = rows;
            this.exporters    = Utility.CreateNGTInstancesOf <ILogExporter>();
            this.previewLabel = "Preview              (" + this.rows.Count + " element" + (this.rows.Count > 1 ? "s" : string.Empty) + ")";

            this.names = new string[this.exporters.Length];
            for (int i = 0; i < this.exporters.Length; i++)
            {
                this.names[i] = Utility.NicifyVariableName(this.exporters[i].GetType().Name);
            }

            string rawUsedOutputs = NGEditorPrefs.GetString(ExportLogsWindow.UsedOutputsKeyPref, null);

            if (string.IsNullOrEmpty(rawUsedOutputs) == false)
            {
                string[] splittedTypes = rawUsedOutputs.Split(ExportLogsWindow.UsedOutputsSeparator);

                for (int i = 0; i < splittedTypes.Length; i++)
                {
                    Type t = Type.GetType(splittedTypes[i]);

                    if (t != null)
                    {
                        this.usedOutputs.Add(Activator.CreateInstance(t) as ILogExportSource);
                    }
                }
            }

            if (this.usedOutputs.Count == 0)
            {
                for (int i = 0; i < LogsExporterDrawer.DefaultExportSources.Length; i++)
                {
                    this.usedOutputs.Add(Activator.CreateInstance(LogsExporterDrawer.DefaultExportSources[i]) as ILogExportSource);
                }
            }

            Utility.LoadEditorPref(this, NGEditorPrefs.GetPerProjectPrefix());

            for (int i = 0; i < this.exporters.Length; i++)
            {
                this.exporters[i].OnEnable();
            }

            this.horizontalScrollbar = new HorizontalScrollbar(0F, 18F, this.window.position.width, 4F);

            this.UpdatePreview();
        }
Ejemplo n.º 19
0
        private void    SetDockMode(bool mode)
        {
            this.dockedAsMenu = mode;

            if (mode == true)
            {
                NGEditorPrefs.SetInt(NGHubWindow.ForceRecreateKeyPref + "_" + Application.dataPath, (int)DockState.ProperlyEnabled);
                this.UpdateDockPosition();
                Utility.RegisterIntervalCallback(this.UpdateDockPosition, 50);
            }
            else
            {
                NGEditorPrefs.SetInt(NGHubWindow.ForceRecreateKeyPref + "_" + Application.dataPath, (int)DockState.ProperlyDisabled);
                Utility.UnregisterIntervalCallback(this.UpdateDockPosition);
            }
        }
Ejemplo n.º 20
0
        protected virtual void  OnEnable()
        {
            Utility.RestoreIcon(this, NGRenamerWindow.TitleColor);

            Metrics.UseTool(11);             // NGRenamer

            NGChangeLogWindow.CheckLatestVersion(NGAssemblyInfo.Name);

            foreach (Type type in Utility.EachNGTSubClassesOf(typeof(TextFilter)))
            {
                this.filters.Add(Activator.CreateInstance(type, new object[] { this }) as TextFilter);
                Utility.LoadEditorPref(this.filters[this.filters.Count - 1], NGEditorPrefs.GetPerProjectPrefix());
            }

            this.filters.Sort((a, b) => b.priority - a.priority);

            Selection.selectionChanged += this.UpdateSelection;
            Undo.undoRedoPerformed     += this.Repaint;
        }
Ejemplo n.º 21
0
        private void    UpdateRecentScenes()
        {
            string rawScenes = NGEditorPrefs.GetString(NGScenesWindow.RecentScenesKey, string.Empty, true);

            if (string.IsNullOrEmpty(rawScenes) == true)
            {
                this.recentListDrawer.array = new Scene[0];
                return;
            }

            string[] scenes = rawScenes.Split(NGScenesWindow.SceneSeparator);

            list.Clear();
            for (int i = 0; i < scenes.Length; i++)
            {
                list.Add(new Scene(scenes[i]));
            }

            this.recentListDrawer.array = list.ToArray();
        }
Ejemplo n.º 22
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);
                }
            }
        }
Ejemplo n.º 23
0
        public void     Save()
        {
            StringBuilder buffer = Utility.GetBuffer();

            for (int i = 0; i < this.usedOutputs.Count; i++)
            {
                if (i > 0)
                {
                    buffer.Append(ExportLogsWindow.UsedOutputsSeparator);
                }
                buffer.Append(this.usedOutputs[i].GetType().GetShortAssemblyType());
            }

            NGEditorPrefs.SetString(ExportLogsWindow.UsedOutputsKeyPref, Utility.ReturnBuffer(buffer));

            Utility.SaveEditorPref(this, NGEditorPrefs.GetPerProjectPrefix());

            for (int i = 0; i < this.exporters.Length; i++)
            {
                this.exporters[i].OnDestroy();
            }
        }
Ejemplo n.º 24
0
        private static void     SaveHistoric()
        {
            if (NGNavSelectionWindow.hasChanged == true)
            {
                NGNavSelectionWindow.hasChanged = false;

                StringBuilder buffer = Utility.GetBuffer();

                for (int i = 0; i < NGNavSelectionWindow.historic.Count; ++i)
                {
                    for (int j = 0; j < NGNavSelectionWindow.historic[i].refs.Count; j++)
                    {
                        Object o = NGNavSelectionWindow.historic[i][j];

                        if (o != null)
                        {
                            buffer.Append(o.GetInstanceID());
                            buffer.Append(';');
                        }
                    }

                    // Should never happens, except if the save is corrupted.
                    if (buffer.Length > 0)
                    {
                        buffer.Length -= 1;
                        buffer.Append(',');
                    }
                }

                if (buffer.Length > 0)
                {
                    buffer.Length -= 1;
                }

                NGEditorPrefs.SetString(NGNavSelectionWindow.AutoSavePrefKey, Utility.ReturnBuffer(buffer), true);
                NGEditorPrefs.SetInt(NGNavSelectionWindow.LastHashPrefKey, NGNavSelectionWindow.lastHash);
            }
        }
Ejemplo n.º 25
0
            public void     Draw(Rect r, float viewYMin, float viewYMax)
            {
                float x    = r.x;
                float xMax = r.xMax;

                r.height = Constants.SingleLineHeight;
                r.width  = r.height;

                if (r.yMax > viewYMin)
                {
                    EditorGUI.showMixedValue = this.HasMixedRefs();
                    EditorGUI.BeginChangeCheck();
                    EditorGUI.ToggleLeft(r, string.Empty, this.referenced);
                    if (EditorGUI.EndChangeCheck() == true)
                    {
                        if (this.referenced == true)
                        {
                            this.Unreference();
                        }
                        else
                        {
                            this.Reference();
                        }
                    }
                    r.x += r.width + r.width;

                    EditorGUI.showMixedValue = false;

                    GUI.DrawTexture(r, Folder.folderIcon);
                    r.x    += r.width;
                    r.xMax  = xMax;
                    r.xMin -= r.height + r.height;

                    EditorGUI.BeginChangeCheck();
                    EditorGUI.Foldout(r, this.Open, "     " + this.name, true);
                    if (EditorGUI.EndChangeCheck() == true)
                    {
                        this.Open = !this.open;

                        if (Event.current.alt == true)
                        {
                            Queue <Folder> queue = new Queue <Folder>(128);

                            queue.Enqueue(this);

                            while (queue.Count > 0)
                            {
                                Folder current = queue.Dequeue();

                                for (int i = 0; i < current.folders.Count; i++)
                                {
                                    queue.Enqueue(current.folders[i]);
                                }

                                current.open   = this.open;
                                current.height = -1F;
                                EditorPrefs.SetBool(EmbedAssetsBrowserWindow.Folder.EnableFolderPrefKey + current.GetHierarchyPath(), this.open);
                            }
                        }
                    }
                }
                else
                {
                    r.xMax = xMax;
                }

                if (this.open == true)
                {
                    r.x  = x + 16F;
                    r.y += r.height;

                    for (int i = 0; i < this.folders.Count; i++)
                    {
                        if (this.folders[i].folders.Count == 0 && this.folders[i].files.Count == 0)
                        {
                            continue;
                        }

                        r.height = this.folders[i].GetHeight();
                        this.folders[i].Draw(r, viewYMin, viewYMax);
                        r.y += r.height;
                    }

                    if (r.yMin > viewYMax)
                    {
                        return;
                    }

                    r.height = Constants.SingleLineHeight;

                    for (int i = 0; i < this.files.Count; i++)
                    {
                        if (r.yMax > viewYMin)
                        {
                            EditorGUI.BeginChangeCheck();

                            Texture2D icon = Utility.GetIcon(AssetDatabase.LoadMainAssetAtPath(this.files[i].path));
                            if (icon == null)
                            {
                                icon = InternalEditorUtility.GetIconForFile(this.files[i].path);
                            }
                            r.width = r.height;
                            r.x    += r.width;
                            GUI.DrawTexture(r, icon);
                            r.x -= r.width;

                            EditorGUI.BeginDisabledGroup(!this.files[i].isValid);
                            {
                                r.xMax = xMax;
                                this.files[i].referenced = EditorGUI.ToggleLeft(r, "     " + this.files[i].name, this.files[i].referenced);
                                if (EditorGUI.EndChangeCheck() == true)
                                {
                                    EditorGUIUtility.PingObject(AssetDatabase.LoadAssetAtPath <Object>(this.files[i].path));

                                    if (this.files[i].referenced == false || EmbedAssetsBrowserWindow.CheckEmbeddableFile(this.files[i]) == true)
                                    {
                                        this.Update();
                                    }
                                    else
                                    {
                                        if (NGEditorPrefs.GetBool(Folder.AlertNullAssetPrefKey) == false &&
                                            EditorUtility.DisplayDialog(Constants.PackageTitle, "Asset at \"" + this.files[i].path + "\" contains null assets.\nFix them and reference again.", "OK", "Don't show again") == false)
                                        {
                                            NGEditorPrefs.SetBool(Folder.AlertNullAssetPrefKey, true);
                                        }

                                        this.files[i].referenced = false;
                                    }
                                }
                            }
                            EditorGUI.EndDisabledGroup();
                        }

                        r.y += r.height;

                        if (r.yMin > viewYMax)
                        {
                            return;
                        }
                    }
                }
            }
Ejemplo n.º 26
0
 public override void    Load(string path)
 {
     this.value = (bool)NGEditorPrefs.GetBool(path);
 }
Ejemplo n.º 27
0
 protected virtual void  OnDisable()
 {
     NGEditorPrefs.SetBool(SubmissionWindow.AutoPublishKeyPref, this.autoPublish);
     NGEditorPrefs.SetString(SubmissionWindow.AutoPublishKeyPref + this.assetName, this.comments);
 }
Ejemplo n.º 28
0
 public override void    Save(string path)
 {
     NGEditorPrefs.SetString(path, ((Double)this.value).ToString());
 }
Ejemplo n.º 29
0
 public override void    Save(string path)
 {
     NGEditorPrefs.SetInt(path, (Int32)this.value);
 }
Ejemplo n.º 30
0
 public override void    Load(string path)
 {
     this.value = (Int32)NGEditorPrefs.GetInt(path);
 }