-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInstanceManager.cs
36 lines (32 loc) · 1.14 KB
/
InstanceManager.cs
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
using System;
using System.Linq;
using Magix.Diagnostics;
namespace Magix
{
public static class InstanceManager
{
private static ICloudResourceAPI m_ResourceAPI;
public static ICloudScriptableObjectResolver Resolver => new DefaultCloudScriptableObjectResolver();
public static ICloudResourceAPI ResourceAPI
{
get
{
#if UNITY_EDITOR
if (m_ResourceAPI == null)
{
var apiType = AppDomain.CurrentDomain.GetAssemblies()
.SelectMany(assembly => assembly.GetTypes())
.FirstOrDefault(type => type.IsClass && !type.IsAbstract && typeof(ICloudResourceAPI).IsAssignableFrom(type));
if (apiType != null)
{
m_ResourceAPI = (ICloudResourceAPI)Activator.CreateInstance(apiType);
MagixLogger.LogVerbose($"Created an instance of {apiType.FullName} for ICloudResourceAPI.");
}
}
#endif
return m_ResourceAPI;
}
set => m_ResourceAPI = value;
}
}
}