-
Notifications
You must be signed in to change notification settings - Fork 135
/
Copy pathMRTKProfile.cs
92 lines (83 loc) · 3.16 KB
/
MRTKProfile.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
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
// Copyright (c) Mixed Reality Toolkit Contributors
// Licensed under the BSD 3-Clause
using MixedReality.Toolkit.Subsystems;
using System.Collections.Generic;
using UnityEngine;
namespace MixedReality.Toolkit
{
/// <summary>
/// A build-target-specific profile that determines which subsystems are launched,
/// and which configurations are bound to them.
/// </summary>
[System.Serializable]
[CreateAssetMenu(fileName = "MRTKProfile.asset", menuName = "MRTK/MRTKProfile")]
public class MRTKProfile : BaseMRTKProfile
{
private static MRTKProfile instance = null;
/// <summary>
/// Static instance that will hold the runtime asset instance we created in our build process.
/// </summary>
public static MRTKProfile Instance
{
get => instance;
#if UNITY_EDITOR
set => instance = value;
#endif
}
[SerializeField]
[Tooltip("The list of subsystems intended to be started at runtime.")]
[Implements(typeof(IMRTKManagedSubsystem), TypeGrouping.ByNamespaceFlat)]
private List<SystemType> loadedSubsystems = new List<SystemType>();
/// <summary>
/// The list of subsystems intended to be started at runtime.
/// </summary>
/// <remarks>
/// Subsystems not on this list may still be started at a later point, manually.
/// </remarks>
public List<SystemType> LoadedSubsystems
{
get => loadedSubsystems;
protected set => loadedSubsystems = value;
}
[SerializeField]
[Tooltip("The collection of configuration mapped to the corresponding subsystem.")]
private SerializableDictionary<SystemType, BaseSubsystemConfig> subsystemConfigs = new SerializableDictionary<SystemType, BaseSubsystemConfig>();
/// <summary>
/// The collection of <see cref="BaseSubsystemConfig"/> mapped to the corresponding subsystem.
/// </summary>
protected SerializableDictionary<SystemType, BaseSubsystemConfig> SubsystemConfigs
{
get => subsystemConfigs;
set => subsystemConfigs = value;
}
/// <summary>
/// Attempts to retrieve the specified <see cref="BaseSubsystemConfig"/> for a given subsystem type.
/// </summary>
/// <returns>
/// <see langword="true"/> if there is a registered configuration for the specified subsystem, <see langword="false"/> otherwise.
/// </returns>
public bool TryGetConfigForSubsystem(SystemType subsystemType, out BaseSubsystemConfig config)
{
if (subsystemConfigs.ContainsKey(subsystemType))
{
config = subsystemConfigs[subsystemType];
return true;
}
else
{
config = null;
return false;
}
}
#if !UNITY_EDITOR
/// <summary>
/// A Unity event function that is called when an enabled script instance is being loaded.
/// </summary>
private void Awake()
{
instance = this;
DontDestroyOnLoad(instance);
}
#endif
}
}