Exemple #1
0
            private void    DrawElement(Rect r, int index, bool isActive, bool isFocused)
            {
                r.width -= 30F;
                r.x     += 30F;
                EditorGUI.BeginChangeCheck();
                ProfilesManager.profiles[index].name = EditorGUI.TextField(r, ProfilesManager.profiles[index].name);
                if (EditorGUI.EndChangeCheck() == true)
                {
                    ProfilesManager.Save();
                }
                r.x -= 30;

                r.width = 30F;
                if (GUI.Button(r, ">") == true)
                {
                    ProfilesManager.SwitchFavorite(index);

                    if (ProfilesManager.SetProfile != null)
                    {
                        ProfilesManager.SetProfile();
                    }

                    InternalEditorUtility.RepaintAllViews();
                    this.editorWindow.Close();
                }
            }
Exemple #2
0
        private static void     AddFavorite()
        {
            Profile p = Utility.DeserializeField <Profile>(Utility.SerializeField(ProfilesManager.Profile));

            p.name = "Profile " + (ProfilesManager.profiles.Count + 1);
            ProfilesManager.profiles.Add(p);
            ProfilesManager.Save();
        }
Exemple #3
0
            private void    DeleteElement(ReorderableList list)
            {
                ProfilesManager.profiles.RemoveAt(list.index);
                ProfilesManager.current = Mathf.Clamp(ProfilesManager.current, 0, ProfilesManager.profiles.Count - 1);
                ProfilesManager.Save();

                this.size = new Vector2(300, 21F + ProfilesManager.profiles.Count * 21F);

                this.editorWindow.Close();
                PopupWindow.Show(new Rect(0F, 0F, 1F, 1F), this);
            }
