Ejemplo n.º 1
0
        private void OnGUI()
        {
            using (GUILayoutHelper.VerticalIdented(14))
            {
                GUILayout.Label("Unity Version Control (UVC), Version : " + VCUtility.GetCurrentVersion(), EditorStyles.boldLabel);
                EditorGUILayout.TextArea(infoText);

                var linkStyle = new GUIStyle(EditorStyles.label)
                {
                    normal = { textColor = new Color(0.4f, 0.4f, 1.0f) }
                };
                if (GUILayout.Button(maintainAtURL, linkStyle))
                {
                    System.Diagnostics.Process.Start(maintainAtURL);
                }
            }
        }
Ejemplo n.º 2
0
        private void OnGUI()
        {
            using (GUILayoutHelper.Vertical())
            {
                username = EditorGUILayout.TextField("Username", username);
                Color passwordColor = Color.grey;
                if (hasVerified && !success)
                {
                    passwordColor = Color.red;
                }
                if (hasVerified && success)
                {
                    passwordColor = Color.green;
                }
                using (GUILayoutHelper.BackgroundColor(passwordColor))
                {
                    password = EditorGUILayout.PasswordField("Password", password);
                }

                allowCacheCredentials = GUILayout.Toggle(allowCacheCredentials, new GUIContent("Allow Credentials to be cached"));

                using (GUILayoutHelper.Horizontal())
                {
                    if (GUILayout.Button("Cancel"))
                    {
                        Close();
                    }
                    if (!success)
                    {
                        if (GUILayout.Button("Verify"))
                        {
                            hasVerified = true;
                            success     = VCCommands.Instance.SetUserCredentials(username, password, allowCacheCredentials);
                        }
                    }
                    else
                    {
                        if (GUILayout.Button("Close"))
                        {
                            Close();
                        }
                    }
                }
            }
        }
