Class AlignSubtree
Script to use an independent AlignmentManager to align a specific subtree, independent of the rest of the scene.
Namespace: Microsoft.MixedReality.WorldLocking.Core
Assembly: cs.temp.dll.dll
Syntax
public class AlignSubtree : MonoBehaviour
Remarks
The subtree aligned by this will remain world-locked by the independent global world-locking by the WorldLockingManager. This script illustrates how to create and manage an independent AlignmentManager, and apply its alignment to a specific subtree within the scene (the Sub Tree). The global AlignmentManager, owned and managed by the WorldLockingManager, applies its alignment to the global Unity coordinate space (frozen space). The desire here is to use the same Space Pin feature to pin parts of a virtual model (subtree) to the physical world, without affecting global space. To do this requires several steps:
- Create a new locally owned AlignmentManager (distinct from the one owned by the WorldLockingManager). See Microsoft.MixedReality.WorldLocking.Core.AlignSubtree.CheckInternalWiring.
- Point the desired SpacePins to use the locally owned AlignmentManager (they default to use the global one). See Microsoft.MixedReality.WorldLocking.Core.AlignSubtree.OnEnable.
- Use the local AlignmentManager to compute a correction pose, and apply it to the subtree. See Microsoft.MixedReality.WorldLocking.Core.AlignSubtree.Update. On point 2., there are a number of reasonable ways to harvest which SpacePins should use this local AlignmentManager, the method used here, invoking GetComponentsInChildren, is just one such way.
Fields
subTree
The transform to align. If unset, will align this.transform.
Declaration
public Transform subTree
Field Value
Type | Description |
---|---|
Transform |
Remarks
This transform must be identity at startup, and must not be modified by anything but this AlignSubtree component.
Properties
AlignmentManager
Owned independent AlignmentManager.
Declaration
public AlignmentManager AlignmentManager { get; }
Property Value
Type | Description |
---|---|
AlignmentManager |
CollectFromTree
Collect all SpacePins from this subtree to manage.
Declaration
public bool CollectFromTree { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
Orienter
Optional orienter for implicit orientation SpacePins. If null, will search for it in subtree.
Declaration
public IOrienter Orienter { get; set; }
Property Value
Type | Description |
---|---|
IOrienter |
SaveFileName
File name for saving to and loading from. Defaults to gameObject's name. Use forward slash '/' for subfolders.
Declaration
public string SaveFileName { get; set; }
Property Value
Type | Description |
---|---|
String |
Remarks
Any non-existent file and/or containing folders will be created if possible.
Methods
AddOwnedPin(SpacePin)
Explicitly add a pin to the owned pins list.
Declaration
public bool AddOwnedPin(SpacePin pin)
Parameters
Type | Name | Description |
---|---|---|
SpacePin | pin | THe pin to add. |
Returns
Type | Description |
---|---|
Boolean | True if added, false if it was already there. |
ClaimPinOwnership()
This should be called whenever pins are added to the owned list.
Declaration
public void ClaimPinOwnership()
Remarks
It's only necessary to call this when adding pins to the owned list dynamically from script. It is called from OnEnable for all pins added in the inspector or collected from the scene graph subtree.
ClearOwnedPins()
Clear the entire list of owned space pins.
Declaration
public void ClearOwnedPins()
Remarks
This removes all pins in the list, whether added dynamically or added in the inspector.
Load()
Explicit command to load the alignment manager from store.
Declaration
public bool Load()
Returns
Type | Description |
---|---|
Boolean | True on successful load. |
RemoveOwnedPin(SpacePin)
Remove a specific pin from the owned pins list.
Declaration
public bool RemoveOwnedPin(SpacePin pin)
Parameters
Type | Name | Description |
---|---|---|
SpacePin | pin | The pin to remove. |
Returns
Type | Description |
---|---|
Boolean | True if removed, else false (probably not found). |
Save()
Explicit command to save the alignment manager to store.
Declaration
public bool Save()
Returns
Type | Description |
---|---|
Boolean | True on successful save. |
Events
OnAlignManagerCreated
Fired when a new AlignmentManager has been created throughout CheckInternalWiring
Declaration
public event EventHandler<IAlignmentManager> OnAlignManagerCreated
Event Type
Type | Description |
---|---|
EventHandler<IAlignmentManager> |