PasswordField() public static method

Make a text field where the user can enter a password.

public static PasswordField ( GUIContent label, string password ) : string
label UnityEngine.GUIContent Optional label to display in front of the password field.
password string The password to edit.
return string
        public void OnGUI()
        {
            if (AssetStoreLoginWindow.styles == null)
            {
                AssetStoreLoginWindow.styles = new AssetStoreLoginWindow.Styles();
            }
            AssetStoreLoginWindow.LoadLogos();
            if (AssetStoreClient.LoginInProgress() || AssetStoreClient.LoggedIn())
            {
                GUI.enabled = false;
            }
            GUILayout.BeginVertical(new GUILayoutOption[0]);
            GUILayout.Space(10f);
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.Space(5f);
            GUILayout.Label(AssetStoreLoginWindow.s_AssetStoreLogo, GUIStyle.none, new GUILayoutOption[]
            {
                GUILayout.ExpandWidth(false)
            });
            GUILayout.BeginVertical(new GUILayoutOption[0]);
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.Space(6f);
            GUILayout.Label(this.m_LoginReason, EditorStyles.wordWrappedLabel, new GUILayoutOption[0]);
            Rect lastRect = GUILayoutUtility.GetLastRect();

            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.Space(6f);
            Rect lastRect2 = new Rect(0f, 0f, 0f, 0f);

            if (this.m_LoginRemoteMessage != null)
            {
                Color color = GUI.color;
                GUI.color = Color.red;
                GUILayout.Label(this.m_LoginRemoteMessage, EditorStyles.wordWrappedLabel, new GUILayoutOption[0]);
                GUI.color = color;
                lastRect2 = GUILayoutUtility.GetLastRect();
            }
            float num = lastRect.height + lastRect2.height + 110f;

            if (Event.current.type == EventType.Repaint && num != base.position.height)
            {
                base.position = new Rect(base.position.x, base.position.y, base.position.width, num);
                base.Repaint();
            }
            GUILayout.EndHorizontal();
            GUILayout.FlexibleSpace();
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUI.SetNextControlName("username");
            this.m_Username = EditorGUILayout.TextField("Username", this.m_Username, new GUILayoutOption[0]);
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            this.m_Password = EditorGUILayout.PasswordField("Password", this.m_Password, new GUILayoutOption[]
            {
                GUILayout.ExpandWidth(true)
            });
            if (GUILayout.Button(new GUIContent("Forgot?", "Reset your password"), AssetStoreLoginWindow.styles.link, new GUILayoutOption[]
            {
                GUILayout.ExpandWidth(false)
            }))
            {
                Application.OpenURL("https://accounts.unity3d.com/password/new");
            }
            EditorGUIUtility.AddCursorRect(GUILayoutUtility.GetLastRect(), MouseCursor.Link);
            GUILayout.EndHorizontal();
            bool rememberSession = AssetStoreClient.RememberSession;
            bool flag            = EditorGUILayout.Toggle("Remember me", rememberSession, new GUILayoutOption[0]);

            if (flag != rememberSession)
            {
                AssetStoreClient.RememberSession = flag;
            }
            GUILayout.EndVertical();
            GUILayout.Space(5f);
            GUILayout.EndHorizontal();
            GUILayout.Space(8f);
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            if (GUILayout.Button("Create account", new GUILayoutOption[0]))
            {
                AssetStore.Open("createuser/");
                this.m_LoginRemoteMessage = "Cancelled - create user";
                base.Close();
            }
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Cancel", new GUILayoutOption[0]))
            {
                this.m_LoginRemoteMessage = "Cancelled";
                base.Close();
            }
            GUILayout.Space(5f);
            if (GUILayout.Button("Login", new GUILayoutOption[0]))
            {
                this.DoLogin();
                base.Repaint();
            }
            GUILayout.Space(5f);
            GUILayout.EndHorizontal();
            GUILayout.Space(5f);
            GUILayout.EndVertical();
            if (Event.current.Equals(Event.KeyboardEvent("return")))
            {
                this.DoLogin();
                base.Repaint();
            }
            if (this.m_Username == string.Empty)
            {
                EditorGUI.FocusTextInControl("username");
            }
        }