Ejemplo n.º 3
0
        public void DrawGUI()
        {
            scrollViewVector = EditorGUILayout.BeginScrollView(scrollViewVector, false, false);
            using (GUILayoutHelper.Horizontal())
            {
                GUILayout.Label("GUI Settings", EditorStyles.boldLabel);
                GUILayout.FlexibleSpace();
                GUILayout.Label(new GUIContent("Inspector Lock", "Version Control allowed to lock Inspector GUI for items not " + Terminology.getlock), EditorStyles.boldLabel);
                GUILayout.Space(92);
            }
            using (GUILayoutHelper.VerticalIdented(14))
            {
                using (GUILayoutHelper.Horizontal())
                {
                    VCSettings.SceneviewGUI = GUILayout.Toggle(VCSettings.SceneviewGUI, new GUIContent("Scene GUI", "Show Version Control GUI in Scene view\nDefault: On"));
                    using (GUILayoutHelper.Enabled(VCSettings.SceneviewGUI, true))
                    {
                        VCSettings.LockScenes = GUILayout.Toggle(VCSettings.SceneviewGUI && VCSettings.LockScenes, new GUIContent("GUI Lock", "Version Control allowed to lock Inspector GUI for scenes which are not " + Terminology.getlock + "\nDefault: On"), GUILayout.ExpandWidth(true), GUILayout.Width(180));
                    }
                }
                using (GUILayoutHelper.Horizontal())
                {
                    VCSettings.MaterialGUI = GUILayout.Toggle(VCSettings.MaterialGUI, new GUIContent("Material GUI", "Show Version Control GUI for material interaction on the Renderer inspector\nDefault: On"));
                }

                using (GUILayoutHelper.Horizontal())
                {
                    VCSettings.LockAssets = GUILayout.Toggle(VCSettings.LockAssets, new GUIContent("Project Asset Lock", "Version Control allowed to lock Inspector GUI for project assets which are " + Terminology.getlock + "\nDefault: On"), GUILayout.ExpandWidth(true), GUILayout.Width(180));
                }
            }

            using (GUILayoutHelper.VerticalIdented(14))
            {
                using (GUILayoutHelper.Horizontal())
                {
                    filterSettingsOpen = GUILayout.Toggle(filterSettingsOpen, new GUIContent("Path Filters", "The Inspector GUI locks will only be active on assetpaths that contains the filter below"), EditorStyles.foldout);
                }
                if (filterSettingsOpen)
                {
                    using (GUILayoutHelper.VerticalIdented(14))
                    {
                        using (GUILayoutHelper.Horizontal())
                        {
                            GUILayout.Label(new GUIContent("Scenes", "The Inspector GUI locks will only be active on assetpaths that contains the following filter.\neg. assets/scenes/"));
                            VCSettings.LockScenesFilter = EditorGUILayout.TextField(VCSettings.LockScenesFilter, GUILayout.ExpandWidth(true), GUILayout.Width(180));
                        }
                    }
                }
            }

            using (GUILayoutHelper.Horizontal())
            {
                GUILayout.Label("Reflection Level", EditorStyles.boldLabel);
                GUILayout.FlexibleSpace();
                GUILayout.Label(new GUIContent("Reflection Level", "Select Remote to retrieve extra information from the server in an exchange for speed."), EditorStyles.boldLabel);
                GUILayout.Space(85);
            }
            using (GUILayoutHelper.VerticalIdented(14))
            {
                using (GUILayoutHelper.Horizontal())
                {
                    VCSettings.HierarchyIcons          = GUILayout.Toggle(VCSettings.HierarchyIcons, new GUIContent("Hierarchy Icons", "Show Version Control controls in hierarchy view\nDefault: On"));
                    VCSettings.HierarchyReflectionMode = (VCSettings.EReflectionLevel)EditorGUILayout.EnumPopup(VCSettings.HierarchyReflectionMode, GUILayout.ExpandWidth(true), GUILayout.Width(180));
                }
                using (GUILayoutHelper.Horizontal())
                {
                    VCSettings.ProjectIcons          = GUILayout.Toggle(VCSettings.ProjectIcons, new GUIContent("Project Icons", "Show Version Control controls in project view\nDefault: On"));
                    VCSettings.ProjectReflectionMode = (VCSettings.EReflectionLevel)EditorGUILayout.EnumPopup(VCSettings.ProjectReflectionMode, GUILayout.ExpandWidth(true), GUILayout.Width(180));
                }
            }

            GUILayout.Label("Commit Window", EditorStyles.boldLabel);
            using (GUILayoutHelper.VerticalIdented(14))
            {
                VCSettings.AutoCloseAfterSuccess       = GUILayout.Toggle(VCSettings.AutoCloseAfterSuccess, new GUIContent("Auto Close", "Auto close commit window on successful commit\nDefault: Off"));
                VCSettings.IncludeDepedenciesAsDefault = GUILayout.Toggle(VCSettings.IncludeDepedenciesAsDefault, new GUIContent("Select Dependencies", "Should dependencies automatically be selected when opening the commit window\nDefault: On"));
                VCSettings.SelectiveCommit             = GUILayout.Toggle(VCSettings.SelectiveCommit, new GUIContent("Selective Commit", "Add an additional selection column which is used to more explicitly select which files to commit\nDefault: Off"));
                VCSettings.RequireLockBeforeCommit     = GUILayout.Toggle(VCSettings.RequireLockBeforeCommit, new GUIContent("Require " + Terminology.getlock + " on commit", "It will be enforced that all non-mergable files are " + Terminology.getlock + " before commit\nDefault: Off"));
            }
            GUILayout.Label("Debug", EditorStyles.boldLabel);
            using (GUILayoutHelper.VerticalIdented(14))
            {
                using (GUILayoutHelper.Horizontal())
                {
                    VCSettings.BugReport     = GUILayout.Toggle(VCSettings.BugReport, new GUIContent("Bug Reports", "Send a bug report to Fogbugz when an error occurs\nDefault: On"));
                    VCSettings.BugReportMode = (VCSettings.EBugReportMode)EditorGUILayout.EnumPopup(VCSettings.BugReportMode, GUILayout.ExpandWidth(true), GUILayout.Width(180));
                }
                VCSettings.Analytics = GUILayout.Toggle(VCSettings.Analytics, new GUIContent("Analytics", "Allow UVC to send anonymous analytics data with the purpose of improving the quality of UVC\nDefault: On"));
                VCSettings.Logging   = GUILayout.Toggle(VCSettings.Logging, new GUIContent("Logging", "Output logs from Version Control to Unity console\nDefault: Off"));
            }
            GUILayout.Label("Advanced", EditorStyles.boldLabel);
            using (GUILayoutHelper.VerticalIdented(14))
            {
                using (GUILayoutHelper.Horizontal())
                {
                    GUILayout.Label(new GUIContent("How to Move and Rename", "How should file move and renames in project be handled\nDefault: Simple"));
                    VCSettings.HandleFileMove = (VCSettings.EHandleFileMove)EditorGUILayout.EnumPopup(VCSettings.HandleFileMove, GUILayout.ExpandWidth(true), GUILayout.Width(180));
                }
                using (GUILayoutHelper.Horizontal())
                {
                    GUILayout.Label(new GUIContent(string.Format("Who Controls Asset Saves", Terminology.getlock),
                                                   $"Select {VCSettings.ESaveAssetsStrategy.VersionControl.ToString()} to only let Unity save files that are either {Terminology.allowLocalEdit} or {Terminology.getlock} \nDefault: {VCSettings.ESaveAssetsStrategy.Unity.ToString()}"));
                    VCSettings.SaveStrategy = (VCSettings.ESaveAssetsStrategy)EditorGUILayout.EnumPopup(VCSettings.SaveStrategy, GUILayout.ExpandWidth(true), GUILayout.Width(180));
                }
                using (GUILayoutHelper.Horizontal())
                {
                    GUILayout.Label(new GUIContent("Version Control System", "The selected Version Control will be used if a valid local copy can be found"));
                    VCSettings.VersionControlBackend = (VCSettings.EVersionControlBackend)EditorGUILayout.EnumPopup(VCSettings.VersionControlBackend, GUILayout.ExpandWidth(true), GUILayout.Width(180));
                }
                using (GUILayoutHelper.Horizontal())
                {
                    GUILayout.Label(new GUIContent("External Merge Tool", "The selected Merge Tool must be installed"));
                    EditorGUI.BeginChangeCheck();
                    VCSettings.MergeToolIndex = EditorGUILayout.Popup(VCSettings.MergeToolIndex, MergeToolNames, GUILayout.ExpandWidth(true), GUILayout.Width(180));
                    if (EditorGUI.EndChangeCheck())
                    {
                        var mergeTool = VCSettings.mergeTools[VCSettings.MergeToolIndex];
                        VCSettings.MergetoolPath = mergeTool.pathMerge.Replace("~", GetUserHomePath());
                        VCSettings.MergetoolArgs = mergeTool.argumentsMerge;
                        VCSettings.DifftoolPath  = mergeTool.pathDiff.Replace("~", GetUserHomePath());
                        VCSettings.DifftoolArgs  = mergeTool.argumentsDiff;
                    }
                }
                using (GUILayoutHelper.VerticalIdented(14))
                {
                    bool validmergeTool = ValidCommandLine(VCSettings.MergetoolPath);
                    using (GUILayoutHelper.Horizontal())
                    {
                        GUILayout.Label(new GUIContent("Merge Tool Path", validmergeTool ? "Valid path to command line tool" : "Invalid path to command line tool"));
                    }
                    using (GUILayoutHelper.VerticalIdented(14))
                    {
                        using (GUILayoutHelper.Color(validmergeTool ? validColor : invalidColor))
                        {
                            VCSettings.MergetoolPath = EditorGUILayout.TextField(VCSettings.MergetoolPath, GUILayout.ExpandWidth(true)).Replace('\\', '/').Replace("~", GetUserHomePath());
                        }
                    }
                    GUILayout.Label(new GUIContent("Merge Tool Arguments", "Include : [base] [theirs] [yours] [merge]"));
                    using (GUILayoutHelper.VerticalIdented(14))
                    {
                        VCSettings.MergetoolArgs = EditorGUILayout.TextField(VCSettings.MergetoolArgs, GUILayout.ExpandWidth(true));
                    }

                    bool validDiffTool = ValidCommandLine(VCSettings.DifftoolPath);
                    using (GUILayoutHelper.Horizontal())
                    {
                        GUILayout.Label(new GUIContent("Diff Tool Path", validDiffTool ? "Valid path to command line tool" : "Invalid path to command line tool"));
                    }

                    using (GUILayoutHelper.VerticalIdented(14))
                    {
                        using (GUILayoutHelper.Color(validDiffTool ? validColor : invalidColor))
                        {
                            VCSettings.DifftoolPath = EditorGUILayout.TextField(VCSettings.DifftoolPath, GUILayout.ExpandWidth(true)).Replace('\\', '/').Replace("~", GetUserHomePath());
                        }
                    }
                    GUILayout.Label(new GUIContent("Diff Tool Arguments", "Include : [theirs] [yours]"));
                    using (GUILayoutHelper.VerticalIdented(14))
                    {
                        VCSettings.DifftoolArgs = EditorGUILayout.TextField(VCSettings.DifftoolArgs, GUILayout.ExpandWidth(true));
                    }
                }
            }
            EditorGUILayout.EndScrollView();
        }
