forked from MattRix/UnityDecompiled
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDesktopStandaloneBuildWindowExtension.cs
More file actions
216 lines (194 loc) · 8.38 KB
/
DesktopStandaloneBuildWindowExtension.cs
File metadata and controls
216 lines (194 loc) · 8.38 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
using System;
using System.Collections.Generic;
using UnityEditor;
using UnityEditor.Modules;
using UnityEngine;
internal class DesktopStandaloneBuildWindowExtension : DefaultBuildWindowExtension
{
private GUIContent m_Architecture = EditorGUIUtility.TextContent("Architecture|Build m_Architecture for standalone");
private BuildTarget[] m_StandaloneSubtargets;
private GUIContent[] m_StandaloneSubtargetStrings;
private GUIContent m_StandaloneTarget = EditorGUIUtility.TextContent("Target Platform|Destination platform for standalone build");
public DesktopStandaloneBuildWindowExtension()
{
this.SetupStandaloneSubtargets();
}
private static BuildTarget DefaultTargetForPlatform(BuildTarget target)
{
switch (target)
{
case BuildTarget.StandaloneOSXUniversal:
case BuildTarget.StandaloneOSXIntel:
case BuildTarget.StandaloneOSXIntel64:
return BuildTarget.StandaloneOSXIntel;
case BuildTarget.StandaloneWindows:
break;
case BuildTarget.StandaloneLinux64:
case BuildTarget.StandaloneLinuxUniversal:
goto Label_0053;
default:
switch (target)
{
case BuildTarget.StandaloneLinux:
goto Label_0053;
case ((BuildTarget) 0x12):
return target;
case BuildTarget.StandaloneWindows64:
break;
default:
return target;
}
break;
}
return BuildTarget.StandaloneWindows;
Label_0053:
return BuildTarget.StandaloneLinux;
}
public override bool EnabledBuildAndRunButton() =>
true;
public override bool EnabledBuildButton() =>
true;
private static Dictionary<GUIContent, BuildTarget> GetArchitecturesForPlatform(BuildTarget target)
{
Dictionary<GUIContent, BuildTarget> dictionary;
switch (target)
{
case BuildTarget.StandaloneOSXUniversal:
case BuildTarget.StandaloneOSXIntel:
case BuildTarget.StandaloneOSXIntel64:
return new Dictionary<GUIContent, BuildTarget> {
{
EditorGUIUtility.TextContent("x86"),
BuildTarget.StandaloneOSXIntel
},
{
EditorGUIUtility.TextContent("x86_64"),
BuildTarget.StandaloneOSXIntel64
},
{
EditorGUIUtility.TextContent("Universal"),
BuildTarget.StandaloneOSXUniversal
}
};
case BuildTarget.StandaloneWindows:
break;
case BuildTarget.StandaloneLinux64:
case BuildTarget.StandaloneLinuxUniversal:
goto Label_007C;
default:
switch (target)
{
case BuildTarget.StandaloneLinux:
goto Label_007C;
case ((BuildTarget) 0x12):
goto Label_0100;
case BuildTarget.StandaloneWindows64:
break;
default:
goto Label_0100;
}
break;
}
return new Dictionary<GUIContent, BuildTarget> {
{
EditorGUIUtility.TextContent("x86"),
BuildTarget.StandaloneWindows
},
{
EditorGUIUtility.TextContent("x86_64"),
BuildTarget.StandaloneWindows64
}
};
Label_007C:
dictionary = new Dictionary<GUIContent, BuildTarget>();
dictionary.Add(EditorGUIUtility.TextContent("x86"), BuildTarget.StandaloneLinux);
dictionary.Add(EditorGUIUtility.TextContent("x86_64"), BuildTarget.StandaloneLinux64);
dictionary.Add(EditorGUIUtility.TextContent("x86 + x86_64 (Universal)"), BuildTarget.StandaloneLinuxUniversal);
return dictionary;
Label_0100:
return null;
}
private static BuildTarget GetBestStandaloneTarget(BuildTarget selectedTarget)
{
if (ModuleManager.IsPlatformSupportLoaded(ModuleManager.GetTargetStringFromBuildTarget(selectedTarget)))
{
return selectedTarget;
}
if ((Application.platform != RuntimePlatform.WindowsEditor) || !ModuleManager.IsPlatformSupportLoaded(ModuleManager.GetTargetStringFromBuildTarget(BuildTarget.StandaloneWindows)))
{
if ((Application.platform == RuntimePlatform.OSXEditor) && ModuleManager.IsPlatformSupportLoaded(ModuleManager.GetTargetStringFromBuildTarget(BuildTarget.StandaloneOSXIntel)))
{
return BuildTarget.StandaloneOSXIntel;
}
if (ModuleManager.IsPlatformSupportLoaded(ModuleManager.GetTargetStringFromBuildTarget(BuildTarget.StandaloneOSXIntel)))
{
return BuildTarget.StandaloneOSXIntel;
}
if (ModuleManager.IsPlatformSupportLoaded(ModuleManager.GetTargetStringFromBuildTarget(BuildTarget.StandaloneLinux)))
{
return BuildTarget.StandaloneLinux;
}
}
return BuildTarget.StandaloneWindows;
}
private void SetupStandaloneSubtargets()
{
List<BuildTarget> list = new List<BuildTarget>();
List<GUIContent> list2 = new List<GUIContent>();
if (ModuleManager.IsPlatformSupportLoaded(ModuleManager.GetTargetStringFromBuildTarget(BuildTarget.StandaloneWindows)))
{
list.Add(BuildTarget.StandaloneWindows);
list2.Add(EditorGUIUtility.TextContent("Windows"));
}
if (ModuleManager.IsPlatformSupportLoaded(ModuleManager.GetTargetStringFromBuildTarget(BuildTarget.StandaloneOSXIntel)))
{
list.Add(BuildTarget.StandaloneOSXIntel);
list2.Add(EditorGUIUtility.TextContent("Mac OS X"));
}
if (ModuleManager.IsPlatformSupportLoaded(ModuleManager.GetTargetStringFromBuildTarget(BuildTarget.StandaloneLinux)))
{
list.Add(BuildTarget.StandaloneLinux);
list2.Add(EditorGUIUtility.TextContent("Linux"));
}
this.m_StandaloneSubtargets = list.ToArray();
this.m_StandaloneSubtargetStrings = list2.ToArray();
}
public override void ShowPlatformBuildOptions()
{
BuildTarget bestStandaloneTarget = GetBestStandaloneTarget(EditorUserBuildSettings.selectedStandaloneTarget);
BuildTarget selectedStandaloneTarget = EditorUserBuildSettings.selectedStandaloneTarget;
int selectedIndex = Math.Max(0, Array.IndexOf<BuildTarget>(this.m_StandaloneSubtargets, DefaultTargetForPlatform(bestStandaloneTarget)));
int index = EditorGUILayout.Popup(this.m_StandaloneTarget, selectedIndex, this.m_StandaloneSubtargetStrings, new GUILayoutOption[0]);
if (index != selectedIndex)
{
selectedStandaloneTarget = this.m_StandaloneSubtargets[index];
}
else
{
Dictionary<GUIContent, BuildTarget> architecturesForPlatform = GetArchitecturesForPlatform(bestStandaloneTarget);
if (architecturesForPlatform != null)
{
GUIContent[] array = new List<GUIContent>(architecturesForPlatform.Keys).ToArray();
int num3 = 0;
if (index == selectedIndex)
{
foreach (KeyValuePair<GUIContent, BuildTarget> pair in architecturesForPlatform)
{
if (((BuildTarget) pair.Value) == bestStandaloneTarget)
{
num3 = Math.Max(0, Array.IndexOf<GUIContent>(array, pair.Key));
break;
}
}
}
num3 = EditorGUILayout.Popup(this.m_Architecture, num3, array, new GUILayoutOption[0]);
selectedStandaloneTarget = architecturesForPlatform[array[num3]];
}
}
if (selectedStandaloneTarget != EditorUserBuildSettings.selectedStandaloneTarget)
{
EditorUserBuildSettings.selectedStandaloneTarget = selectedStandaloneTarget;
GUIUtility.ExitGUI();
}
}
}