コード例 #1
0
        public void OnGUI()
        {
            if (AssetStoreLoginWindow.styles == null)
            {
                AssetStoreLoginWindow.styles = new AssetStoreLoginWindow.Styles();
            }
            AssetStoreLoginWindow.LoadLogos();
            if (AssetStoreClient.LoginInProgress() || AssetStoreClient.LoggedIn())
            {
                GUI.enabled = false;
            }
            GUILayout.BeginVertical();
            GUILayout.Space(10f);
            GUILayout.BeginHorizontal();
            GUILayout.Space(5f);
            GUILayout.Label(AssetStoreLoginWindow.s_AssetStoreLogo, GUIStyle.none, new GUILayoutOption[1]
            {
                GUILayout.ExpandWidth(false)
            });
            GUILayout.BeginVertical();
            GUILayout.BeginHorizontal();
            GUILayout.Space(6f);
            GUILayout.Label(this.m_LoginReason, EditorStyles.wordWrappedLabel, new GUILayoutOption[0]);
            Rect lastRect = GUILayoutUtility.GetLastRect();

            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.Space(6f);
            Rect rect = new Rect(0.0f, 0.0f, 0.0f, 0.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;
                rect      = GUILayoutUtility.GetLastRect();
            }
            float height = (float)((double)lastRect.height + (double)rect.height + 110.0);

            if (Event.current.type == EventType.Repaint && (double)height != (double)this.position.height)
            {
                this.position = new Rect(this.position.x, this.position.y, this.position.width, height);
                this.Repaint();
            }
            GUILayout.EndHorizontal();
            GUILayout.FlexibleSpace();
            GUILayout.BeginHorizontal();
            GUI.SetNextControlName("username");
            this.m_Username = EditorGUILayout.TextField("Username", this.m_Username, new GUILayoutOption[0]);
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            this.m_Password = EditorGUILayout.PasswordField("Password", this.m_Password, new GUILayoutOption[1]
            {
                GUILayout.ExpandWidth(true)
            });
            if (GUILayout.Button(new GUIContent("Forgot?", "Reset your password"), AssetStoreLoginWindow.styles.link, new GUILayoutOption[1]
            {
                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();
            if (GUILayout.Button("Create account"))
            {
                AssetStore.Open("createuser/");
                this.m_LoginRemoteMessage = "Cancelled - create user";
                this.Close();
            }
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Cancel"))
            {
                this.m_LoginRemoteMessage = "Cancelled";
                this.Close();
            }
            GUILayout.Space(5f);
            if (GUILayout.Button("Login"))
            {
                this.DoLogin();
                this.Repaint();
            }
            GUILayout.Space(5f);
            GUILayout.EndHorizontal();
            GUILayout.Space(5f);
            GUILayout.EndVertical();
            if (Event.current.Equals((object)Event.KeyboardEvent("return")))
            {
                this.DoLogin();
                this.Repaint();
            }
            if (!(this.m_Username == string.Empty))
            {
                return;
            }
            EditorGUI.FocusTextInControl("username");
        }
コード例 #2
0
        public void OnGUI()
        {
            if (styles == null)
            {
                styles = new Styles();
            }

            LoadLogos();

            if (AssetStoreClient.LoginInProgress() || AssetStoreClient.LoggedIn())
            {
                GUI.enabled = false;
            }

            GUILayout.BeginVertical();
            GUILayout.Space(10);
            GUILayout.BeginHorizontal();
            GUILayout.Space(5);
            GUILayout.Label(s_AssetStoreLogo, GUIStyle.none, GUILayout.ExpandWidth(false));
            GUILayout.BeginVertical();
            GUILayout.BeginHorizontal();
            GUILayout.Space(6);
            GUILayout.Label(m_LoginReason, EditorStyles.wordWrappedLabel);
            Rect lastReasonRect = GUILayoutUtility.GetLastRect();

            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.Space(6);
            Rect lastMessageRect = new Rect(0f, 0f, 0f, 0f);

            if (m_LoginRemoteMessage != null)
            {
                Color oldColor = GUI.color;
                GUI.color = Color.red;
                GUILayout.Label(m_LoginRemoteMessage, EditorStyles.wordWrappedLabel);
                GUI.color       = oldColor;
                lastMessageRect = GUILayoutUtility.GetLastRect();
            }
            float newHeight = lastReasonRect.height + lastMessageRect.height + kBaseHeight;

            if (Event.current.type == EventType.Repaint && newHeight != position.height)
            {
                // Debug.Log(newHeight.ToString() + " " + position.height + " " + lastReasonRect.height.ToString() + " " + lastMessageRect.height.ToString());
                position = new Rect(position.x, position.y, position.width, newHeight);
                Repaint();
            }
            GUILayout.EndHorizontal();

            GUILayout.FlexibleSpace();
            GUILayout.BeginHorizontal();
            GUI.SetNextControlName("username");
            m_Username = EditorGUILayout.TextField("Username", m_Username);
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            m_Password = EditorGUILayout.PasswordField("Password", m_Password, GUILayout.ExpandWidth(true));
            if (GUILayout.Button(EditorGUIUtility.TrTextContent("Forgot?", "Reset your password"), styles.link, GUILayout.ExpandWidth(false)))
            {
                Application.OpenURL("https://accounts.unity3d.com/password/new");
            }

            EditorGUIUtility.AddCursorRect(GUILayoutUtility.GetLastRect(), MouseCursor.Link);
            GUILayout.EndHorizontal();

            bool oldRememberMe = AssetStoreClient.RememberSession;
            bool newRememberMe = EditorGUILayout.Toggle("Remember me", oldRememberMe);

            if (newRememberMe != oldRememberMe)
            {
                AssetStoreClient.RememberSession = newRememberMe;
            }

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

            GUILayout.Space(8);

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Create account"))
            {
                AssetStore.Open("createuser/");
                m_LoginRemoteMessage = "Cancelled - create user";
                Close();
            }
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Cancel"))
            {
                m_LoginRemoteMessage = "Cancelled";
                Close();
            }
            GUILayout.Space(5);
            if (GUILayout.Button("Login"))
            {
                DoLogin();
                Repaint();
            }
            GUILayout.Space(5);
            GUILayout.EndHorizontal();

            GUILayout.Space(5);

            GUILayout.EndVertical();

            if (Event.current.Equals(Event.KeyboardEvent("return")))
            {
                DoLogin();
                Repaint();
            }

            if (m_Username == "")
            {
                EditorGUI.FocusTextInControl("username");
            }
        }