Beispiel #1
0
        public static void ShowAndroidKeystoreWindow(string company, string keystore, string storepass)
        {
            if (File.Exists(keystore))
            {
                try
                {
                    AndroidSDKTools.GetInstanceOrThrowException().ReadAvailableKeys(keystore, storepass);
                }
                catch (Exception exception)
                {
                    Debug.LogError(exception.ToString());
                    return;
                }
            }
            Rect rect = new Rect(100f, 100f, 500f, 330f);
            AndroidKeystoreWindow window = (AndroidKeystoreWindow)EditorWindow.GetWindowWithRect(typeof(AndroidKeystoreWindow), rect, true, EditorGUIUtility.TextContent("Create a new key").text);

            window.position = rect;
            window.m_Parent.window.m_DontSaveToLayout = true;
            window.m_Organization = company;
            window.m_Keystore     = keystore;
            window.m_StorePass    = storepass;
        }
        public override void PublishSectionGUI(float h, float kLabelFloatMinW, float kLabelFloatMaxW)
        {
            Rect   rect2;
            string keystorePass = PlayerSettings.keystorePass;
            string keyaliasPass = PlayerSettings.keyaliasPass;
            bool   flag         = false;

            GUILayout.Label(EditorGUIUtility.TextContent("Keystore"), EditorStyles.boldLabel, new GUILayoutOption[0]);
            Rect position = GUILayoutUtility.GetRect(kLabelFloatMinW, kLabelFloatMaxW, h + 5f, h + 5f, EditorStyles.layerMaskField, null);

            GUIContent[] contents = new GUIContent[] { EditorGUIUtility.TextContent("Use Existing Keystore"), EditorGUIUtility.TextContent("Create New Keystore") };
            bool         flag2    = GUI.SelectionGrid(position, !this.m_KeystoreCreate ? 0 : 1, contents, 2, "toggle") == 1;

            if (flag2 != this.m_KeystoreCreate)
            {
                this.m_KeystoreCreate = flag2;
                this.m_AndroidKeystoreName.stringValue = "";
                this.m_AndroidKeyaliasName.stringValue = "";
                this.m_KeystoreAvailableKeys           = null;
            }
            position = GUILayoutUtility.GetRect(kLabelFloatMinW, kLabelFloatMaxW, h, h, EditorStyles.layerMaskField, null);
            GUIContent content  = null;
            bool       disabled = this.m_AndroidKeystoreName.stringValue.Length == 0;

            using (new EditorGUI.DisabledScope(disabled))
            {
                if (disabled)
                {
                    content = EditorGUIUtility.TextContent("Browse to select keystore name");
                }
                else
                {
                    content = EditorGUIUtility.TempContent(this.m_AndroidKeystoreName.stringValue);
                }
                float labelWidth = EditorGUIUtility.labelWidth;
                rect2 = new Rect(position.x + EditorGUI.indent, position.y, labelWidth - EditorGUI.indent, position.height);
                Rect rect3 = new Rect(position.x + labelWidth, position.y, position.width - labelWidth, position.height);
                EditorGUI.TextArea(rect3, content.text, EditorStyles.label);
            }
            if (GUI.Button(rect2, EditorGUIUtility.TextContent("Browse Keystore")))
            {
                this.m_KeystoreAvailableKeys = null;
                string currentDirectory = Directory.GetCurrentDirectory();
                if (this.m_KeystoreCreate)
                {
                    this.m_AndroidKeystoreName.stringValue = EditorUtility.SaveFilePanel(EditorGUIUtility.TextContent("Create a new keystore...").text, currentDirectory, "user.keystore", "keystore");
                }
                else
                {
                    this.m_AndroidKeystoreName.stringValue = EditorUtility.OpenFilePanel(EditorGUIUtility.TextContent("Open existing keystore...").text, currentDirectory, "keystore");
                }
                if (this.m_KeystoreCreate && File.Exists(this.m_AndroidKeystoreName.stringValue))
                {
                    FileUtil.DeleteFileOrDirectory(this.m_AndroidKeystoreName.stringValue);
                }
                currentDirectory = currentDirectory + Path.DirectorySeparatorChar;
                if (this.m_AndroidKeystoreName.stringValue.StartsWith(currentDirectory))
                {
                    this.m_AndroidKeystoreName.stringValue = this.m_AndroidKeystoreName.stringValue.Substring(currentDirectory.Length);
                }
                this.m_SettingsEditor.serializedObject.ApplyModifiedProperties();
                GUIUtility.ExitGUI();
            }
            EditorGUI.BeginChangeCheck();
            keystorePass = EditorGUI.PasswordField(GUILayoutUtility.GetRect(kLabelFloatMinW, kLabelFloatMaxW, h, h, EditorStyles.layerMaskField, null), EditorGUIUtility.TextContent("Keystore password"), keystorePass);
            if (EditorGUI.EndChangeCheck())
            {
                AndroidKeystoreWindow.GetAvailableKeys("", "");
                this.m_KeystoreAvailableKeys = null;
            }
            using (new EditorGUI.DisabledScope(!this.m_KeystoreCreate))
            {
                position = GUILayoutUtility.GetRect(kLabelFloatMinW, kLabelFloatMaxW, h, h, EditorStyles.layerMaskField, null);
                this.m_KeystoreConfirm = EditorGUI.PasswordField(position, EditorGUIUtility.TextContent("Confirm password"), this.m_KeystoreConfirm);
            }
            GUIContent content2 = null;

            flag = false;
            if (keystorePass.Length == 0)
            {
                content2 = EditorGUIUtility.TextContent("Enter password.");
            }
            else if (keystorePass.Length < 6)
            {
                content2 = EditorGUIUtility.TextContent("Password must be at least 6 characters.");
            }
            else if (this.m_KeystoreCreate && (this.m_KeystoreConfirm.Length == 0))
            {
                content2 = EditorGUIUtility.TextContent("Confirm keystore password.");
            }
            else if (this.m_KeystoreCreate && !keystorePass.Equals(this.m_KeystoreConfirm))
            {
                content2 = EditorGUIUtility.TextContent("Passwords do not match.");
            }
            else
            {
                content2 = EditorGUIUtility.TempContent(" ");
                flag     = true;
            }
            GUILayout.Label(content2, EditorStyles.miniLabel, new GUILayoutOption[0]);
            EditorGUILayout.Space();
            GUILayout.Label(EditorGUIUtility.TextContent("Key"), EditorStyles.boldLabel, new GUILayoutOption[0]);
            string[] array = new string[] { EditorGUIUtility.TextContent("Unsigned (debug)").text };
            position = GUILayoutUtility.GetRect(kLabelFloatMinW, kLabelFloatMaxW, h, h, EditorStyles.layerMaskField, null);
            if (flag && !this.m_KeystoreCreate)
            {
                float num2  = EditorGUIUtility.labelWidth;
                Rect  rect4 = new Rect(position.x + num2, position.y, position.width - num2, position.height);
                if (((Event.current.type == EventType.MouseDown) && (Event.current.button == 0)) && rect4.Contains(Event.current.mousePosition))
                {
                    string keystore = !Path.IsPathRooted(this.m_AndroidKeystoreName.stringValue) ? Path.Combine(Directory.GetCurrentDirectory(), this.m_AndroidKeystoreName.stringValue) : this.m_AndroidKeystoreName.stringValue;
                    this.m_KeystoreAvailableKeys = AndroidKeystoreWindow.GetAvailableKeys(keystore, keystorePass);
                }
            }
            else
            {
                AndroidKeystoreWindow.GetAvailableKeys("", "");
                this.m_KeystoreAvailableKeys = null;
            }
            int selectedIndex = 0;

            if ((this.m_KeystoreAvailableKeys != null) && (this.m_KeystoreAvailableKeys.Length != 0))
            {
                ArrayUtility.AddRange <string>(ref array, this.m_KeystoreAvailableKeys);
            }
            else if (this.m_AndroidKeyaliasName.stringValue.Length != 0)
            {
                ArrayUtility.Add <string>(ref array, this.m_AndroidKeyaliasName.stringValue);
            }
            for (int i = 0; i < array.Length; i++)
            {
                if (array[i].Equals(this.m_AndroidKeyaliasName.stringValue))
                {
                    selectedIndex = i;
                }
            }
            bool flag4 = flag && ((this.m_KeystoreCreate && (this.m_AndroidKeystoreName.stringValue.Length != 0)) || (this.m_KeystoreAvailableKeys != null));

            if (flag4)
            {
                ArrayUtility.Add <string>(ref array, "");
                ArrayUtility.Add <string>(ref array, EditorGUIUtility.TextContent("Create a new key").text);
            }
            int num5 = EditorGUI.Popup(position, EditorGUIUtility.TextContent("Alias"), selectedIndex, EditorGUIUtility.TempContent(array), EditorStyles.popup);

            if (flag4 && (num5 == (array.Length - 1)))
            {
                num5 = selectedIndex;
                this.m_KeystoreCreate = false;
                string str5 = !Path.IsPathRooted(this.m_AndroidKeystoreName.stringValue) ? Path.Combine(Directory.GetCurrentDirectory(), this.m_AndroidKeystoreName.stringValue) : this.m_AndroidKeystoreName.stringValue;
                AndroidKeystoreWindow.ShowAndroidKeystoreWindow(PlayerSettings.companyName, str5, PlayerSettings.keystorePass);
                GUIUtility.ExitGUI();
            }
            if (num5 != selectedIndex)
            {
                selectedIndex = num5;
                this.m_AndroidKeyaliasName.stringValue = (selectedIndex != 0) ? array[selectedIndex] : "";
            }
            using (new EditorGUI.DisabledScope(selectedIndex == 0))
            {
                keyaliasPass = EditorGUI.PasswordField(GUILayoutUtility.GetRect(kLabelFloatMinW, kLabelFloatMaxW, h, h, EditorStyles.layerMaskField, null), EditorGUIUtility.TextContent("Password"), keyaliasPass);
            }
            GUIContent content3 = null;

            if (selectedIndex == 0)
            {
                content3 = EditorGUIUtility.TempContent(" ");
            }
            else if (keyaliasPass.Length == 0)
            {
                content3 = EditorGUIUtility.TextContent("Enter password.");
            }
            else if (keyaliasPass.Length < 6)
            {
                content3 = EditorGUIUtility.TextContent("Password must be at least 6 characters.");
            }
            else
            {
                content3 = EditorGUIUtility.TempContent(" ");
            }
            GUILayout.Label(content3, EditorStyles.miniLabel, new GUILayoutOption[0]);
            PlayerSettings.keystorePass = keystorePass;
            PlayerSettings.keyaliasPass = keyaliasPass;
            EditorGUILayout.Space();
            EditorGUILayout.PropertyField(this.m_APKExpansionFiles, EditorGUIUtility.TextContent("Split Application Binary|Split application binary into expansion files\n(use only with Google Play Store if larger than 50 MB)"), new GUILayoutOption[0]);
            EditorGUILayout.Space();
        }