コード例 #1
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
            {
            }
        }
コード例 #2
0
ファイル: NGScenesWindow.cs プロジェクト: Hengle/clapotis
        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);
            }
        }
コード例 #3
0
        public override void    Load(string path)
        {
            Double result;

            if (Double.TryParse(NGEditorPrefs.GetString(path), out result) == true)
            {
                this.value = result;
            }
        }
コード例 #4
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();
            };
        }
コード例 #5
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();
        }
コード例 #6
0
ファイル: NGScenesWindow.cs プロジェクト: Hengle/clapotis
        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();
        }
コード例 #7
0
        public static void      GoToFileLine(string file, int line, bool focus)
        {
            GeneralSettings general = HQ.Settings.Get <GeneralSettings>();

            if (file.StartsWith("Assets") == true)
            {
                file = Path.Combine(Application.dataPath, file.Substring(7)).Replace('/', '\\');
            }
            else
            {
                file = Application.dataPath + '/' + file;
            }

            if (general.openMode == GeneralSettings.ModeOpen.AssetDatabaseOpenAsset)
            {
                Object sourceFile = AssetDatabase.LoadAssetAtPath(@"Assets\" + file.Substring(Application.dataPath.Length + 1), typeof(TextAsset));
                if (sourceFile != null)
                {
                    AssetDatabase.OpenAsset(sourceFile, line);
                }
                else
                {
                    Debug.LogWarning(string.Format(LC.G("Console_AssetNotText"), @"Assets\" + file.Substring(Application.dataPath.Length + 1)));
                }
            }
            else if (general.openMode == GeneralSettings.ModeOpen.NGConsoleOpener)
            {
                GeneralSettings.EditorExtensions editorExtensions = null;
                string editorPath    = NGEditorPrefs.GetString(ConsoleConstants.ScriptDefaultApp);
                string fileExtension = Path.GetExtension(file);

                if ((string.IsNullOrEmpty(editorPath) == true ||
                     editorPath == "internal") &&
                    string.IsNullOrEmpty(fileExtension) == false)
                {
                    fileExtension = fileExtension.Substring(1);
                    for (int i = 0; i < general.editorExtensions.Length; i++)
                    {
                        for (int j = 0; j < general.editorExtensions[i].extensions.Length; j++)
                        {
                            if (general.editorExtensions[i].extensions[j].Equals(fileExtension, StringComparison.OrdinalIgnoreCase) == true)
                            {
                                editorExtensions = general.editorExtensions[i];
                                editorPath       = general.editorExtensions[i].editor;
                                goto doubleBreak;
                            }
                        }
                    }
                }
doubleBreak:

                // It is required to delay the opening, due editor sometimes falling into error state during the same frame.

                // Fallback when it is log without any reachable file. (Happened with a non-usable dll.)
                if (string.IsNullOrEmpty(editorPath) == true || editorExtensions == null)
                {
                    Object sourceFile = AssetDatabase.LoadAssetAtPath(@"Assets\" + file.Substring(Application.dataPath.Length + 1), typeof(Object));

                    if (sourceFile != null)
                    {
                        EditorApplication.delayCall += () => AssetDatabase.OpenAsset(sourceFile, line);
                    }
                    else
                    {
                        EditorApplication.delayCall += () => EditorUtility.OpenWithDefaultApp(file);
                    }
                    return;
                }

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

                foreach (IEditorOpener opener in NGConsoleWindow.Openers)
                {
                    if (opener.CanHandleEditor(editorPath) == true)
                    {
                        EditorApplication.delayCall += () => opener.Open(editorPath, editorExtensions.arguments, file, line);

                        // Easy trick to give focus to the application.
                        if (settings.giveFocusToEditor == true || focus == true)
                        {
                            EditorApplication.delayCall += () => EditorUtility.OpenWithDefaultApp(file);
                        }
                        break;
                    }
                }
            }
        }
コード例 #8
0
 public override void    Load(string path)
 {
     this.value = NGEditorPrefs.GetString(path);
 }