Exemple #4
0
            private void    DrawFooter(Rect r)
            {
                r.y      -= 3F;
                r.width   = (r.width - 56F) / 2F;
                r.height -= 5F;
                if (GUI.Button(r, "Export") == true)
                {
                    string path = EditorUtility.SaveFilePanel(Constants.PackageTitle, "", "profiles", "uon");

                    if (string.IsNullOrEmpty(path) == false)
                    {
                        File.WriteAllText(path, UON.ToUON(ProfilesManager.profiles));
                    }
                }
                r.x += r.width;

                if (GUI.Button(r, "Import") == true)
                {
                    string path = EditorUtility.OpenFilePanel(Constants.PackageTitle, "", "uon");

                    if (string.IsNullOrEmpty(path) == false)
                    {
                        try
                        {
                            string         uon = File.ReadAllText(path);
                            List <Profile> importedProfiles = UON.FromUON(uon) as List <Profile>;
                            ProfilesManager.profiles = importedProfiles;
                            ProfilesManager.Save();
                        }
                        catch (Exception ex)
                        {
                            Debug.LogException(ex);
                        }
                    }
                }
            }
        private void    Draw(Rect rect, int index, bool isActive, bool isFocused)
        {
            string unityVersion = Utility.GetUnityVersion(ProfilesManager.Profile.projects[index]);
            float  width        = rect.width;

            rect.width = 55F;
            if (GUI.Button(rect, "Browse", "ButtonLeft") == true)
            {
                string projectPath = EditorUtility.OpenFolderPanel("Open Unity Project", ProfilesManager.Profile.projects[index], string.Empty);

                if (string.IsNullOrEmpty(projectPath) == false)
                {
                    ProfilesManager.Profile.projects[index] = projectPath;
                    this.CheckUnityProject(ProfilesManager.Profile.projects[index]);
                    GUI.FocusControl(null);
                }
            }

            rect.x    += rect.width;
            rect.width = 40F;
            if (GUI.Button(rect, "Open", "ButtonMid") == true)
            {
                Utility.ShowExplorer(ProfilesManager.Profile.projects[index]);
            }

            string error = null;

            if (this.packageFolderError != string.Empty)
            {
                error = this.packageFolderError;
                Utility.content.tooltip = this.packageFolderError;
            }
            else if (this.errors.TryGetValue(ProfilesManager.Profile.projects[index], out error) == true)
            {
                Utility.content.tooltip = error;
            }

            rect.x    += rect.width;
            rect.width = 40F;
            EditorGUI.BeginDisabledGroup(error != null);
            Utility.content.text = "Unity";
            if (GUI.Button(rect, Utility.content, "ButtonRight") == true)
            {
                if (Utility.IsUnityProject(ProfilesManager.Profile.projects[index]) == true)
                {
                    if (string.IsNullOrEmpty(unityVersion) == false)
                    {
                        string unityExe = NGUnityDetectorWindow.GetUnityExecutable(this.unityInstalls, unityVersion);

                        if (File.Exists(unityExe) == true)
                        {
                            Process.Start(unityExe, "-projectPath \"" + ProfilesManager.Profile.projects[index] + "\"");
                        }
                    }
                }
            }
            EditorGUI.EndDisabledGroup();

            Utility.content.text = unityVersion;

            rect.x    += rect.width;
            rect.width = width - 195F - GUI.skin.label.CalcSize(Utility.content).x;
            EditorGUI.BeginChangeCheck();
            ProfilesManager.Profile.projects[index] = EditorGUI.TextField(rect, ProfilesManager.Profile.projects[index], this.textStyle);
            if (EditorGUI.EndChangeCheck() == true)
            {
                this.CheckUnityProject(ProfilesManager.Profile.projects[index]);
                ProfilesManager.Save();
            }

            rect.x    += rect.width;
            rect.width = GUI.skin.label.CalcSize(Utility.content).x;

            GUI.Label(rect, unityVersion, this.labelStyle);

            rect.x    += rect.width;
            rect.width = 60F;

            int v = -1;

            lock (this.deployingProjects)
            {
                if (this.deployingProjects.TryGetValue(ProfilesManager.Profile.projects[index], out v) == true)
                {
                    if (v == 101)
                    {
                        Utility.content.text = "Pending";
                    }
                    else if (v == 102)
                    {
                        Utility.content.text = "Compiling";
                    }
                    else
                    {
                        Utility.content.text = v + "%";
                    }

                    this.Repaint();
                }
                else
                {
                    Utility.content.text = "Deploy";
                }
            }

            EditorGUI.BeginDisabledGroup(error != null || Utility.content.text != "Deploy");
            if (GUI.Button(rect, Utility.content) == true)
            {
                this.AsyncDeploy(ProfilesManager.Profile.projects[index]);
            }
            EditorGUI.EndDisabledGroup();

            if (error != null)
            {
                Utility.content.tooltip = string.Empty;
            }
        }
        protected virtual void  OnGUI()
        {
            ProfilesManager.OnProfilesBarGUI();
            if (ProfilesManager.IsReady == false)
            {
                return;
            }

            if (this.textStyle == null)
            {
                this.textStyle            = new GUIStyle(GUI.skin.textField);
                this.textStyle.alignment  = TextAnchor.MiddleLeft;
                this.labelStyle           = new GUIStyle(GUI.skin.label);
                this.labelStyle.alignment = TextAnchor.MiddleLeft;
            }

            this.scrollPosition = EditorGUILayout.BeginScrollView(this.scrollPosition);
            {
                EditorGUI.BeginChangeCheck();
                ProfilesManager.Profile.packagePath = EditorGUILayout.TextField(this.packageFolderContent, ProfilesManager.Profile.packagePath);
                Rect r2 = GUILayoutUtility.GetLastRect();
                r2.x += 107F;
                GUI.Label(r2, "Assets/");
                if (EditorGUI.EndChangeCheck() == true || this.packageFolderError == null)
                {
                    if (string.IsNullOrEmpty(ProfilesManager.Profile.packagePath) == true || Directory.Exists("Assets/" + ProfilesManager.Profile.packagePath) == false)
                    {
                        this.packageFolderError = "Package at \"Assets/" + ProfilesManager.Profile.packagePath + "\" was not found.";
                    }
                    else
                    {
                        this.packageFolderError = string.Empty;
                    }

                    ProfilesManager.Save();
                }

                if (this.packageFolderError != string.Empty)
                {
                    EditorGUILayout.HelpBox(this.packageFolderError, MessageType.Warning);
                }

                EditorGUI.BeginChangeCheck();
                ProfilesManager.Profile.deployMeta = EditorGUILayout.Toggle("Copy Meta", ProfilesManager.Profile.deployMeta);
                if (EditorGUI.EndChangeCheck() == true)
                {
                    ProfilesManager.Save();
                }

                GUILayout.Space(10F);

                EditorGUILayout.LabelField("Unity Projects:");
                EditorGUILayout.BeginHorizontal();
                {
                    if (GUILayout.Button("Detect Projects") == true)
                    {
                        string path = EditorUtility.OpenFolderPanel("Folder with Unity Projects ending by A.B.C[abfpx]NN", string.Empty, string.Empty);

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

                    if (GUILayout.Button("Generate Projects") == true)
                    {
                        GenerateProjectsWindow window = EditorWindow.GetWindow <GenerateProjectsWindow>(true, GenerateProjectsWindow.Title, true);

                        window.packagePath           = ProfilesManager.Profile.packagePath;
                        window.projects              = ProfilesManager.Profile.projects;
                        window.unityInstallsDetected = this.unityInstalls;
                    }

                    EditorGUI.BeginDisabledGroup(this.packageFolderError != string.Empty);
                    if (GUILayout.Button("Deploy All") == true && EditorUtility.DisplayDialog("Deploy All", "Package is gonna be erased before deploying in all projects. May takes few minutes.", "Yes", "No") == true)
                    {
                        this.AsyncDeployAll();
                    }
                    EditorGUI.EndDisabledGroup();
                }
                EditorGUILayout.EndHorizontal();

                if (ProfilesManager.Profile.projects.Count == 0)
                {
                    EditorGUILayout.HelpBox("Path must be \"C:\\Path\\To\\Your\\Project A.B.C[abfpx]NN\" with A.B.C[abfpx]NN the Unity version. (e.g. 4.5.0f2, 5.3.5b14)", MessageType.Info);
                }

                this.list.DoLayoutList();

                if (this.unityProcessesDetected.Count >= 2)
                {
                    EditorGUILayout.LabelField("Unity processes:");
                    for (int i = 0; i < this.unityProcessesDetected.Count; i++)
                    {
                        EditorGUILayout.LabelField(this.unityProcessesDetected[i]);
                    }
                }
            }
            EditorGUILayout.EndScrollView();

            if (this.unityProcessesDetected.Count >= 2)
            {
                EditorGUILayout.HelpBox("Many Unity processes detected. You should not launch more than one Unity Editor when deploying, to avoid log collision, since they all share the same editor.log.", MessageType.Warning);
            }
        }
        protected virtual void  OnGUI()
        {
            ProfilesManager.OnProfilesBarGUI();
            if (ProfilesManager.IsReady == false)
            {
                return;
            }

            EditorGUILayout.LabelField("Default keywords:");
            EditorGUI.BeginDisabledGroup(true);
            for (int i = 0; i < NGPackageExcluderWindow.DefaultKeywords.Length; i++)
            {
                EditorGUILayout.TextField(NGPackageExcluderWindow.DefaultKeywords[i]);
            }
            EditorGUI.EndDisabledGroup();

            EditorGUILayout.LabelField("Excluded keywords:");
            for (int i = 0; i < ProfilesManager.Profile.excludeKeywords.Count; i++)
            {
                EditorGUILayout.BeginHorizontal();
                {
                    ProfilesManager.Profile.excludeKeywords[i] = EditorGUILayout.TextField(ProfilesManager.Profile.excludeKeywords[i]);
                    if (GUILayout.Button("X", GUILayout.Width(20F)) == true)
                    {
                        ProfilesManager.Profile.excludeKeywords.RemoveAt(i);
                        ProfilesManager.Save();
                        break;
                    }
                }
                EditorGUILayout.EndHorizontal();
            }

            EditorGUILayout.BeginHorizontal();
            {
                if (GUILayout.Button("Add") == true)
                {
                    ProfilesManager.Profile.excludeKeywords.Add(string.Empty);
                    ProfilesManager.Save();
                }

                if (GUILayout.Button("Save") == true)
                {
                    StringBuilder buffer = Utility.GetBuffer();

                    for (int i = 0; i < ProfilesManager.Profile.excludeKeywords.Count; i++)
                    {
                        if (ProfilesManager.Profile.excludeKeywords[i] != string.Empty)
                        {
                            buffer.Append(ProfilesManager.Profile.excludeKeywords[i]);
                            buffer.Append(NGPackageExcluderWindow.KeywordSeparator);
                        }
                    }

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

                    ProfilesManager.Save();
                }
            }
            EditorGUILayout.EndHorizontal();

            GUILayout.Space(10F);

            EditorGUILayout.LabelField("Include keywords:");
            for (int i = 0; i < ProfilesManager.Profile.includeKeywords.Count; i++)
            {
                EditorGUILayout.BeginHorizontal();
                {
                    ProfilesManager.Profile.includeKeywords[i] = EditorGUILayout.TextField(ProfilesManager.Profile.includeKeywords[i]);
                    if (GUILayout.Button("X", GUILayout.Width(20F)) == true)
                    {
                        ProfilesManager.Profile.includeKeywords.RemoveAt(i);
                        ProfilesManager.Save();
                        break;
                    }
                }
                EditorGUILayout.EndHorizontal();
            }

            EditorGUILayout.BeginHorizontal();
            {
                if (GUILayout.Button("Add") == true)
                {
                    ProfilesManager.Profile.includeKeywords.Add(string.Empty);
                    ProfilesManager.Save();
                }

                if (GUILayout.Button("Save") == true)
                {
                    StringBuilder buffer = Utility.GetBuffer();

                    for (int i = 0; i < ProfilesManager.Profile.includeKeywords.Count; i++)
                    {
                        if (ProfilesManager.Profile.includeKeywords[i] != string.Empty)
                        {
                            buffer.Append(ProfilesManager.Profile.includeKeywords[i]);
                            buffer.Append(NGPackageExcluderWindow.KeywordSeparator);
                        }
                    }

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

                    ProfilesManager.Save();
                }
            }
            EditorGUILayout.EndHorizontal();
        }
Exemple #8
0
        public static void      OnProfilesBarGUI()
        {
            if (Event.current.type == EventType.KeyDown &&
                Event.current.modifiers == EventModifiers.Control)
            {
                if (Event.current.keyCode == KeyCode.Q && ProfilesManager.current > 0)
                {
                    GUI.FocusControl(null);
                    ProfilesManager.SwitchFavorite(ProfilesManager.current - 1);
                }
                else if (Event.current.keyCode == KeyCode.E && ProfilesManager.current < ProfilesManager.profiles.Count - 1)
                {
                    GUI.FocusControl(null);
                    ProfilesManager.SwitchFavorite(ProfilesManager.current + 1);
                }

                Event.current.Use();
            }

            EditorGUILayout.BeginHorizontal("Toolbar");
            {
                if (ProfilesManager.profiles == null)
                {
                    GUILayout.Label("Profiles not loaded yet.");
                }
                else
                {
                    if (GUILayout.Button("", "ToolbarDropDown", GUILayout.Width(20F)) == true)
                    {
                        Rect r = GUILayoutUtility.GetLastRect();
                        r.y += 16F;
                        new ProfilesPopup().Open(r);
                    }

                    EditorGUILayout.BeginHorizontal();
                    {
                        EditorGUI.BeginDisabledGroup(ProfilesManager.current <= 0);
                        if (GUILayout.Button("<", "ToolbarButton", GUILayout.Width(30F)) == true)
                        {
                            ProfilesManager.SwitchFavorite(ProfilesManager.current - 1);
                        }
                        EditorGUI.EndDisabledGroup();

                        EditorGUI.BeginDisabledGroup(ProfilesManager.current >= ProfilesManager.profiles.Count - 1);
                        if (GUILayout.Button(">", "ToolbarButton", GUILayout.Width(30F)) == true)
                        {
                            ProfilesManager.SwitchFavorite(ProfilesManager.current + 1);
                        }
                        EditorGUI.EndDisabledGroup();

                        EditorGUI.BeginChangeCheck();
                        ProfilesManager.Profile.name = EditorGUILayout.TextField(ProfilesManager.Profile.name, new GUIStyle("ToolbarTextField"), GUILayout.ExpandWidth(true));
                        if (EditorGUI.EndChangeCheck() == true)
                        {
                            ProfilesManager.Save();
                        }
                    }
                    EditorGUILayout.EndHorizontal();

                    EditorGUI.BeginDisabledGroup(ProfilesManager.profiles.Count <= 1);
                    if (GUILayout.Button("X", "ToolbarButton") == true && EditorUtility.DisplayDialog("Profiles", "Confirm deletion of " + ProfilesManager.Profile.name, "Yes", "No") == true)
                    {
                        ProfilesManager.profiles.RemoveAt(ProfilesManager.current);
                        ProfilesManager.current = Mathf.Clamp(ProfilesManager.current, 0, ProfilesManager.profiles.Count - 1);
                        ProfilesManager.Save();
                    }
                    EditorGUI.EndDisabledGroup();
                }
            }
            EditorGUILayout.EndHorizontal();
        }
Exemple #9
0
 private void    ReorderElement(ReorderableList list)
 {
     ProfilesManager.Save();
 }