9using System.Collections.Generic;
18 private static List<LeapSpace> _enabledSpaces =
new List<LeapSpace>();
24 if (!Application.isPlaying) {
25 FindObjectsOfType<LeapSpace>().Query().Where(c => c.enabled).FillList(_enabledSpaces);
28 return _enabledSpaces;
32 private List<LeapSpaceAnchor> _anchors =
new List<LeapSpaceAnchor>();
37 _enabledSpaces.Add(
this);
46 _enabledSpaces.Remove(
this);
48 for (
int i = 0; i < _anchors.Count; i++) {
49 _anchors[i].space =
null;
50 _anchors[i].transformer =
null;
72 Assert.IsTrue(enabled,
"Should never call RebuildHierarchy on a disabled space.");
75 rebuildHierarchyRecursively(transform);
77 Assert.IsTrue(_anchors.Count > 0,
"There should always be at least a single anchor (this one).");
78 Assert.AreEqual(_anchors[0],
this,
"A space should always be the first element in the anchor list.");
86 Assert.IsTrue(enabled,
"Should never call RecalculateTransformers on a disabled space.");
92 for (
int i = 1; i < _anchors.Count; i++) {
93 var anchor = _anchors[i];
96 Assert.IsNotNull(anchor,
"Make sure to call RebuildHierarchy before RecalculateTransformers if you delete an anchor.");
97 Assert.IsTrue(anchor.enabled,
"Make sure to all RebuildHierarchy before RecalculateTransformers if you disable an anchor.");
113 private void rebuildHierarchyRecursively(Transform root) {
115 if (anchor !=
null && anchor.enabled) {
120 _anchors.Add(anchor);
123 int childCount = root.childCount;
124 for (
int i = 0; i < childCount; i++) {
125 rebuildHierarchyRecursively(root.GetChild(i));
void RecalculateParentAnchor()
List< LeapSpaceAnchor > anchors
Returns all active anchors in depth-first pre-order
abstract ITransformer CosntructBaseTransformer()
abstract void UpdateTransformer(ITransformer transformer, ITransformer parent)
abstract Hash GetSettingHash()
Get a hash of all features in this space. This is useful if you want to know if anything has changed ...
static List< LeapSpace > allEnabled
override void OnDisable()
void RecalculateTransformers()
Call to update all transformers in the space. Call this whenever any anchor or parent of an anchor ch...
void RebuildHierarchy()
Call to traverse the entire hierarchy and rebuild the relationship between anchors....
abstract ITransformer ConstructTransformer(LeapSpaceAnchor anchor)