XRCustomLoaderUIManager.cs
1.51 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
using System;
using UnityEngine;
namespace UnityEditor.XR.Management
{
internal class XRCustomLoaderUIManager
{
public static IXRCustomLoaderUI GetCustomLoaderUI(string loaderTypeName, BuildTargetGroup buildTargetGroup)
{
IXRCustomLoaderUI ret = null;
var customLoaderTypes = TypeCache.GetTypesDerivedFrom(typeof(IXRCustomLoaderUI));
foreach (var customLoader in customLoaderTypes)
{
var attribs = customLoader.GetCustomAttributes(typeof(XRCustomLoaderUIAttribute), true);
foreach (var attrib in attribs)
{
if (attrib is XRCustomLoaderUIAttribute)
{
var customUiAttrib = attrib as XRCustomLoaderUIAttribute;
if (String.Compare(loaderTypeName, customUiAttrib.loaderTypeName, true) == 0 &&
buildTargetGroup == customUiAttrib.buildTargetGroup)
{
if (ret != null)
{
Debug.Log($"Multiple custom ui renderers found for ({loaderTypeName}, {buildTargetGroup}). Defaulting to built-in rendering instead.");
return null;
}
ret = Activator.CreateInstance(customLoader) as IXRCustomLoaderUI;
}
}
}
}
return ret;
}
}
}