forked from MattRix/UnityDecompiled
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAndroidSdkRoot.cs
More file actions
84 lines (84 loc) · 2.12 KB
/
AndroidSdkRoot.cs
File metadata and controls
84 lines (84 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
using Microsoft.Win32;
using System;
using System.IO;
using UnityEngine;
namespace UnityEditor
{
internal class AndroidSdkRoot
{
private static string GuessPerPlatform()
{
RuntimePlatform platform = Application.platform;
if (platform != RuntimePlatform.OSXEditor)
{
if (platform != RuntimePlatform.WindowsEditor)
{
return string.Empty;
}
string text = Registry.GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Android SDK Tools", "Path", string.Empty).ToString();
if (!string.IsNullOrEmpty(text))
{
return text;
}
text = Registry.GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Android SDK Tools", "Path", string.Empty).ToString();
if (!string.IsNullOrEmpty(text))
{
return text;
}
text = Environment.GetEnvironmentVariable("ProgramFiles");
if (!string.IsNullOrEmpty(text))
{
return text;
}
}
else
{
string environmentVariable = Environment.GetEnvironmentVariable("HOME");
if (!string.IsNullOrEmpty(environmentVariable))
{
return environmentVariable;
}
}
return string.Empty;
}
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;
}
internal static bool IsSdkDir(string path)
{
return Directory.Exists(Path.Combine(path, "platform-tools")) || File.Exists(Path.Combine(Path.Combine(path, "tools"), "android")) || File.Exists(Path.Combine(Path.Combine(path, "tools"), "android.bat"));
}
}
}