Ejemplo n.º 4
0
        static void SceneViewUpdate(SceneView sceneView)
        {
            using (sceneviewUpdateMarker.Auto())
            {
                InitializeIfNeeded();
                if (!shouldDraw)
                {
                    return;
                }

                // This optimization is causing problems for following sceneview GUI, so removed for now.
                //if (Event.current.type == EventType.MouseMove || Event.current.type == EventType.MouseDrag)
                //    return;

                var stateRect     = new Rect(2f, 2f, buttonWidth, buttonHeight);
                var selectionRect = new Rect(2f + buttonWidth, 1f, 700f, buttonHeight);
                var buttonRect    = new Rect(2f, 2f, buttonWidth, buttonHeight);

                Handles.BeginGUI();

                GUI.TextField(stateRect, AssetStatusUtils.GetStatusText(vcSceneStatus), backgroundGuiStyle);
                GUI.Label(selectionRect, selectionPath.Substring(selectionPath.LastIndexOf('/') + 1), EditorStyles.miniLabel);

                int       numberOfButtons = 0;
                const int maxButtons      = 4;

                using (new PushState <bool>(GUI.enabled, VCCommands.Instance.Ready, v => GUI.enabled = v))
                {
                    if ((validActions & ValidActions.Add) != 0)
                    {
                        buttonRect.y += buttonHeight;
                        numberOfButtons++;
                        if (GUI.Button(buttonRect, addContent, buttonStyle))
                        {
                            SceneManagerUtilities.SaveActiveScene();
                            OnNextUpdate.Do(() => VCCommands.Instance.CommitDialog(new[] { selectionPath }));
                        }
                    }

                    if ((validActions & ValidActions.Open) != 0)
                    {
                        buttonRect.y += buttonHeight;
                        numberOfButtons++;
                        if (GUI.Button(buttonRect, getLockContent, buttonStyle))
                        {
                            VCCommands.Instance.GetLockTask(new[] { selectionPath });
                        }
                    }

                    if ((validActions & ValidActions.Commit) != 0)
                    {
                        buttonRect.y += buttonHeight;
                        numberOfButtons++;
                        if (GUI.Button(buttonRect, commitContent, buttonStyle))
                        {
                            OnNextUpdate.Do(() => VCCommands.Instance.CommitDialog(new[] { selectionPath }));
                        }
                    }

                    if ((validActions & ValidActions.Revert) != 0)
                    {
                        buttonRect.y += buttonHeight;
                        numberOfButtons++;
                        if (GUI.Button(buttonRect, revertContent, buttonStyle))
                        {
                            var sceneAssetPath = new[] { selectionPath };
                            if (Event.current.shift || VCUtility.VCDialog(Terminology.revert, sceneAssetPath))
                            {
                                VCCommands.Instance.Revert(sceneAssetPath);
                            }
                        }
                    }

                    if ((validActions & ValidActions.OpenLocal) != 0)
                    {
                        buttonRect.y += buttonHeight;
                        numberOfButtons++;
                        if (GUI.Button(buttonRect, allowLocalEditContent, buttonStyle))
                        {
                            VCCommands.Instance.AllowLocalEdit(new[] { selectionPath });
                        }
                    }

                    if ((validActions & ValidActions.Unlock) != 0)
                    {
                        buttonRect.y += buttonHeight;
                        numberOfButtons++;
                        if (GUI.Button(buttonRect, unlockContent, buttonStyle))
                        {
                            OnNextUpdate.Do(() => VCCommands.Instance.ReleaseLock(new[] { selectionPath }));
                        }
                    }

                    // bug: Workaround for a bug in Unity to avoid Tools getting stuck when number of GUI elements change while right mouse is down.
                    using (GUILayoutHelper.Enabled(false))
                    {
                        for (int i = numberOfButtons; i <= maxButtons; ++i)
                        {
                            GUI.Button(new Rect(0, 0, 0, 0), "", EditorStyles.label);
                        }
                    }
                }
                Handles.EndGUI();
            }
        }
