forked from Unity-Technologies/UnityCsReference
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSubsystemManager.cs
More file actions
105 lines (89 loc) · 3.65 KB
/
Copy pathSubsystemManager.cs
File metadata and controls
105 lines (89 loc) · 3.65 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
102
103
104
105
// Unity C# reference source
// Copyright (c) Unity Technologies. For terms of use, see
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License
using System;
using System.Collections.Generic;
using UnityEngine.Bindings;
using UnityEngine.SubsystemsImplementation;
namespace UnityEngine
{
public static partial class SubsystemManager
{
static SubsystemManager() => StaticConstructScriptingClassMap();
public static void GetAllSubsystemDescriptors(List<ISubsystemDescriptor> descriptors)
{
SubsystemDescriptorStore.GetAllSubsystemDescriptors(descriptors);
}
public static void GetSubsystemDescriptors<T>(List<T> descriptors)
where T : ISubsystemDescriptor
{
SubsystemDescriptorStore.GetSubsystemDescriptors(descriptors);
}
public static void GetSubsystems<T>(List<T> subsystems)
where T : ISubsystem
{
subsystems.Clear();
AddSubsystemSubset(s_IntegratedSubsystems, subsystems);
AddSubsystemSubset(s_StandaloneSubsystems, subsystems);
AddSubsystemSubset(s_DeprecatedSubsystems, subsystems);
}
static void AddSubsystemSubset<TBaseTypeInList, TQueryType>(List<TBaseTypeInList> copyFrom, List<TQueryType> copyTo)
where TQueryType : ISubsystem
where TBaseTypeInList : ISubsystem
{
foreach (var subsystem in copyFrom)
{
if (subsystem is TQueryType concreteSubsystem)
copyTo.Add(concreteSubsystem);
}
}
// event never invoked warning (invoked indirectly from native code)
#pragma warning disable CS0067
public static event Action beforeReloadSubsystems;
public static event Action afterReloadSubsystems;
#pragma warning restore CS0067
[VisibleToOtherModules("UnityEngine.XRModule")]
internal static IntegratedSubsystem GetIntegratedSubsystemByPtr(IntPtr ptr)
{
foreach (var subsystem in s_IntegratedSubsystems)
{
if (subsystem.m_Ptr == ptr)
return subsystem;
}
return null;
}
internal static void RemoveIntegratedSubsystemByPtr(IntPtr ptr)
{
for (int finderIndex = 0; finderIndex < s_IntegratedSubsystems.Count; ++finderIndex)
{
if (s_IntegratedSubsystems[finderIndex].m_Ptr != ptr)
continue;
s_IntegratedSubsystems[finderIndex].m_Ptr = IntPtr.Zero;
s_IntegratedSubsystems.RemoveAt(finderIndex);
break;
}
}
internal static void AddStandaloneSubsystem(SubsystemWithProvider subsystem)
{
s_StandaloneSubsystems.Add(subsystem);
}
internal static bool RemoveStandaloneSubsystem(SubsystemWithProvider subsystem)
{
return s_StandaloneSubsystems.Remove(subsystem);
}
internal static SubsystemWithProvider FindStandaloneSubsystemByDescriptor(SubsystemDescriptorWithProvider descriptor)
{
foreach (var subsystem in s_StandaloneSubsystems)
{
if (subsystem.descriptor == descriptor)
return subsystem;
}
return null;
}
static List<IntegratedSubsystem> s_IntegratedSubsystems = new List<IntegratedSubsystem>();
static List<SubsystemWithProvider> s_StandaloneSubsystems = new List<SubsystemWithProvider>();
#pragma warning disable CS0618
static List<Subsystem> s_DeprecatedSubsystems = new List<Subsystem>();
#pragma warning restore CS0618
}
}