Beispiel #2
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            GUILayout.Space(10);
            GUILayout.BeginVertical(EditorStyles.inspectorDefaultMargins);

            bool collabEnabled = Collab.instance.IsCollabEnabledForCurrentProject();

            using (new EditorGUI.DisabledScope(!collabEnabled))
            {
                GUI.enabled = !collabEnabled;

                ExternalVersionControl selvc = VersionControlSettings.mode;
                CreatePopupMenuVersionControl(Styles.mode.text, vcPopupList, selvc, SetVersionControlSystem);
                GUI.enabled = !collabEnabled;
            }

            if (collabEnabled)
            {
                EditorGUILayout.HelpBox("Version Control not available when using Collaboration feature.",
                                        MessageType.Warning);
            }

            GUI.enabled = true;
            ConfigField[] configFields = null;

            if (VersionControlSystemHasGUI())
            {
                bool hasRequiredFields = false;

                if (VersionControlSettings.mode == ExternalVersionControl.Generic ||
                    VersionControlSettings.mode == ExternalVersionControl.Disabled)
                {
                    // no specific UI for these VCS types
                }
                else
                {
                    configFields = Provider.GetActiveConfigFields();

                    hasRequiredFields = true;

                    foreach (ConfigField field in configFields)
                    {
                        string newVal;
                        string oldVal = EditorUserSettings.GetConfigValue(field.name);
                        if (field.isPassword)
                        {
                            newVal = EditorGUILayout.PasswordField(GUIContent.Temp(field.label, field.description),
                                                                   oldVal);
                            if (newVal != oldVal)
                            {
                                EditorUserSettings.SetPrivateConfigValue(field.name, newVal);
                            }
                        }
                        else
                        {
                            var recentValues = GetVCConfigFieldRecentValues(field.name);
                            newVal = EditorGUILayout.TextFieldDropDown(GUIContent.Temp(field.label, field.description),
                                                                       oldVal, recentValues);
                            if (newVal != oldVal)
                            {
                                EditorUserSettings.SetConfigValue(field.name, newVal);
                            }
                        }

                        if (field.isRequired && string.IsNullOrEmpty(newVal))
                        {
                            hasRequiredFields = false;
                        }
                    }
                }

                // Log level popup
                string logLevel = EditorUserSettings.GetConfigValue("vcSharedLogLevel");
                int    idx      = System.Array.FindIndex(logLevelPopupList, (item) => item.ToLower() == logLevel);
                if (idx == -1)
                {
                    logLevel = "notice";
                    idx      = System.Array.FindIndex(logLevelPopupList, (item) => item.ToLower() == logLevel);
                    if (idx == -1)
                    {
                        idx = 0;
                    }

                    logLevel = logLevelPopupList[idx];
                    EditorUserSettings.SetConfigValue("vcSharedLogLevel", logLevel);
                }

                int newIdx = EditorGUILayout.Popup(Styles.logLevel, idx, logLevelPopupList);
                if (newIdx != idx)
                {
                    EditorUserSettings.SetConfigValue("vcSharedLogLevel", logLevelPopupList[newIdx].ToLower());
                }

                if (Provider.onlineState == OnlineState.Offline)
                {
                    var text = "Not Connected. " + (Provider.offlineReason ?? "");
                    EditorGUILayout.HelpBox(text, MessageType.Error);
                }
                else if (Provider.onlineState == OnlineState.Updating)
                {
                    var text = "Connecting...";
                    EditorGUILayout.HelpBox(text, MessageType.Info);
                }
                else if (EditorUserSettings.WorkOffline)
                {
                    var text =
                        "Working Offline. Manually integrate your changes using a version control client, and uncheck 'Work Offline' setting below to get back to regular state.";
                    EditorGUILayout.HelpBox(text, MessageType.Warning);
                }
                else if (Provider.onlineState == OnlineState.Online)
                {
                    var text = "Connected";
                    EditorGUILayout.HelpBox(text, MessageType.Info);
                }

                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                GUI.enabled = hasRequiredFields && Provider.onlineState != OnlineState.Updating;
                if (GUILayout.Button(
                        Provider.onlineState != OnlineState.Offline ? Styles.vcsReconnect : Styles.vcsConnect,
                        EditorStyles.miniButton))
                {
                    m_NeedToSaveValuesOnConnect = true;
                    Provider.UpdateSettings();
                }

                GUILayout.EndHorizontal();

                if (m_NeedToSaveValuesOnConnect && Provider.onlineState == OnlineState.Online)
                {
                    // save connection field settings if we got online with them successfully
                    m_NeedToSaveValuesOnConnect = false;
                    UpdateVCConfigFieldRecentValues(configFields);
                }

                if (Provider.requiresNetwork)
                {
                    bool workOfflineNew =
                        EditorGUILayout.Toggle(Styles.workOffline,
                                               EditorUserSettings.WorkOffline); // Enabled has a slightly different behaviour
                    if (workOfflineNew != EditorUserSettings.WorkOffline)
                    {
                        // On toggling on show a warning
                        if (workOfflineNew && !EditorUtility.DisplayDialog("Confirm working offline",
                                                                           "Working offline and making changes to your assets means that you will have to manually integrate changes back into version control using your standard version control client before you stop working offline in Unity. Make sure you know what you are doing.",
                                                                           "Work offline", "Cancel"))
                        {
                            workOfflineNew = false; // User cancelled working offline
                        }

                        EditorUserSettings.WorkOffline = workOfflineNew;
                        EditorApplication.RequestRepaintAllViews();
                    }
                }

                EditorUserSettings.AutomaticAdd =
                    EditorGUILayout.Toggle(Styles.automaticAdd, EditorUserSettings.AutomaticAdd);

                if (Provider.requiresNetwork)
                {
                    EditorUserSettings.allowAsyncStatusUpdate = EditorGUILayout.Toggle(Styles.allowAsyncUpdate,
                                                                                       EditorUserSettings.allowAsyncStatusUpdate);
                }

                if (Provider.hasCheckoutSupport)
                {
                    EditorUserSettings.showFailedCheckout = EditorGUILayout.Toggle(Styles.showFailedCheckouts,
                                                                                   EditorUserSettings.showFailedCheckout);
                    EditorUserSettings.overwriteFailedCheckoutAssets = EditorGUILayout.Toggle(
                        Styles.overwriteFailedCheckoutAssets, EditorUserSettings.overwriteFailedCheckoutAssets);
                }

                EditorUserSettings.semanticMergeMode = (SemanticMergeMode)EditorGUILayout.Popup(Styles.smartMerge,
                                                                                                (int)EditorUserSettings.semanticMergeMode, semanticMergePopupList);

                GUILayout.Space(10);
                GUILayout.Label(Styles.overlayIcons);

                EditorGUI.indentLevel++;
                var newProjectOverlayIcons = EditorGUILayout.Toggle(Styles.projectOverlayIcons, EditorUserSettings.overlayIcons);
                if (newProjectOverlayIcons != EditorUserSettings.overlayIcons)
                {
                    EditorUserSettings.overlayIcons = newProjectOverlayIcons;
                    EditorApplication.RequestRepaintAllViews();
                }

                var newHierarchyOverlayIcons = EditorGUILayout.Toggle(Styles.hierarchyOverlayIcons, EditorUserSettings.hierarchyOverlayIcons);
                if (newHierarchyOverlayIcons != EditorUserSettings.hierarchyOverlayIcons)
                {
                    EditorUserSettings.hierarchyOverlayIcons = newHierarchyOverlayIcons;
                    EditorApplication.RequestRepaintAllViews();
                }

                var newOtherOverlayIcons = EditorGUILayout.Toggle(Styles.otherOverlayIcons, EditorUserSettings.otherOverlayIcons);
                if (newOtherOverlayIcons != EditorUserSettings.otherOverlayIcons)
                {
                    EditorUserSettings.otherOverlayIcons = newOtherOverlayIcons;
                    EditorApplication.RequestRepaintAllViews();
                }
                EditorGUI.indentLevel--;
                GUILayout.Space(10);

                GUI.enabled = true;
                if (newProjectOverlayIcons || newHierarchyOverlayIcons || newOtherOverlayIcons)
                {
                    DrawOverlayDescriptions();
                }
            }
            GUILayout.EndVertical();
        }
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            // GUI.enabled hack because we don't want some controls to be disabled if the EditorSettings.asset is locked
            // since some of the controls are not dependent on the Editor Settings asset. Unfortunately, this assumes
            // that the editor will only be disabled because of version control locking which may change in the future.
            var editorEnabled = GUI.enabled;

            ShowUnityRemoteGUI(editorEnabled);

            GUILayout.Space(10);
            bool collabEnabled = Collab.instance.IsCollabEnabledForCurrentProject();

            using (new EditorGUI.DisabledScope(!collabEnabled))
            {
                GUI.enabled = !collabEnabled;
                GUILayout.Label(Content.versionControl, EditorStyles.boldLabel);

                ExternalVersionControl selvc = EditorSettings.externalVersionControl;
                CreatePopupMenuVersionControl(Content.mode.text, vcPopupList, selvc, SetVersionControlSystem);
                GUI.enabled = editorEnabled && !collabEnabled;
            }
            if (collabEnabled)
            {
                EditorGUILayout.HelpBox("Version Control not available when using Collaboration feature.", MessageType.Warning);
            }

            if (VersionControlSystemHasGUI())
            {
                GUI.enabled = true;
                bool hasRequiredFields = false;

                if (EditorSettings.externalVersionControl == ExternalVersionControl.Generic ||
                    EditorSettings.externalVersionControl == ExternalVersionControl.Disabled)
                {
                    // no specific UI for these VCS types
                }
                else
                {
                    ConfigField[] configFields = Provider.GetActiveConfigFields();

                    hasRequiredFields = true;

                    foreach (ConfigField field in configFields)
                    {
                        string newVal;
                        string oldVal = EditorUserSettings.GetConfigValue(field.name);
                        if (field.isPassword)
                        {
                            newVal = EditorGUILayout.PasswordField(field.label, oldVal);
                            if (newVal != oldVal)
                            {
                                EditorUserSettings.SetPrivateConfigValue(field.name, newVal);
                            }
                        }
                        else
                        {
                            newVal = EditorGUILayout.TextField(field.label, oldVal);
                            if (newVal != oldVal)
                            {
                                EditorUserSettings.SetConfigValue(field.name, newVal);
                            }
                        }

                        if (field.isRequired && string.IsNullOrEmpty(newVal))
                        {
                            hasRequiredFields = false;
                        }
                    }
                }

                // Log level popup
                string logLevel = EditorUserSettings.GetConfigValue("vcSharedLogLevel");
                int    idx      = System.Array.FindIndex(logLevelPopupList, (item) => item.ToLower() == logLevel);
                if (idx == -1)
                {
                    logLevel = "notice";
                    idx      = System.Array.FindIndex(logLevelPopupList, (item) => item.ToLower() == logLevel);
                    if (idx == -1)
                    {
                        idx = 0;
                    }
                    logLevel = logLevelPopupList[idx];
                    EditorUserSettings.SetConfigValue("vcSharedLogLevel", logLevel);
                }
                int newIdx = EditorGUILayout.Popup(Content.logLevel, idx, logLevelPopupList);
                if (newIdx != idx)
                {
                    EditorUserSettings.SetConfigValue("vcSharedLogLevel", logLevelPopupList[newIdx].ToLower());
                }

                GUI.enabled = editorEnabled;

                string osState = "Connected";
                if (Provider.onlineState == OnlineState.Updating)
                {
                    osState = "Connecting...";
                }
                else if (Provider.onlineState == OnlineState.Offline)
                {
                    osState = "Disconnected";
                }

                EditorGUILayout.LabelField(Content.status.text, osState);

                if (Provider.onlineState != OnlineState.Online && !string.IsNullOrEmpty(Provider.offlineReason))
                {
                    GUI.enabled = false;
                    GUILayout.TextArea(Provider.offlineReason);
                    GUI.enabled = editorEnabled;
                }

                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                GUI.enabled = hasRequiredFields && Provider.onlineState != OnlineState.Updating;
                if (GUILayout.Button("Connect", EditorStyles.miniButton))
                {
                    Provider.UpdateSettings();
                }
                GUILayout.EndHorizontal();

                EditorUserSettings.AutomaticAdd = EditorGUILayout.Toggle(Content.automaticAdd, EditorUserSettings.AutomaticAdd);

                if (Provider.requiresNetwork)
                {
                    bool workOfflineNew = EditorGUILayout.Toggle(Content.workOffline, EditorUserSettings.WorkOffline); // Enabled has a slightly different behaviour
                    if (workOfflineNew != EditorUserSettings.WorkOffline)
                    {
                        // On toggling on show a warning
                        if (workOfflineNew && !EditorUtility.DisplayDialog("Confirm working offline", "Working offline and making changes to your assets means that you will have to manually integrate changes back into version control using your standard version control client before you stop working offline in Unity. Make sure you know what you are doing.", "Work offline", "Cancel"))
                        {
                            workOfflineNew = false; // User cancelled working offline
                        }
                        EditorUserSettings.WorkOffline = workOfflineNew;
                        EditorApplication.RequestRepaintAllViews();
                    }

                    EditorUserSettings.allowAsyncStatusUpdate = EditorGUILayout.Toggle(Content.allowAsyncUpdate, EditorUserSettings.allowAsyncStatusUpdate);
                }

                if (Provider.hasCheckoutSupport)
                {
                    EditorUserSettings.showFailedCheckout = EditorGUILayout.Toggle(Content.showFailedCheckouts, EditorUserSettings.showFailedCheckout);
                }

                GUI.enabled = editorEnabled;

                // Semantic merge popup
                EditorUserSettings.semanticMergeMode = (SemanticMergeMode)EditorGUILayout.Popup(Content.smartMerge, (int)EditorUserSettings.semanticMergeMode, semanticMergePopupList);

                DrawOverlayDescriptions();
            }

            GUILayout.Space(10);

            int index = (int)EditorSettings.serializationMode;

            using (new EditorGUI.DisabledScope(!collabEnabled))
            {
                GUI.enabled = !collabEnabled;
                GUILayout.Label(Content.assetSerialization, EditorStyles.boldLabel);
                GUI.enabled = editorEnabled && !collabEnabled;


                CreatePopupMenu("Mode", serializationPopupList, index, SetAssetSerializationMode);
            }
            if (collabEnabled)
            {
                EditorGUILayout.HelpBox("Asset Serialization is forced to Text when using Collaboration feature.", MessageType.Warning);
            }

            GUILayout.Space(10);

            GUI.enabled = true;
            GUILayout.Label(Content.defaultBehaviorMode, EditorStyles.boldLabel);
            GUI.enabled = editorEnabled;

            index = Mathf.Clamp((int)EditorSettings.defaultBehaviorMode, 0, behaviorPopupList.Length - 1);
            CreatePopupMenu(Content.mode.text, behaviorPopupList, index, SetDefaultBehaviorMode);

            {
                var wasEnabled = GUI.enabled;
                GUI.enabled = true;

                DoAssetPipelineSettings();

                if (m_AssetPipelineMode.intValue == (int)AssetPipelineMode.Version2)
                {
                    DoCacheServerSettings();
                }

                GUI.enabled = wasEnabled;
            }
            GUILayout.Space(10);

            GUI.enabled = true;
            GUILayout.Label("Prefab Editing Environments", EditorStyles.boldLabel);
            GUI.enabled = editorEnabled;

            {
                EditorGUI.BeginChangeCheck();
                SceneAsset scene = EditorSettings.prefabRegularEnvironment;
                scene = (SceneAsset)EditorGUILayout.ObjectField("Regular Environment", scene, typeof(SceneAsset), false);
                if (EditorGUI.EndChangeCheck())
                {
                    EditorSettings.prefabRegularEnvironment = scene;
                }
            }
            {
                EditorGUI.BeginChangeCheck();
                SceneAsset scene = EditorSettings.prefabUIEnvironment;
                scene = (SceneAsset)EditorGUILayout.ObjectField("UI Environment", scene, typeof(SceneAsset), false);
                if (EditorGUI.EndChangeCheck())
                {
                    EditorSettings.prefabUIEnvironment = scene;
                }
            }

            GUILayout.Space(10);

            GUI.enabled = true;
            GUILayout.Label(Content.graphics, EditorStyles.boldLabel);
            GUI.enabled = editorEnabled;

            EditorGUI.BeginChangeCheck();
            bool showRes = LightmapVisualization.showResolution;

            showRes = EditorGUILayout.Toggle(Content.showLightmapResolutionOverlay, showRes);
            if (EditorGUI.EndChangeCheck())
            {
                LightmapVisualization.showResolution = showRes;
            }

            GUILayout.Space(10);

            GUI.enabled = true;
            GUILayout.Label(Content.spritePacker, EditorStyles.boldLabel);
            GUI.enabled = editorEnabled;

            index = Mathf.Clamp((int)EditorSettings.spritePackerMode, 0, spritePackerPopupList.Length - 1);
            CreatePopupMenu(Content.mode.text, spritePackerPopupList, index, SetSpritePackerMode);

            if (EditorSettings.spritePackerMode == SpritePackerMode.AlwaysOn ||
                EditorSettings.spritePackerMode == SpritePackerMode.BuildTimeOnly)
            {
                index = Mathf.Clamp((int)(EditorSettings.spritePackerPaddingPower - 1), 0, 2);
                CreatePopupMenu("Padding Power (Legacy Sprite Packer)", spritePackerPaddingPowerPopupList, index, SetSpritePackerPaddingPower);
            }

            DoProjectGenerationSettings();
            DoEtcTextureCompressionSettings();
            DoLineEndingsSettings();
            DoStreamingSettings();
            DoShaderCompilationSettings();

            serializedObject.ApplyModifiedProperties();
            m_EditorUserSettings.ApplyModifiedProperties();
        }