Ejemplo n.º 5
0
        public static CustomDialog CreateExceptionDialog(string title, string message, VCException e)
        {
            bool         stackTraceToggle      = false;
            bool         innerStackTraceToggle = false;
            bool         detailsToggle         = false;
            bool         isCritical            = e is VCCriticalException;
            Vector2      scrollPos             = Vector2.zero;
            CustomDialog dialog = CustomDialog.Create(title);

            dialog
            .CenterOnScreen()
            .SetBodyGUI(() =>
            {
                if (e != null)
                {
                    scrollPos = GUILayout.BeginScrollView(scrollPos);
                    if (!string.IsNullOrEmpty(message))
                    {
                        EditorGUILayout.HelpBox(message, isCritical ? MessageType.Error : MessageType.Warning);
                    }

                    if (!string.IsNullOrEmpty(e.ErrorDetails))
                    {
                        detailsToggle = GUILayout.Toggle(detailsToggle, "Details", EditorStyles.foldout);
                        if (detailsToggle)
                        {
                            using (GUILayoutHelper.VerticalIdented(14))
                            {
                                GUILayout.BeginVertical(GUI.skin.box);
                                GUILayout.TextField(e.ErrorDetails);
                                GUILayout.EndVertical();
                            }
                        }
                    }

                    if (!string.IsNullOrEmpty(e.StackTrace))
                    {
                        stackTraceToggle = GUILayout.Toggle(stackTraceToggle, "Stacktrace", EditorStyles.foldout);
                        if (stackTraceToggle)
                        {
                            using (GUILayoutHelper.VerticalIdented(14))
                            {
                                GUILayout.BeginVertical(GUI.skin.box);
                                GUILayout.TextField(e.StackTrace);
                                GUILayout.EndVertical();
                            }
                        }
                    }

                    if (e.InnerException != null)
                    {
                        if (!string.IsNullOrEmpty(e.InnerException.StackTrace))
                        {
                            innerStackTraceToggle = GUILayout.Toggle(innerStackTraceToggle, "Inner Stacktrace", EditorStyles.foldout);
                            if (innerStackTraceToggle)
                            {
                                using (GUILayoutHelper.VerticalIdented(14))
                                {
                                    GUILayout.BeginVertical(GUI.skin.box);
                                    GUILayout.TextField(e.InnerException.StackTrace);
                                    GUILayout.EndVertical();
                                }
                            }
                        }
                    }
                    GUILayout.FlexibleSpace();
                    GUILayout.EndScrollView();
                }
            })
            .AddButton("OK", () => dialog.Close(), GUILayout.Width(60f))
            .AddButton("Copy To Clipboard", () =>
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendFormat("Title: {0}\r\n\r\n", title);
                if (!string.IsNullOrEmpty(message))
                {
                    sb.AppendFormat("Message: {0}\r\n", message);
                }
                if (!string.IsNullOrEmpty(e.ErrorDetails))
                {
                    sb.AppendFormat("\r\nDetails:\r\n{0}\r\n", e.ErrorDetails);
                }
                if (!string.IsNullOrEmpty(e.StackTrace))
                {
                    sb.AppendFormat("\r\nStacktrace:\r\n{0}\r\n", e.StackTrace);
                }
                if (e.InnerException != null && !string.IsNullOrEmpty(e.StackTrace))
                {
                    sb.AppendFormat("\r\nInner Stacktrace:\r\n{0}\r\n", e.InnerException.StackTrace);
                }

                EditorGUIUtility.systemCopyBuffer = sb.ToString();
            });

            return(dialog);
        }
