TestLoaderBase.cs
3.09 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
using System.Collections.Generic;
using UnityEngine.XR.Management;
#if UNITY_EDITOR
using UnityEditor;
using UnityEditor.XR.Management;
#endif
using UnityEngine.XR.Management.Tests.Standalone;
namespace Unity.XR.Management.TestPackage
{
public class TestLoaderBase : XRLoaderHelper
{
#if UNITY_EDITOR
public TestLoaderBase()
{
WasAssigned = false;
WasUnassigned = false;
}
public static bool WasAssigned { get; set; }
public static bool WasUnassigned { get; set; }
#endif
static List<StandaloneSubsystemDescriptor> s_StandaloneSubsystemDescriptors =
new List<StandaloneSubsystemDescriptor>();
public StandaloneSubsystem inputSubsystem
{
get { return GetLoadedSubsystem<StandaloneSubsystem>(); }
}
TestSettings GetSettings()
{
TestSettings settings = null;
// When running in the Unity Editor, we have to load user's customization of configuration data directly from
// EditorBuildSettings. At runtime, we need to grab it from the static instance field instead.
#if UNITY_EDITOR
UnityEditor.EditorBuildSettings.TryGetConfigObject(Constants.k_SettingsKey, out settings);
#else
settings = TestSettings.s_RuntimeInstance;
#endif
return settings;
}
#region XRLoader API Implementation
/// <summary>Implementaion of <see cref="XRLoader.Initialize"/></summary>
/// <returns>True if successful, false otherwise</returns>
public override bool Initialize()
{
TestSettings settings = GetSettings();
if (settings != null)
{
// TODO: Pass settings off to plugin prior to subsystem init.
}
CreateSubsystem<StandaloneSubsystemDescriptor, StandaloneSubsystem>(s_StandaloneSubsystemDescriptors, "Standalone Subsystem");
return false;
}
/// <summary>Implementaion of <see cref="XRLoader.Start"/></summary>
/// <returns>True if successful, false otherwise</returns>
public override bool Start()
{
StartSubsystem<StandaloneSubsystem>();
return true;
}
/// <summary>Implementaion of <see cref="XRLoader.Stop"/></summary>
/// <returns>True if successful, false otherwise</returns>
public override bool Stop()
{
StopSubsystem<StandaloneSubsystem>();
return true;
}
/// <summary>Implementaion of <see cref="XRLoader.Deinitialize"/></summary>
/// <returns>True if successful, false otherwise</returns>
public override bool Deinitialize()
{
DestroySubsystem<StandaloneSubsystem>();
return true;
}
#if UNITY_EDITOR
public override void WasAssignedToBuildTarget(BuildTargetGroup buildTargetGroup)
{
WasAssigned = true;
}
public override void WasUnassignedFromBuildTarget(BuildTargetGroup buildTargetGroup)
{
WasUnassigned = true;
}
#endif
#endregion
}
}