Beispiel #4
0
        private void ActionBox()
        {
            bool enabled = GUI.enabled;

            switch (this.currAction)
            {
            case Action.Main:
                if (!this.isConnected)
                {
                    GUI.enabled = false;
                }
                if (this.WordWrappedLabelButton("Want to create a new project?", "Create"))
                {
                    this.nProjectName         = string.Empty;
                    this.nTemplateProjectName = string.Empty;
                    this.currAction           = Action.CreateProject;
                }
                if (this.WordWrappedLabelButton("Want to create a new user?", "New User"))
                {
                    this.nPassword1 = this.nPassword2 = string.Empty;
                    this.nFullName  = this.nUserName = this.nEmail = string.Empty;
                    this.currAction = Action.CreateUser;
                }
                GUI.enabled = (this.isConnected && this.userSelected) && enabled;
                if (this.WordWrappedLabelButton("Need to change user password?", "Set Password"))
                {
                    this.nPassword1 = this.nPassword2 = string.Empty;
                    this.currAction = Action.SetPassword;
                }
                if (this.WordWrappedLabelButton("Need to change user information?", "Edit"))
                {
                    this.nFullName  = this.users[this.lv2.row].fullName;
                    this.nEmail     = this.users[this.lv2.row].email;
                    this.currAction = Action.ModifyUser;
                }
                GUI.enabled = (this.isConnected && this.projectSelected) && enabled;
                if (this.WordWrappedLabelButton("Duplicate selected project", "Copy Project"))
                {
                    this.nProjectName         = string.Empty;
                    this.nTemplateProjectName = this.databases[this.lv.row].name;
                    this.currAction           = Action.CreateProject;
                }
                if ((this.WordWrappedLabelButton("Delete selected project", "Delete Project") && EditorUtility.DisplayDialog("Delete project", "Are you sure you want to delete project " + this.databases[this.lv.row].name + "? This operation cannot be undone!", "Delete", "Cancel")) && (AssetServer.AdminDeleteDB(this.databases[this.lv.row].name) != 0))
                {
                    this.DoRefreshDatabases();
                    GUIUtility.ExitGUI();
                }
                GUI.enabled = (this.isConnected && this.userSelected) && enabled;
                if ((this.WordWrappedLabelButton("Delete selected user", "Delete User") && EditorUtility.DisplayDialog("Delete user", "Are you sure you want to delete user " + this.users[this.lv2.row].userName + "? This operation cannot be undone!", "Delete", "Cancel")) && (AssetServer.AdminDeleteUser(this.users[this.lv2.row].userName) != 0))
                {
                    if (this.lv.row > -1)
                    {
                        this.DoGetUsers();
                    }
                    GUIUtility.ExitGUI();
                }
                GUI.enabled = enabled;
                break;

            case Action.CreateUser:
                this.nFullName = EditorGUILayout.TextField("Full Name:", this.nFullName, new GUILayoutOption[0]);
                this.nEmail    = EditorGUILayout.TextField("Email Address:", this.nEmail, new GUILayoutOption[0]);
                GUILayout.Space(5f);
                this.nUserName = EditorGUILayout.TextField("User Name:", this.nUserName, new GUILayoutOption[0]);
                GUILayout.Space(5f);
                this.nPassword1 = EditorGUILayout.PasswordField("Password:"******"Repeat Password:"******"Create User", constants.smallButton, new GUILayoutOption[0]))
                {
                    this.PerformCurrentAction();
                }
                GUI.enabled = enabled;
                if (GUILayout.Button("Cancel", constants.smallButton, new GUILayoutOption[0]))
                {
                    this.currAction = Action.Main;
                }
                GUILayout.EndHorizontal();
                break;

            case Action.SetPassword:
                GUILayout.Label("Setting password for user: "******"Password:"******"Repeat Password:"******"Change Password", constants.smallButton, new GUILayoutOption[0]))
                {
                    this.PerformCurrentAction();
                }
                GUI.enabled = enabled;
                if (GUILayout.Button("Cancel", constants.smallButton, new GUILayoutOption[0]))
                {
                    this.currAction = Action.Main;
                }
                GUILayout.EndHorizontal();
                break;

            case Action.CreateProject:
                this.nProjectName = EditorGUILayout.TextField("Project Name:", this.nProjectName, new GUILayoutOption[0]);
                GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                GUILayout.FlexibleSpace();
                GUI.enabled = this.CanPerformCurrentAction() && enabled;
                if (GUILayout.Button(!(this.nTemplateProjectName == string.Empty) ? ("Copy " + this.nTemplateProjectName) : "Create Project", constants.smallButton, new GUILayoutOption[0]))
                {
                    this.PerformCurrentAction();
                }
                GUI.enabled = enabled;
                if (GUILayout.Button("Cancel", constants.smallButton, new GUILayoutOption[0]))
                {
                    this.currAction = Action.Main;
                }
                GUILayout.EndHorizontal();
                break;

            case Action.ModifyUser:
                this.nFullName = EditorGUILayout.TextField("Full Name:", this.nFullName, new GUILayoutOption[0]);
                this.nEmail    = EditorGUILayout.TextField("Email Address:", this.nEmail, new GUILayoutOption[0]);
                GUILayout.Space(5f);
                GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                GUILayout.FlexibleSpace();
                GUI.enabled = this.CanPerformCurrentAction() && enabled;
                if (GUILayout.Button("Change", constants.smallButton, new GUILayoutOption[0]))
                {
                    this.PerformCurrentAction();
                }
                GUI.enabled = enabled;
                if (GUILayout.Button("Cancel", constants.smallButton, new GUILayoutOption[0]))
                {
                    this.currAction = Action.Main;
                }
                GUILayout.EndHorizontal();
                break;
            }
        }