Ejemplo n.º 6
0
        public void DrawGUI()
        {
            scrollViewVector = EditorGUILayout.BeginScrollView(scrollViewVector, false, false);
            using (GUILayoutHelper.Horizontal())
            {
                GUILayout.Label("GUI Settings", EditorStyles.boldLabel);
                GUILayout.FlexibleSpace();
                GUILayout.Label(new GUIContent("Inspector Lock", "Version Control allowed to lock Inspector GUI for items not " + Terminology.getlock), EditorStyles.boldLabel);
                GUILayout.Space(92);
            }
            using (GUILayoutHelper.VerticalIdented(14))
            {
                using (GUILayoutHelper.Horizontal())
                {
                    VCSettings.SceneviewGUI = GUILayout.Toggle(VCSettings.SceneviewGUI, new GUIContent("Scene GUI", "Show Version Control GUI in Scene view\nDefault: On"));
                    using (GUILayoutHelper.Enabled(VCSettings.SceneviewGUI, true))
                    {
                        VCSettings.LockScenes = GUILayout.Toggle(VCSettings.SceneviewGUI && VCSettings.LockScenes, new GUIContent("GUI Lock", "Version Control allowed to lock Inspector GUI for scenes which are not " + Terminology.getlock + "\nDefault: On"), GUILayout.ExpandWidth(true), GUILayout.Width(180));
                    }
                }
                using (GUILayoutHelper.Horizontal())
                {
                    VCSettings.PrefabGUI = GUILayout.Toggle(VCSettings.PrefabGUI, new GUIContent("Prefab GUI", "Show Version Control GUI for prefabs in hierarchy view\nDefault: On"));
                    using (GUILayoutHelper.Enabled(VCSettings.PrefabGUI, true))
                    {
                        VCSettings.LockPrefabs = GUILayout.Toggle(VCSettings.LockPrefabs && VCSettings.PrefabGUI, new GUIContent("GUI Lock", "Version Control allowed to lock Inspector GUI for prefabs which are not " + Terminology.getlock + "\nDefault: Off"), GUILayout.ExpandWidth(true), GUILayout.Width(180));
                    }
                }
                using (GUILayoutHelper.Horizontal())
                {
                    VCSettings.MaterialGUI = GUILayout.Toggle(VCSettings.MaterialGUI, new GUIContent("Material GUI", "Show Version Control GUI for material interaction on the Renderer inspector\nDefault: On"));
                }

                using (GUILayoutHelper.Horizontal())
                {
                    VCSettings.LockAssets = GUILayout.Toggle(VCSettings.LockAssets, new GUIContent("Project Asset Lock", "Version Control allowed to lock Inspector GUI for project assets which are " + Terminology.getlock + "\nDefault: On"), GUILayout.ExpandWidth(true), GUILayout.Width(180));
                }
            }

            using (GUILayoutHelper.VerticalIdented(14))
            {
                using (GUILayoutHelper.Horizontal())
                {
                    filterSettingsOpen = GUILayout.Toggle(filterSettingsOpen, new GUIContent("Path Filters", "The Inspector GUI locks will only be active on assetpaths that contains the filter below"), EditorStyles.foldout);
                }
                if (filterSettingsOpen)
                {
                    using (GUILayoutHelper.VerticalIdented(14))
                    {
                        using (GUILayoutHelper.Horizontal())
                        {
                            GUILayout.Label(new GUIContent("Scenes", "The Inspector GUI locks will only be active on assetpaths that contains the following filter.\neg. assets/scenes/"));
                            VCSettings.LockScenesFilter = EditorGUILayout.TextField(VCSettings.LockScenesFilter, GUILayout.ExpandWidth(true), GUILayout.Width(180));
                        }
                        using (GUILayoutHelper.Horizontal())
                        {
                            GUILayout.Label(new GUIContent("Prefabs", "The Inspector GUI locks will only be active on assetpaths that contains the following filter.\neg. assets/prefabs/"));
                            VCSettings.LockPrefabsFilter = EditorGUILayout.TextField(VCSettings.LockPrefabsFilter, GUILayout.ExpandWidth(true), GUILayout.Width(180));
                        }
                    }
                }
            }

            using (GUILayoutHelper.Horizontal())
            {
                GUILayout.Label("Reflection Level", EditorStyles.boldLabel);
                GUILayout.FlexibleSpace();
                GUILayout.Label(new GUIContent("Reflection Level", "Select Remote to retrieve extra information from the server in an exchange for speed."), EditorStyles.boldLabel);
                GUILayout.Space(85);
            }
            using (GUILayoutHelper.VerticalIdented(14))
            {
                using (GUILayoutHelper.Horizontal())
                {
                    VCSettings.HierarchyIcons          = GUILayout.Toggle(VCSettings.HierarchyIcons, new GUIContent("Hierachy Icons", "Show Version Control controls in hierachy view\nDefault: On"));
                    VCSettings.HierarchyReflectionMode = (VCSettings.EReflectionLevel)EditorGUILayout.EnumPopup(VCSettings.HierarchyReflectionMode, GUILayout.ExpandWidth(true), GUILayout.Width(180));
                }
                using (GUILayoutHelper.Horizontal())
                {
                    VCSettings.ProjectIcons          = GUILayout.Toggle(VCSettings.ProjectIcons, new GUIContent("Project Icons", "Show Version Control controls in project view\nDefault: On"));
                    VCSettings.ProjectReflectionMode = (VCSettings.EReflectionLevel)EditorGUILayout.EnumPopup(VCSettings.ProjectReflectionMode, GUILayout.ExpandWidth(true), GUILayout.Width(180));
                }
            }

            GUILayout.Label("Commit Window", EditorStyles.boldLabel);
            using (GUILayoutHelper.VerticalIdented(14))
            {
                VCSettings.AutoCloseAfterSuccess       = GUILayout.Toggle(VCSettings.AutoCloseAfterSuccess, new GUIContent("Auto Close", "Auto close commit window on successful commit\nDefault: Off"));
                VCSettings.IncludeDepedenciesAsDefault = GUILayout.Toggle(VCSettings.IncludeDepedenciesAsDefault, new GUIContent("Select Dependencies", "Should dependencies automatically be selected when opening the commit window\nDefault: On"));
                VCSettings.SelectiveCommit             = GUILayout.Toggle(VCSettings.SelectiveCommit, new GUIContent("Selective Commit", "Add an additional selection column which is used to more explicitly select which files to commit\nDefault: Off"));
                VCSettings.RequireLockBeforeCommit     = GUILayout.Toggle(VCSettings.RequireLockBeforeCommit, new GUIContent("Require " + Terminology.getlock + " on commit", "It will be enforced that all non-mergable files are " + Terminology.getlock + " before commit\nDefault: Off"));
            }
            GUILayout.Label("Debug", EditorStyles.boldLabel);
            using (GUILayoutHelper.VerticalIdented(14))
            {
                using (GUILayoutHelper.Horizontal())
                {
                    VCSettings.BugReport     = GUILayout.Toggle(VCSettings.BugReport, new GUIContent("Bug Reports", "Send a bug report to Fogbugz when an error occurs\nDefault: On"));
                    VCSettings.BugReportMode = (VCSettings.EBugReportMode)EditorGUILayout.EnumPopup(VCSettings.BugReportMode, GUILayout.ExpandWidth(true), GUILayout.Width(180));
                }
                VCSettings.Analytics = GUILayout.Toggle(VCSettings.Analytics, new GUIContent("Analytics", "Allow UVC to send anonymous analytics data with the purpose of improving the quality of UVC\nDefault: On"));
                VCSettings.Logging   = GUILayout.Toggle(VCSettings.Logging, new GUIContent("Logging", "Output logs from Version Control to Unity console\nDefault: Off"));
            }
            GUILayout.Label("Advanced", EditorStyles.boldLabel);
            using (GUILayoutHelper.VerticalIdented(14))
            {
                using (GUILayoutHelper.Horizontal())
                {
                    GUILayout.Label(new GUIContent("How to Move and Rename", "How should file move and renames in project be handled\nDefault: Simple"));
                    VCSettings.HandleFileMove = (VCSettings.EHandleFileMove)EditorGUILayout.EnumPopup(VCSettings.HandleFileMove, GUILayout.ExpandWidth(true), GUILayout.Width(180));
                }
                using (GUILayoutHelper.Horizontal())
                {
                    GUILayout.Label(new GUIContent(string.Format("Who Controls Asset Saves", Terminology.getlock), string.Format("Select {0} to only let Unity save files that are either {1} or {2} \nDefault: {3}", VCSettings.ESaveAssetsStrategy.VersionControl.ToString(), Terminology.allowLocalEdit, Terminology.getlock, VCSettings.ESaveAssetsStrategy.Unity.ToString())));
                    VCSettings.SaveStrategy = (VCSettings.ESaveAssetsStrategy)EditorGUILayout.EnumPopup(VCSettings.SaveStrategy, GUILayout.ExpandWidth(true), GUILayout.Width(180));
                }
                if (clientPath == null)
                {
                    clientPath = VCSettings.ClientPath;
                }
                var textColor = ValidCommandLineClient(clientPath) ? new Color(0.0f, 0.6f, 0.0f) : new Color(0.6f, 0.0f, 0.0f);
                var textStyle = new GUIStyle(EditorStyles.textField)
                {
                    normal = { textColor = textColor }
                };
                using (GUILayoutHelper.Horizontal())
                {
                    GUILayout.Label(new GUIContent("Environment Path", "Specify the path to a command line client. eg MacPorts SVN : /opt/local/bin/\nDefault: <Empty>"));
                    clientPath = EditorGUILayout.TextField(clientPath, textStyle, GUILayout.ExpandWidth(true), GUILayout.Width(180)).Trim(new[] { ' ' }).Replace('\\', '/');
                }
                if (ValidCommandLineClient(clientPath))
                {
                    VCSettings.ClientPath = clientPath;
                }
                using (GUILayoutHelper.Horizontal())
                {
                    GUILayout.Label(new GUIContent("Version Control System", "The selected Version Control will be used if a valid local copy can be found"));
                    VCSettings.VersionControlBackend = (VCSettings.EVersionControlBackend)EditorGUILayout.EnumPopup(VCSettings.VersionControlBackend, GUILayout.ExpandWidth(true), GUILayout.Width(180));
                }
            }
            EditorGUILayout.EndScrollView();
        }
