private void AndroidSdkLocation()
        {
            GUIStyle popup = EditorStyles.popup;

            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            EditorGUILayout.PrefixLabel("Android SDK Location", popup);
            string     text    = (!string.IsNullOrEmpty(this.m_AndroidSdkPath)) ? this.m_AndroidSdkPath : "Browse...";
            GUIContent content = new GUIContent(text);
            Rect       rect    = GUILayoutUtility.GetRect(GUIContent.none, popup);

            if (EditorGUI.ButtonMouseDown(rect, content, FocusType.Native, popup))
            {
                string text2 = AndroidSdkRoot.Browse(this.m_AndroidSdkPath);
                if (!string.IsNullOrEmpty(text2))
                {
                    this.m_AndroidSdkPath = text2;
                    this.WritePreferences();
                    this.ReadPreferences();
                }
            }
            GUILayout.EndHorizontal();
        }
Esempio n. 2
0
        internal static string Browse(string sdkPath)
        {
            string defaultName = string.Empty;

            if (Application.platform == RuntimePlatform.OSXEditor)
            {
                defaultName = "android-sdk-mac_x86";
            }
            string title = "Select Android SDK root folder";
            string text  = sdkPath;

            if (string.IsNullOrEmpty(text))
            {
                try
                {
                    text = AndroidSdkRoot.GuessPerPlatform();
                }
                catch (Exception value)
                {
                    Console.WriteLine("Exception while trying to guess Android SDK location");
                    Console.WriteLine(value);
                }
            }
            while (true)
            {
                sdkPath = EditorUtility.OpenFolderPanel(title, text, defaultName);
                if (sdkPath.Length == 0)
                {
                    break;
                }
                if (AndroidSdkRoot.IsSdkDir(sdkPath))
                {
                    return(sdkPath);
                }
            }
            return(string.Empty);
        }