Beispiel #5
0
        public bool DoGUI()
        {
            bool enabled = GUI.enabled;

            if (constants == null)
            {
                constants            = new ASMainWindow.Constants();
                constants.toggleSize = constants.toggle.CalcSize(new GUIContent("X"));
            }
            if (this.resetKeyboardControl)
            {
                this.resetKeyboardControl  = false;
                GUIUtility.keyboardControl = 0;
            }
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.BeginVertical(constants.groupBox, new GUILayoutOption[0]);
            GUILayout.Box("Server Connection", constants.title, new GUILayoutOption[0]);
            GUILayout.BeginVertical(constants.contentBox, new GUILayoutOption[0]);
            Event current = Event.current;

            if (((current.type == EventType.KeyDown) && (current.keyCode == KeyCode.Return)) && this.CanPerformCurrentAction())
            {
                this.PerformCurrentAction();
            }
            if (((current.type == EventType.KeyDown) && (current.keyCode == KeyCode.Escape)) && (this.currAction != Action.Main))
            {
                this.currAction = Action.Main;
                current.Use();
            }
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            this.server = EditorGUILayout.TextField("Server Address:", this.server, new GUILayoutOption[0]);
            this.ServersPopup();
            GUILayout.EndHorizontal();
            this.user     = EditorGUILayout.TextField("User Name:", this.user, new GUILayoutOption[0]);
            this.password = EditorGUILayout.PasswordField("Password:"******"Connect", constants.smallButton, new GUILayoutOption[0]))
            {
                this.PerformCurrentAction();
            }
            GUI.enabled = enabled;
            GUILayout.EndHorizontal();
            if (AssetServer.GetAssetServerError() != string.Empty)
            {
                GUILayout.Label(AssetServer.GetAssetServerError(), constants.errorLabel, new GUILayoutOption[0]);
            }
            GUILayout.EndVertical();
            GUILayout.EndVertical();
            GUILayout.BeginVertical(constants.groupBox, new GUILayoutOption[0]);
            GUILayout.Box("Admin Actions", constants.title, new GUILayoutOption[0]);
            GUILayout.BeginVertical(constants.contentBox, new GUILayoutOption[0]);
            this.ActionBox();
            GUILayout.EndVertical();
            GUILayout.EndVertical();
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.BeginVertical(constants.groupBox, new GUILayoutOption[0]);
            GUILayout.Box("Project", constants.title, new GUILayoutOption[0]);
            IEnumerator enumerator = ListViewGUILayout.ListView(this.lv, constants.background, new GUILayoutOption[0]).GetEnumerator();

            try
            {
                while (enumerator.MoveNext())
                {
                    ListViewElement element = (ListViewElement)enumerator.Current;
                    if ((element.row == this.lv.row) && (Event.current.type == EventType.Repaint))
                    {
                        constants.entrySelected.Draw(element.position, false, false, false, false);
                    }
                    GUILayout.Label(this.databases[element.row].name, new GUILayoutOption[0]);
                }
            }
            finally
            {
                IDisposable disposable = enumerator as IDisposable;
                if (disposable == null)
                {
                }
                disposable.Dispose();
            }
            if (this.lv.selectionChanged)
            {
                if (this.lv.row > -1)
                {
                    this.projectSelected = true;
                }
                this.currAction = Action.Main;
                this.DoGetUsers();
            }
            GUILayout.EndVertical();
            GUILayout.BeginVertical(constants.groupBox, new GUILayoutOption[0]);
            SplitterGUILayout.BeginHorizontalSplit(this.lvSplit, new GUILayoutOption[0]);
            GUILayout.Box(string.Empty, constants.columnHeader, new GUILayoutOption[0]);
            GUILayout.Box("User", constants.columnHeader, new GUILayoutOption[0]);
            GUILayout.Box("Full Name", constants.columnHeader, new GUILayoutOption[0]);
            GUILayout.Box("Email", constants.columnHeader, new GUILayoutOption[0]);
            SplitterGUILayout.EndHorizontalSplit();
            int         left        = EditorStyles.label.margin.left;
            IEnumerator enumerator2 = ListViewGUILayout.ListView(this.lv2, constants.background, new GUILayoutOption[0]).GetEnumerator();

            try
            {
                while (enumerator2.MoveNext())
                {
                    ListViewElement element2 = (ListViewElement)enumerator2.Current;
                    if ((element2.row == this.lv2.row) && (Event.current.type == EventType.Repaint))
                    {
                        constants.entrySelected.Draw(element2.position, false, false, false, false);
                    }
                    bool flag2 = this.users[element2.row].enabled != 0;
                    bool flag3 = GUI.Toggle(new Rect(element2.position.x + 2f, element2.position.y - 1f, constants.toggleSize.x, constants.toggleSize.y), flag2, string.Empty);
                    GUILayout.Space(constants.toggleSize.x);
                    if ((flag2 != flag3) && AssetServer.AdminSetUserEnabled(this.databases[this.lv.row].dbName, this.users[element2.row].userName, this.users[element2.row].fullName, this.users[element2.row].email, !flag3 ? 0 : 1))
                    {
                        this.users[element2.row].enabled = !flag3 ? 0 : 1;
                    }
                    GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.Width((float)(this.lvSplit.realSizes[1] - left)) };
                    GUILayout.Label(this.users[element2.row].userName, options);
                    GUILayoutOption[] optionArray2 = new GUILayoutOption[] { GUILayout.Width((float)(this.lvSplit.realSizes[2] - left)) };
                    GUILayout.Label(this.users[element2.row].fullName, optionArray2);
                    GUILayout.Label(this.users[element2.row].email, new GUILayoutOption[0]);
                }
            }
            finally
            {
                IDisposable disposable2 = enumerator2 as IDisposable;
                if (disposable2 == null)
                {
                }
                disposable2.Dispose();
            }
            if (this.lv2.selectionChanged)
            {
                if (this.lv2.row > -1)
                {
                    this.userSelected = true;
                }
                if (this.currAction == Action.SetPassword)
                {
                    this.currAction = Action.Main;
                }
            }
            GUILayout.EndVertical();
            GUILayout.EndHorizontal();
            GUILayout.Space(10f);
            if (!this.splittersOk && (Event.current.type == EventType.Repaint))
            {
                this.splittersOk = true;
                this.parentWin.Repaint();
            }
            return(true);
        }