Ejemplo n.º 7
0
        static void SceneViewUpdate(SceneView sceneView)
        {
            EditorUpdate();
            if (!shouldDraw)
            {
                return;
            }

            if (Event.current.type == EventType.Layout)
            {
                string assetPath = selectionPath;
                VCUtility.RequestStatus(assetPath, VCSettings.HierarchyReflectionMode);
                vcSceneStatus = VCCommands.Instance.GetAssetStatus(assetPath);
                validActions  = VCGUIControls.GetValidActions(assetPath);
            }

            buttonStyle = new GUIStyle(EditorStyles.miniButton)
            {
                margin = new RectOffset(0, 0, 0, 0), fixedWidth = 80
            };

            backgroundGuiStyle           = VCGUIControls.GetVCBox(vcSceneStatus);
            backgroundGuiStyle.padding   = new RectOffset(4, 8, 1, 1);
            backgroundGuiStyle.margin    = new RectOffset(1, 1, 1, 1);
            backgroundGuiStyle.border    = new RectOffset(1, 1, 1, 1);
            backgroundGuiStyle.alignment = TextAnchor.MiddleCenter;

            var rect = new Rect(5, 5, 800, 100);

            Handles.BeginGUI();
            GUILayout.BeginArea(new Rect(0, 0, rect.width, rect.height));
            GUILayout.BeginHorizontal();
            GUILayout.TextField(AssetStatusUtils.GetLockStatusMessage(vcSceneStatus), backgroundGuiStyle);
            GUILayout.Label(selectionPath.Substring(selectionPath.LastIndexOf('/') + 1));
            GUILayout.EndHorizontal();


            int       numberOfButtons = 0;
            const int maxButtons      = 4;

            using (GUILayoutHelper.Vertical())
            {
                using (new PushState <bool>(GUI.enabled, VCCommands.Instance.Ready, v => GUI.enabled = v))
                {
                    if (validActions.showAdd)
                    {
                        numberOfButtons++;
                        if (GUILayout.Button(Terminology.add, buttonStyle))
                        {
                            SceneManagerUtilities.SaveActiveScene();
                            OnNextUpdate.Do(() => VCCommands.Instance.CommitDialog(new[] { selectionPath }));
                        }
                    }
                    if (validActions.showOpen)
                    {
                        numberOfButtons++;
                        if (GUILayout.Button(Terminology.getlock, buttonStyle))
                        {
                            VCCommands.Instance.GetLockTask(new[] { selectionPath });
                        }
                    }
                    if (validActions.showCommit)
                    {
                        numberOfButtons++;
                        if (GUILayout.Button(Terminology.commit, buttonStyle))
                        {
                            OnNextUpdate.Do(() => VCCommands.Instance.CommitDialog(new[] { selectionPath }));
                        }
                    }
                    if (validActions.showRevert)
                    {
                        numberOfButtons++;
                        if (GUILayout.Button(new GUIContent(Terminology.revert, "Shift-click to " + Terminology.revert + " without confirmation"), buttonStyle))
                        {
                            var sceneAssetPath = new[] { selectionPath };
                            if (Event.current.shift || VCUtility.VCDialog(Terminology.revert, sceneAssetPath))
                            {
                                VCCommands.Instance.Revert(sceneAssetPath);
                            }
                        }
                    }
                    if (validActions.showOpenLocal)
                    {
                        numberOfButtons++;
                        if (GUILayout.Button(Terminology.allowLocalEdit, buttonStyle))
                        {
                            VCCommands.Instance.AllowLocalEdit(new[] { selectionPath });
                        }
                    }
                    if (validActions.showUnlock)
                    {
                        numberOfButtons++;
                        if (GUILayout.Button(Terminology.unlock, buttonStyle))
                        {
                            OnNextUpdate.Do(() => VCCommands.Instance.ReleaseLock(new[] { selectionPath }));
                        }
                    }
                    if (validActions.showForceOpen)
                    {
                        numberOfButtons++;
                        if (GUILayout.Button("Force Open", buttonStyle))
                        {
                            OnNextUpdate.Do(() => VCUtility.GetLock(selectionPath, OperationMode.Force));
                        }
                    }

                    // bug: Workaround for a bug in Unity to avoid Tools getting stuck when number of GUI elements change while right mouse is down.
                    using (GUILayoutHelper.Enabled(false))
                    {
                        for (int i = numberOfButtons; i <= maxButtons; ++i)
                        {
                            GUI.Button(new Rect(0, 0, 0, 0), "", EditorStyles.label);
                        }
                    }
                }
            }


            GUILayout.EndArea();
            Handles.EndGUI();
        }
