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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using UnityEngine;
using UnityEditor;
using UnityEditor.SceneManagement;
using VRC.SDKBase.Validation.Performance;
using Object = UnityEngine.Object;
using VRC.SDKBase.Editor;
public partial class VRCSdkControlPanel : EditorWindow
{
public static System.Action _EnableSpatialization = null; // assigned in AutoAddONSPAudioSourceComponents
public const string AVATAR_OPTIMIZATION_TIPS_URL = "https://docs.vrchat.com/docs/avatar-optimizing-tips";
public const string AVATAR_RIG_REQUIREMENTS_URL = "https://docs.vrchat.com/docs/rig-requirements";
const string kCantPublishContent = "Before you can upload avatars or worlds, you will need to spend some time in VRChat.";
const string kCantPublishAvatars = "Before you can upload avatars, you will need to spend some time in VRChat.";
const string kCantPublishWorlds = "Before you can upload worlds, you will need to spend some time in VRChat.";
private const string FIX_ISSUES_TO_BUILD_OR_TEST_WARNING_STRING = "You must address the above issues before you can build or test this content!";
static Texture _perfIcon_Excellent;
static Texture _perfIcon_Good;
static Texture _perfIcon_Medium;
static Texture _perfIcon_Poor;
static Texture _perfIcon_VeryPoor;
static Texture _bannerImage;
public void ResetIssues()
{
GUIErrors.Clear();
GUIInfos.Clear();
GUIWarnings.Clear();
GUILinks.Clear();
GUIStats.Clear();
CheckedForIssues = false;
}
public bool CheckedForIssues { get; set; } = false;
class Issue
{
public string issueText;
public System.Action showThisIssue;
public System.Action fixThisIssue;
public PerformanceRating performanceRating;
public Issue(string text, System.Action show, System.Action fix, PerformanceRating rating = PerformanceRating.None)
{
issueText = text;
showThisIssue = show;
fixThisIssue = fix;
performanceRating = rating;
}
public class Equality : IEqualityComparer<Issue>, IComparer<Issue>
{
public bool Equals(Issue b1, Issue b2)
{
return (b1.issueText == b2.issueText);
}
public int Compare(Issue b1, Issue b2)
{
return string.Compare(b1.issueText, b2.issueText);
}
public int GetHashCode(Issue bx)
{
return bx.issueText.GetHashCode();
}
}
}
Dictionary<Object, List<Issue>> GUIErrors = new Dictionary<Object, List<Issue>>();
Dictionary<Object, List<Issue>> GUIWarnings = new Dictionary<Object, List<Issue>>();
Dictionary<Object, List<Issue>> GUIInfos = new Dictionary<Object, List<Issue>>();
Dictionary<Object, List<Issue>> GUILinks = new Dictionary<Object, List<Issue>>();
Dictionary<Object, List<Issue>> GUIStats = new Dictionary<Object, List<Issue>>();
public bool NoGuiErrors()
{
return GUIErrors.Count == 0;
}
public bool NoGuiErrorsOrIssues()
{
return GUIErrors.Count == 0 && CheckedForIssues;
}
void AddToReport(Dictionary<Object, List<Issue>> report, Object subject, string output, System.Action show, System.Action fix)
{
if (subject == null)
subject = this;
if (!report.ContainsKey(subject))
report.Add(subject, new List<Issue>());
var issue = new Issue(output, show, fix);
if (!report[subject].Contains(issue, new Issue.Equality()))
{
report[subject].Add(issue);
report[subject].Sort(new Issue.Equality());
}
}
void BuilderAssemblyReload()
{
ResetIssues();
}
public void OnGUIError(Object subject, string output, System.Action show, System.Action fix)
{
AddToReport(GUIErrors, subject, output, show, fix);
}
public void OnGUIWarning(Object subject, string output, System.Action show, System.Action fix)
{
AddToReport(GUIWarnings, subject, output, show, fix);
}
public void OnGUIInformation(Object subject, string output)
{
AddToReport(GUIInfos, subject, output, null, null);
}
public void OnGUILink(Object subject, string output, string link)
{
AddToReport(GUILinks, subject, output + "\n" + link, null, null);
}
public void OnGUIStat(Object subject, string output, PerformanceRating rating, System.Action show, System.Action fix)
{
if (subject == null)
subject = this;
if (!GUIStats.ContainsKey(subject))
GUIStats.Add(subject, new List<Issue>());
GUIStats[subject].Add(new Issue(output, show, fix, rating));
}
public int triggerLineMode
{
get { return EditorPrefs.GetInt("VRC.SDKBase_triggerLineMode", 0); }
set { EditorPrefs.SetInt("VRC.SDKBase_triggerLineMode", value); }
}
private void ShowSettingsOptionsForBuilders()
{
if (_sdkBuilders == null)
{
PopulateSdkBuilders();
}
for (int i = 0; i < _sdkBuilders.Length; i++)
{
IVRCSdkControlPanelBuilder builder = _sdkBuilders[i];
builder.ShowSettingsOptions();
if (i < _sdkBuilders.Length - 1)
{
EditorGUILayout.Separator();
}
}
}
private IVRCSdkControlPanelBuilder[] _sdkBuilders;
private static List<Type> GetSdkBuilderTypesFromAttribute()
{
Type sdkBuilderInterfaceType = typeof(IVRCSdkControlPanelBuilder);
Type sdkBuilderAttributeType = typeof(VRCSdkControlPanelBuilderAttribute);
List<Type> moduleTypesFromAttribute = new List<Type>();
foreach(Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
{
VRCSdkControlPanelBuilderAttribute[] sdkBuilderAttributes;
try
{
sdkBuilderAttributes = (VRCSdkControlPanelBuilderAttribute[])assembly.GetCustomAttributes(sdkBuilderAttributeType, true);
}
catch
{
sdkBuilderAttributes = new VRCSdkControlPanelBuilderAttribute[0];
}
foreach(VRCSdkControlPanelBuilderAttribute udonWrapperModuleAttribute in sdkBuilderAttributes)
{
if(udonWrapperModuleAttribute == null)
{
continue;
}
if(!sdkBuilderInterfaceType.IsAssignableFrom(udonWrapperModuleAttribute.Type))
{
continue;
}
moduleTypesFromAttribute.Add(udonWrapperModuleAttribute.Type);
}
}
return moduleTypesFromAttribute;
}
private void PopulateSdkBuilders()
{
if (_sdkBuilders != null)
{
return;
}
List<IVRCSdkControlPanelBuilder> builders = new List<IVRCSdkControlPanelBuilder>();
foreach (Type type in GetSdkBuilderTypesFromAttribute())
{
IVRCSdkControlPanelBuilder builder = (IVRCSdkControlPanelBuilder)Activator.CreateInstance(type);
builder.RegisterBuilder(this);
builders.Add(builder);
}
_sdkBuilders = builders.ToArray();
}
void ShowBuilders()
{
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
GUILayout.BeginVertical();
if (VRC.Core.ConfigManager.RemoteConfig.IsInitialized())
{
string sdkUnityVersion = VRC.Core.ConfigManager.RemoteConfig.GetString("sdkUnityVersion");
if (Application.unityVersion != sdkUnityVersion)
{
OnGUIWarning(null, "You are not using the recommended Unity version for the VRChat SDK. Content built with this version may not work correctly. Please use Unity " + sdkUnityVersion,
null,
() => { Application.OpenURL("https://unity3d.com/get-unity/download/archive"); }
);
}
}
if (VRCSdk3Analysis.IsSdkDllActive(VRCSdk3Analysis.SdkVersion.VRCSDK2) && VRCSdk3Analysis.IsSdkDllActive(VRCSdk3Analysis.SdkVersion.VRCSDK3))
{
List<Component> sdk2Components = VRCSdk3Analysis.GetSDKInScene(VRCSdk3Analysis.SdkVersion.VRCSDK2);
List<Component> sdk3Components = VRCSdk3Analysis.GetSDKInScene(VRCSdk3Analysis.SdkVersion.VRCSDK3);
if (sdk2Components.Count > 0 && sdk3Components.Count > 0)
{
OnGUIError(null,
"This scene contains components from the VRChat SDK version 2 and version 3. Version two elements will have to be replaced with their version 3 counterparts to build with SDK3 and UDON.",
() => { Selection.objects = sdk2Components.ToArray(); },
null
);
}
}
if (Lightmapping.giWorkflowMode == Lightmapping.GIWorkflowMode.Iterative)
{
OnGUIWarning(null,
"Automatic lightmap generation is enabled, which may stall the Unity build process. Before building and uploading, consider turning off 'Auto Generate' at the bottom of the Lighting Window.",
() =>
{
EditorWindow lightingWindow = GetLightingWindow();
if (lightingWindow)
{
lightingWindow.Show();
lightingWindow.Focus();
}
},
() =>
{
Lightmapping.giWorkflowMode = Lightmapping.GIWorkflowMode.OnDemand;
EditorWindow lightingWindow = GetLightingWindow();
if (!lightingWindow) return;
lightingWindow.Repaint();
Focus();
}
);
}
PopulateSdkBuilders();
IVRCSdkControlPanelBuilder selectedBuilder = null;
string errorMessage = null;
foreach (IVRCSdkControlPanelBuilder sdkBuilder in _sdkBuilders)
{
if (!sdkBuilder.IsValidBuilder(out string message))
{
if (selectedBuilder == null)
{
errorMessage = message;
}
}
else
{
if (selectedBuilder == null)
{
selectedBuilder = sdkBuilder;
errorMessage = null;
}
else
{
errorMessage =
"A Unity scene cannot contain a VRChat Scene Descriptor and also contain VRChat Avatar Descriptors";
}
}
}
if (selectedBuilder == null)
{
string message = "";
#if VRC_SDK_VRCSDK2
message = "A VRC_SceneDescriptor or VRC_AvatarDescriptor\nis required to build VRChat SDK Content";
#elif UDON
message = "A VRCSceneDescriptor is required to build a World";
#elif VRC_SDK_VRCSDK3
message = "A VRCAvatarDescriptor is required to build an Avatar";
#else
message = "The SDK did not load properly. Try this - In the Project window, navigate to Assets/VRCSDK/Plugins. Select all the DLLs, then right click and choose 'Reimport'";
#endif
EditorGUILayout.LabelField(message, titleGuiStyle, GUILayout.Width(SdkWindowWidth));
}
else if (errorMessage != null)
{
OnGUIError(null,
errorMessage,
() => {
foreach (IVRCSdkControlPanelBuilder builder in _sdkBuilders)
{
builder.SelectAllComponents();
} },
null
);
OnGUIShowIssues();
}
else
{
selectedBuilder.ShowBuilder();
}
if (Event.current.type == EventType.Used) return;
GUILayout.EndVertical();
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
}
public bool showLayerHelp = false;
bool ShouldShowLightmapWarning
{
get
{
const string GraphicsSettingsAssetPath = "ProjectSettings/GraphicsSettings.asset";
SerializedObject graphicsManager = new SerializedObject(UnityEditor.AssetDatabase.LoadAllAssetsAtPath(GraphicsSettingsAssetPath)[0]);
SerializedProperty lightmapStripping = graphicsManager.FindProperty("m_LightmapStripping");
return lightmapStripping.enumValueIndex == 0;
}
}
bool ShouldShowFogWarning
{
get
{
const string GraphicsSettingsAssetPath = "ProjectSettings/GraphicsSettings.asset";
SerializedObject graphicsManager = new SerializedObject(UnityEditor.AssetDatabase.LoadAllAssetsAtPath(GraphicsSettingsAssetPath)[0]);
SerializedProperty lightmapStripping = graphicsManager.FindProperty("m_FogStripping");
return lightmapStripping.enumValueIndex == 0;
}
}
void DrawIssueBox(MessageType msgType, Texture icon, string message, System.Action show, System.Action fix)
{
bool haveButtons = ((show != null) || (fix != null));
GUIStyle style = new GUIStyle("HelpBox");
style.fixedWidth = (haveButtons ? (SdkWindowWidth - 90) : SdkWindowWidth);
float minHeight = 40;
try
{
EditorGUILayout.BeginHorizontal();
if (icon != null)
{
GUIContent c = new GUIContent(message, icon);
float height = style.CalcHeight(c, style.fixedWidth);
GUILayout.Box(c, style, GUILayout.MinHeight(Mathf.Max(minHeight, height)));
}
else
{
GUIContent c = new GUIContent(message);
float height = style.CalcHeight(c, style.fixedWidth);
Rect rt = GUILayoutUtility.GetRect(c, style, GUILayout.MinHeight(Mathf.Max(minHeight, height)));
EditorGUI.HelpBox(rt, message, msgType); // note: EditorGUILayout resulted in uneven button layout in this case
}
if (haveButtons)
{
EditorGUILayout.BeginVertical();
float buttonHeight = ((show == null || fix == null) ? minHeight : (minHeight * 0.5f));
if ((show != null) && GUILayout.Button("Select", GUILayout.Height(buttonHeight)))
show();
if ((fix != null) && GUILayout.Button("Auto Fix", GUILayout.Height(buttonHeight)))
{
fix();
EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
CheckedForIssues = false;
Repaint();
}
EditorGUILayout.EndVertical();
}
EditorGUILayout.EndHorizontal();
}
catch
{
// mutes 'ArgumentException: Getting control 0's position in a group with only 0 controls when doing repaint'
}
}
public void OnGuiFixIssuesToBuildOrTest()
{
GUIStyle s = new GUIStyle(EditorStyles.label) { alignment = TextAnchor.MiddleCenter };
EditorGUILayout.Space();
GUILayout.BeginVertical(boxGuiStyle, GUILayout.Height(WARNING_ICON_SIZE), GUILayout.Width(SdkWindowWidth));
GUILayout.FlexibleSpace();
EditorGUILayout.BeginHorizontal();
var textDimensions = s.CalcSize(new GUIContent(FIX_ISSUES_TO_BUILD_OR_TEST_WARNING_STRING));
GUILayout.Label(new GUIContent(warningIconGraphic), GUILayout.Width(WARNING_ICON_SIZE), GUILayout.Height(WARNING_ICON_SIZE));
EditorGUILayout.LabelField(FIX_ISSUES_TO_BUILD_OR_TEST_WARNING_STRING, s, GUILayout.Width(textDimensions.x), GUILayout.Height(WARNING_ICON_SIZE));
EditorGUILayout.EndHorizontal();
GUILayout.FlexibleSpace();
GUILayout.EndVertical();
}
public void OnGUIShowIssues(Object subject = null)
{
if (subject == null)
subject = this;
EditorGUI.BeginChangeCheck();
GUIStyle style = GUI.skin.GetStyle("HelpBox");
if (GUIErrors.ContainsKey(subject))
foreach (Issue error in GUIErrors[subject].Where(s => !string.IsNullOrEmpty(s.issueText)))
DrawIssueBox(MessageType.Error, null, error.issueText, error.showThisIssue, error.fixThisIssue);
if (GUIWarnings.ContainsKey(subject))
foreach (Issue error in GUIWarnings[subject].Where(s => !string.IsNullOrEmpty(s.issueText)))
DrawIssueBox(MessageType.Warning, null, error.issueText, error.showThisIssue, error.fixThisIssue);
if (GUIStats.ContainsKey(subject))
{
foreach (var kvp in GUIStats[subject].Where(k => k.performanceRating == PerformanceRating.VeryPoor))
DrawIssueBox(MessageType.Warning, GetPerformanceIconForRating(kvp.performanceRating), kvp.issueText, kvp.showThisIssue, kvp.fixThisIssue);
foreach (var kvp in GUIStats[subject].Where(k => k.performanceRating == PerformanceRating.Poor))
DrawIssueBox(MessageType.Warning, GetPerformanceIconForRating(kvp.performanceRating), kvp.issueText, kvp.showThisIssue, kvp.fixThisIssue);
foreach (var kvp in GUIStats[subject].Where(k => k.performanceRating == PerformanceRating.Medium))
DrawIssueBox(MessageType.Warning, GetPerformanceIconForRating(kvp.performanceRating), kvp.issueText, kvp.showThisIssue, kvp.fixThisIssue);
foreach (var kvp in GUIStats[subject].Where(k => k.performanceRating == PerformanceRating.Good || k.performanceRating == PerformanceRating.Excellent))
DrawIssueBox(MessageType.Warning, GetPerformanceIconForRating(kvp.performanceRating), kvp.issueText, kvp.showThisIssue, kvp.fixThisIssue);
}
if (GUIInfos.ContainsKey(subject))
foreach (Issue error in GUIInfos[subject].Where(s => !string.IsNullOrEmpty(s.issueText)))
EditorGUILayout.HelpBox(error.issueText, MessageType.Info);
if (GUILinks.ContainsKey(subject))
{
EditorGUILayout.BeginVertical(style);
foreach (Issue error in GUILinks[subject].Where(s => !string.IsNullOrEmpty(s.issueText)))
{
var s = error.issueText.Split('\n');
EditorGUILayout.BeginHorizontal();
GUILayout.Label(s[0]);
if (GUILayout.Button("Open Link", GUILayout.Width(100)))
Application.OpenURL(s[1]);
EditorGUILayout.EndHorizontal();
}
EditorGUILayout.EndVertical();
}
if (EditorGUI.EndChangeCheck())
{
EditorUtility.SetDirty(subject);
UnityEditor.SceneManagement.EditorSceneManager.MarkSceneDirty(UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene());
}
}
private Texture GetPerformanceIconForRating(PerformanceRating value)
{
if (_perfIcon_Excellent == null)
_perfIcon_Excellent = Resources.Load<Texture>("PerformanceIcons/Perf_Great_32");
if (_perfIcon_Good == null)
_perfIcon_Good = Resources.Load<Texture>("PerformanceIcons/Perf_Good_32");
if (_perfIcon_Medium == null)
_perfIcon_Medium = Resources.Load<Texture>("PerformanceIcons/Perf_Medium_32");
if (_perfIcon_Poor == null)
_perfIcon_Poor = Resources.Load<Texture>("PerformanceIcons/Perf_Poor_32");
if (_perfIcon_VeryPoor == null)
_perfIcon_VeryPoor = Resources.Load<Texture>("PerformanceIcons/Perf_Horrible_32");
switch (value)
{
case PerformanceRating.Excellent:
return _perfIcon_Excellent;
case PerformanceRating.Good:
return _perfIcon_Good;
case PerformanceRating.Medium:
return _perfIcon_Medium;
case PerformanceRating.Poor:
return _perfIcon_Poor;
case PerformanceRating.None:
case PerformanceRating.VeryPoor:
return _perfIcon_VeryPoor;
}
return _perfIcon_Excellent;
}
Texture2D CreateBackgroundColorImage(UnityEngine.Color color)
{
int w = 4, h = 4;
Texture2D back = new Texture2D(w, h);
UnityEngine.Color[] buffer = new UnityEngine.Color[w * h];
for (int i = 0; i < w; ++i)
for (int j = 0; j < h; ++j)
buffer[i + w * j] = color;
back.SetPixels(buffer);
back.Apply(false);
return back;
}
public static void DrawContentInfo(string name, string version, string description, string capacity, string releaseStatus, List<string> tags)
{
EditorGUILayout.LabelField("Name: " + name);
EditorGUILayout.LabelField("Version: " + version.ToString());
EditorGUILayout.LabelField("Description: " + description);
if (capacity != null)
EditorGUILayout.LabelField("Capacity: " + capacity);
EditorGUILayout.LabelField("Release: " + releaseStatus);
if (tags != null)
{
string tagString = "";
for (int i = 0; i < tags.Count; i++)
{
if (i != 0) tagString += ", ";
tagString += tags[i];
}
EditorGUILayout.LabelField("Tags: " + tagString);
}
}
public static void DrawContentPlatformSupport(VRC.Core.ApiModel m)
{
if (m.supportedPlatforms == VRC.Core.ApiModel.SupportedPlatforms.StandaloneWindows || m.supportedPlatforms == VRC.Core.ApiModel.SupportedPlatforms.All)
EditorGUILayout.LabelField("Windows Support: YES");
else
EditorGUILayout.LabelField("Windows Support: NO");
if (m.supportedPlatforms == VRC.Core.ApiModel.SupportedPlatforms.Android || m.supportedPlatforms == VRC.Core.ApiModel.SupportedPlatforms.All)
EditorGUILayout.LabelField("Android Support: YES");
else
EditorGUILayout.LabelField("Android Support: NO");
}
public static void DrawBuildTargetSwitcher()
{
EditorGUILayout.LabelField("Active Build Target: " + EditorUserBuildSettings.activeBuildTarget);
if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.StandaloneWindows || EditorUserBuildSettings.activeBuildTarget == BuildTarget.StandaloneWindows64 && GUILayout.Button("Switch Build Target to Android"))
{
if (EditorUtility.DisplayDialog("Build Target Switcher", "Are you sure you want to switch your build target to Android? This could take a while.", "Confirm", "Cancel"))
{
EditorUserBuildSettings.selectedBuildTargetGroup = BuildTargetGroup.Android;
EditorUserBuildSettings.SwitchActiveBuildTargetAsync(BuildTargetGroup.Android, BuildTarget.Android);
}
}
if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.Android && GUILayout.Button("Switch Build Target to Windows"))
{
if (EditorUtility.DisplayDialog("Build Target Switcher", "Are you sure you want to switch your build target to Windows? This could take a while.", "Confirm", "Cancel"))
{
EditorUserBuildSettings.selectedBuildTargetGroup = BuildTargetGroup.Standalone;
EditorUserBuildSettings.SwitchActiveBuildTargetAsync(BuildTargetGroup.Standalone, BuildTarget.StandaloneWindows64);
}
}
}
public static string GetBuildAndPublishButtonString()
{
string buildButtonString = "Build & Publish for UNSUPPORTED";
if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.StandaloneWindows || EditorUserBuildSettings.activeBuildTarget == BuildTarget.StandaloneWindows64)
buildButtonString = "Build & Publish for Windows";
if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.Android)
buildButtonString = "Build & Publish for Android";
return buildButtonString;
}
public static Object[] GetSubstanceObjects(GameObject obj = null, bool earlyOut = false)
{
// if 'obj' is null we check entire scene
// if 'earlyOut' is true we only return 1st object (to detect if substances are present)
List<Object> objects = new List<Object>();
if (obj == null) return objects.Count < 1 ? null : objects.ToArray();
Renderer[] renderers = obj ? obj.GetComponentsInChildren<Renderer>(true) : FindObjectsOfType<Renderer>();
if (renderers == null || renderers.Length < 1)
return null;
foreach (Renderer r in renderers)
{
if (r.sharedMaterials.Length < 1)
continue;
foreach (Material m in r.sharedMaterials)
{
if (!m)
continue;
string path = AssetDatabase.GetAssetPath(m);
if (string.IsNullOrEmpty(path))
continue;
if (path.EndsWith(".sbsar", true, System.Globalization.CultureInfo.InvariantCulture))
{
objects.Add(r.gameObject);
if (earlyOut)
return objects.ToArray();
}
}
}
return objects.Count < 1 ? null : objects.ToArray();
}
public static bool HasSubstances(GameObject obj = null)
{
return (GetSubstanceObjects(obj, true) != null);
}
EditorWindow GetLightingWindow()
{
var editorAsm = typeof(UnityEditor.Editor).Assembly;
return EditorWindow.GetWindow(editorAsm.GetType("UnityEditor.LightingWindow"));
}
public static void ShowContentPublishPermissionsDialog()
{
if (!VRC.Core.ConfigManager.RemoteConfig.IsInitialized())
{
VRC.Core.ConfigManager.RemoteConfig.Init(() => ShowContentPublishPermissionsDialog());
return;
}
string message = VRC.Core.ConfigManager.RemoteConfig.GetString("sdkNotAllowedToPublishMessage");
int result = UnityEditor.EditorUtility.DisplayDialogComplex("VRChat SDK", message, "Developer FAQ", "VRChat Discord", "OK");
if (result == 0)
{
ShowDeveloperFAQ();
}
if (result == 1)
{
ShowVRChatDiscord();
}
}
}
|