Beispiel #6
0
        void PasswordGUI()
        {
            AssetStoreAsset.PreviewInfo item = m_Asset.previewInfo;
            GUILayout.BeginHorizontal();
            GUILayout.Space(5);
            GUILayout.Label(s_AssetStoreLogo, GUIStyle.none, GUILayout.ExpandWidth(false));
            GUILayout.BeginVertical();
            GUILayout.Label("Complete purchase by entering your AssetStore password", EditorStyles.boldLabel);
            bool  hasMessage      = !string.IsNullOrEmpty(m_PurchaseMessage);
            bool  hasErrorMessage = !string.IsNullOrEmpty(m_Message);
            float newHeight       = kStandardHeight + (hasMessage ? 20 : 0) + (hasErrorMessage ? 20 : 0);

            if (newHeight != position.height)
            {
                position = new Rect(position.x, position.y, position.width, newHeight);
            }

            if (hasMessage)
            {
                GUILayout.Label(m_PurchaseMessage, EditorStyles.wordWrappedLabel);
            }
            if (hasErrorMessage)
            {
                Color oldColor = GUI.color;
                GUI.color = Color.red;
                GUILayout.Label(m_Message, EditorStyles.wordWrappedLabel);
                GUI.color = oldColor;
            }
            GUILayout.Label("Package: " + item.packageName, EditorStyles.wordWrappedLabel);
            string cardInfo = string.Format("Credit card: {0} (expires {1})", m_PaymentMethodCard, m_PaymentMethodExpire);

            GUILayout.Label(cardInfo, EditorStyles.wordWrappedLabel);
            GUILayout.Space(8);
            EditorGUILayout.LabelField("Amount", m_PriceText);
            m_Password = EditorGUILayout.PasswordField("Password", m_Password);
            GUILayout.EndVertical();
            GUILayout.Space(5);
            GUILayout.EndHorizontal();

            GUILayout.FlexibleSpace();

            GUILayout.BeginHorizontal();
            GUILayout.Space(8);
            if (GUILayout.Button("Just put to basket..."))
            {
                AssetStore.Open(string.Format("content/{0}/basketpurchase", m_Asset.packageID));
                m_Asset = null;
                this.Close();
                GUIUtility.ExitGUI();
            }
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Cancel"))
            {
                m_Asset = null;
                this.Close();
                GUIUtility.ExitGUI();
            }
            GUILayout.Space(5);
            if (GUILayout.Button("Complete purchase"))
            {
                CompletePurchase();
            }

            GUILayout.Space(5);
            GUILayout.EndHorizontal();

            GUILayout.Space(5);
        }
        private void DoCacheServerSettings()
        {
            GUILayout.Space(10);
            GUILayout.Label(Content.cacheServer, EditorStyles.boldLabel);

            var overrideAddress = CacheServerPreferences.GetCommandLineRemoteAddressOverride();

            if (overrideAddress != null)
            {
                EditorGUILayout.HelpBox("Cache Server remote address forced via command line argument. To use the cache server address specified here please restart Unity without the -CacheServerIPAddress command line argument.", MessageType.Info, true);
            }

            int index = Mathf.Clamp((int)EditorSettings.cacheServerMode, 0, cacheServerModePopupList.Length - 1);

            CreatePopupMenu(Content.mode.text, cacheServerModePopupList, index, SetCacheServerMode);

            if (index != (int)CacheServerMode.Disabled)
            {
                bool isCacheServerEnabled = true;

                if (index == (int)CacheServerMode.AsPreferences)
                {
                    if (CacheServerPreferences.IsCacheServerV2Enabled)
                    {
                        var cacheServerIP = CacheServerPreferences.CachesServerV2Address;
                        cacheServerIP = string.IsNullOrEmpty(cacheServerIP) ? "Not set in preferences" : cacheServerIP;
                        EditorGUILayout.HelpBox(cacheServerIP, MessageType.None, false);
                    }
                    else
                    {
                        isCacheServerEnabled = false;
                        EditorGUILayout.HelpBox("Disabled", MessageType.None, false);
                    }
                }

                if (isCacheServerEnabled)
                {
                    var oldEndpoint = EditorSettings.cacheServerEndpoint;
                    var newEndpoint = EditorGUILayout.TextField(Content.cacheServerIPLabel, oldEndpoint);
                    if (newEndpoint != oldEndpoint)
                    {
                        EditorSettings.cacheServerEndpoint = newEndpoint;
                    }

                    EditorGUILayout.BeginHorizontal();

                    if (GUILayout.Button("Check Connection", GUILayout.Width(150)))
                    {
                        if (AssetDatabase.IsV2Enabled())
                        {
                            var    address = EditorSettings.cacheServerEndpoint.Split(':');
                            var    ip      = address[0];
                            UInt16 port    = 0; // If 0, will use the default set port
                            if (address.Length == 2)
                            {
                                port = Convert.ToUInt16(address[1]);
                            }

                            if (AssetDatabaseExperimental.CanConnectToCacheServer(ip, port))
                            {
                                m_CacheServerConnectionState = CacheServerConnectionState.Success;
                            }
                            else
                            {
                                m_CacheServerConnectionState = CacheServerConnectionState.Failure;
                            }
                        }
                        else
                        {
                            if (InternalEditorUtility.CanConnectToCacheServer())
                            {
                                m_CacheServerConnectionState = CacheServerConnectionState.Success;
                            }
                            else
                            {
                                m_CacheServerConnectionState = CacheServerConnectionState.Failure;
                            }
                        }
                    }

                    GUILayout.Space(25);

                    switch (m_CacheServerConnectionState)
                    {
                    case CacheServerConnectionState.Success:
                        EditorGUILayout.HelpBox("Connection successful.", MessageType.Info, true);
                        break;

                    case CacheServerConnectionState.Failure:
                        EditorGUILayout.HelpBox("Connection failed.", MessageType.Warning, true);
                        break;

                    case CacheServerConnectionState.Unknown:
                        GUILayout.Space(44);
                        break;
                    }

                    EditorGUILayout.EndHorizontal();

                    var old      = EditorSettings.cacheServerNamespacePrefix;
                    var newvalue = EditorGUILayout.TextField(Content.cacheServerNamespacePrefixLabel, old);
                    if (newvalue != old)
                    {
                        EditorSettings.cacheServerNamespacePrefix = newvalue;
                    }

                    EditorGUI.BeginChangeCheck();
                    bool enableDownload = EditorSettings.cacheServerEnableDownload;
                    enableDownload = EditorGUILayout.Toggle(Content.cacheServerEnableDownloadLabel, enableDownload);
                    if (EditorGUI.EndChangeCheck())
                    {
                        EditorSettings.cacheServerEnableDownload = enableDownload;
                    }

                    EditorGUI.BeginChangeCheck();
                    bool enableUpload = EditorSettings.cacheServerEnableUpload;
                    enableUpload = EditorGUILayout.Toggle(Content.cacheServerEnableUploadLabel, enableUpload);
                    if (EditorGUI.EndChangeCheck())
                    {
                        EditorSettings.cacheServerEnableUpload = enableUpload;
                    }

                    bool enableAuth = EditorSettings.cacheServerEnableAuth;
                    using (new EditorGUI.DisabledScope(enableAuth))
                    {
                        EditorGUI.BeginChangeCheck();
                        bool enableTls = EditorSettings.cacheServerEnableTls;
                        enableTls = EditorGUILayout.Toggle(Content.cacheServerEnableTlsLabel, enableTls);
                        if (EditorGUI.EndChangeCheck())
                        {
                            EditorSettings.cacheServerEnableTls = enableTls;
                        }
                    }

                    EditorGUI.BeginChangeCheck();
                    enableAuth = EditorGUILayout.Toggle(Content.cacheServerEnableAuthLabel, enableAuth);
                    if (EditorGUI.EndChangeCheck())
                    {
                        EditorSettings.cacheServerEnableAuth = enableAuth;
                        if (enableAuth)
                        {
                            EditorSettings.cacheServerEnableTls = true;
                        }
                    }

                    EditorGUI.indentLevel++;
                    using (new EditorGUI.DisabledScope(!enableAuth))
                    {
                        int authModeIndex = Convert.ToInt32(EditorUserSettings.GetConfigValue("cacheServerAuthMode"));
                        CreatePopupMenu(Content.mode.text, cacheServerAuthMode, authModeIndex, SetCacheServerAuthMode);

                        string oldUserVal = EditorUserSettings.GetConfigValue("cacheServerAuthUser");
                        var    newUserVal = EditorGUILayout.TextField(Content.cacheServerAuthUserLabel, oldUserVal);
                        if (newUserVal != oldUserVal)
                        {
                            EditorUserSettings.SetConfigValue("cacheServerAuthUser", newUserVal);
                        }

                        var oldPasswordVal = EditorUserSettings.GetConfigValue("cacheServerAuthPassword");
                        var newPasswordVal = EditorGUILayout.PasswordField(Content.cacheServerAuthPasswordLabel, oldPasswordVal);
                        if (newPasswordVal != oldPasswordVal)
                        {
                            EditorUserSettings.SetPrivateConfigValue("cacheServerAuthPassword", newPasswordVal);
                        }
                    }
                    EditorGUI.indentLevel--;
                }
            }
        }