Ejemplo n.º 8
0
        private void DrawButtons()
        {
            EditorGUILayout.BeginHorizontal();

            GUI.SetNextControlName("CommitMessage");
            using (GUILayoutHelper.BackgroundColor(CommitMessage.Length < 10 ? new Color(1, 0, 0) : new Color(0, 1, 0)))
            {
                statusScroll  = EditorGUILayout.BeginScrollView(statusScroll, false, false);
                CommitMessage = EditorGUILayout.TextArea(CommitMessage, GUILayout.MinWidth(100), GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));
                EditorGUILayout.EndScrollView();
            }
            if (firstTime)
            {
                GUI.FocusControl("CommitMessage");
                firstTime = false;
            }

            using (new PushState <bool>(GUI.enabled, VCCommands.Instance.Ready, v => GUI.enabled = v))
            {
                if (GUILayout.Button(Terminology.commit, GUILayout.Width(100)))
                {
                    var selection = VCSettings.SelectiveCommit ? vcMultiColumnAssetList.GetMasterSelection() : vcMultiColumnAssetList.GetSelection();
                    if (selection.Count() != 0)
                    {
                        var selectedAssets = selection.Select(status => status.assetPath).Select(cstr => cstr.Compose()).ToList();
                        VCCommands.Instance.ProgressInformation += s =>
                        {
                            commitProgress = commitProgress + s;
                            if (commitProgress.Length > maxProgressSize)
                            {
                                commitProgress = commitProgress.Substring(commitProgress.Length - maxProgressSize);
                            }
                            statusScroll.y = Mathf.Infinity;
                            Repaint();
                        };
                        var commitTask = VCCommands.Instance.CommitTask(selectedAssets, CommitMessage);
                        commitTask.ContinueWithOnNextUpdate(result =>
                        {
                            if (result)
                            {
                                commitedFiles = selectedAssets;
                                CommitMessage = "";
                                Repaint();
                                if (VCSettings.AutoCloseAfterSuccess)
                                {
                                    Close();
                                }
                            }
                            commitCompleted = true;
                        });
                        commitInProgress = true;
                    }
                    else
                    {
                        ShowNotification(new GUIContent("No files selected"));
                    }
                }
                if (GUILayout.Button("Cancel", GUILayout.Width(100)))
                {
                    Close();
                }
            }
            EditorGUILayout.EndHorizontal();
            if (vcMultiColumnAssetList.GetSelection().Any())
            {
                RemoveNotification();
            }
        }