API reference

AnchorPrefabSpawner Class

Extends MonoBehaviour

Protected Fields

_random : Random
Signature
Random Meta.XR.MRUtilityKit.AnchorPrefabSpawner._random

Fields

onPrefabSpawned : UnityEvent
Signature
UnityEvent Meta.XR.MRUtilityKit.AnchorPrefabSpawner.onPrefabSpawned
PrefabsToSpawn : List< AnchorPrefabGroup >
Signature
List<AnchorPrefabGroup> Meta.XR.MRUtilityKit.AnchorPrefabSpawner.PrefabsToSpawn
SeedValue : int
Signature
int Meta.XR.MRUtilityKit.AnchorPrefabSpawner.SeedValue
SpawnOnStart : MRUK.RoomFilter
Signature
MRUK.RoomFilter Meta.XR.MRUtilityKit.AnchorPrefabSpawner.SpawnOnStart

Properties

AnchorPrefabSpawnerObjects : Dictionary< MRUKAnchor, GameObject >
[Get]
Signature
Dictionary<MRUKAnchor, GameObject> Meta.XR.MRUtilityKit.AnchorPrefabSpawner.AnchorPrefabSpawnerObjects
SpawnedPrefabs : List< GameObject >
[Get]
Signature
List<GameObject> Meta.XR.MRUtilityKit.AnchorPrefabSpawner.SpawnedPrefabs

Protected Methods

ClearPrefab ( go )
Signature
virtual void Meta.XR.MRUtilityKit.AnchorPrefabSpawner.ClearPrefab(GameObject go)
Parameters
go: GameObject
Returns
void
ClearPrefab ( anchorInfo )
Clears the gameobject associated with the anchor.
Useful when receiving an event that a specific anchor has been removed
Signature
virtual void Meta.XR.MRUtilityKit.AnchorPrefabSpawner.ClearPrefab(MRUKAnchor anchorInfo)
Parameters
anchorInfo: MRUKAnchor  The anchor reference
Returns
void
ClearPrefabs ( room )
Clears all the spawned gameobjects from this AnchorPrefabSpawner in the given room.
Signature
virtual void Meta.XR.MRUtilityKit.AnchorPrefabSpawner.ClearPrefabs(MRUKRoom room)
Parameters
room: MRUKRoom  The room from where to remove all the spawned objects
Returns
void
ClearPrefabs ()
Clears all the gameobjects created with the PrefabSpawner.
Signature
virtual void Meta.XR.MRUtilityKit.AnchorPrefabSpawner.ClearPrefabs()
Returns
void
ReceiveAnchorCreatedEvent ( anchorInfo )
Signature
virtual void Meta.XR.MRUtilityKit.AnchorPrefabSpawner.ReceiveAnchorCreatedEvent(MRUKAnchor anchorInfo)
Parameters
anchorInfo: MRUKAnchor
Returns
void
ReceiveAnchorRemovedCallback ( anchorInfo )
Signature
virtual void Meta.XR.MRUtilityKit.AnchorPrefabSpawner.ReceiveAnchorRemovedCallback(MRUKAnchor anchorInfo)
Parameters
anchorInfo: MRUKAnchor
Returns
void
ReceiveAnchorUpdatedCallback ( anchorInfo )
Signature
virtual void Meta.XR.MRUtilityKit.AnchorPrefabSpawner.ReceiveAnchorUpdatedCallback(MRUKAnchor anchorInfo)
Parameters
anchorInfo: MRUKAnchor
Returns
void
ReceiveCreatedRoom ( room )
Signature
virtual void Meta.XR.MRUtilityKit.AnchorPrefabSpawner.ReceiveCreatedRoom(MRUKRoom room)
Parameters
room: MRUKRoom
Returns
void
ReceiveRemovedRoom ( room )
Signature
virtual void Meta.XR.MRUtilityKit.AnchorPrefabSpawner.ReceiveRemovedRoom(MRUKRoom room)
Parameters
room: MRUKRoom
Returns
void
RegisterAnchorUpdates ( room )
Signature
virtual void Meta.XR.MRUtilityKit.AnchorPrefabSpawner.RegisterAnchorUpdates(MRUKRoom room)
Parameters
room: MRUKRoom
Returns
void
SpawnPrefab ( anchorInfo )
Signature
virtual void Meta.XR.MRUtilityKit.AnchorPrefabSpawner.SpawnPrefab(MRUKAnchor anchorInfo)
Parameters
anchorInfo: MRUKAnchor
Returns
void
SpawnPrefabs ( clearPrefabs )
Spawns prefabs according to the settings.
Signature
virtual void Meta.XR.MRUtilityKit.AnchorPrefabSpawner.SpawnPrefabs(bool clearPrefabs=true)
Parameters
clearPrefabs: bool  Clear already existing prefabs before.
Returns
void
SpawnPrefabs ( room , clearPrefabs )
Creates gameobjects for the given room.
Signature
virtual void Meta.XR.MRUtilityKit.AnchorPrefabSpawner.SpawnPrefabs(MRUKRoom room, bool clearPrefabs=true)
Parameters
room: MRUKRoom  The room reference
clearPrefabs: bool  clear all before adding them again
Returns
void
UnRegisterAnchorUpdates ( room )
Signature
virtual void Meta.XR.MRUtilityKit.AnchorPrefabSpawner.UnRegisterAnchorUpdates(MRUKRoom room)
Parameters
room: MRUKRoom
Returns
void

Methods

CustomPrefabAlignment ( anchorVolumeBounds , prefabBounds )
Aligns a prefab to an anchor's volume, based on custom logic.
This method is intended to be overridden a class that extends AnchorPrefabSpawner with custom logic for aligning a prefab. If not overridden, it throws a NotImplementedException.
Signature
virtual Vector3 Meta.XR.MRUtilityKit.AnchorPrefabSpawner.CustomPrefabAlignment(Bounds anchorVolumeBounds, Bounds? prefabBounds)
Parameters
anchorVolumeBounds: Bounds  The volume bounds of the anchor.
prefabBounds: Bounds?  The bounds of the prefab.
Returns
Vector3  The local position of the prefab defined as the difference between the anchor's pivot and the prefab's pivot.
CustomPrefabAlignment ( anchorPlaneRect , prefabBounds )
Aligns a prefab to an anchor's plane rect, based on custom logic.
This method is intended to be overridden a class that extends AnchorPrefabSpawner with custom logic for aligning a prefab. If not overridden, it throws a NotImplementedException.
Signature
virtual Vector3 Meta.XR.MRUtilityKit.AnchorPrefabSpawner.CustomPrefabAlignment(Rect anchorPlaneRect, Bounds? prefabBounds)
Parameters
anchorPlaneRect: Rect  The volume bounds of the anchor.
prefabBounds: Bounds?  The bounds of the prefab.
Returns
Vector3  The local position of the prefab defined as the difference between the anchor's pivot and the prefab's pivot.
CustomPrefabScaling ( localScale )
Scales a prefab based on custom logic.
This method is intended to be overridden in a class that extends AnchorPrefabSpawner with custom logic for scaling a prefab. If not overridden, it throws a NotImplementedException.
Signature
virtual Vector3 Meta.XR.MRUtilityKit.AnchorPrefabSpawner.CustomPrefabScaling(Vector3 localScale)
Parameters
localScale: Vector3  The local scale of the prefab.
Returns
Vector3  The scaled local scale of the prefab.
CustomPrefabScaling ( localScale )
Scales a prefab based on custom logic.
This method is intended to be overridden a class that extends AnchorPrefabSpawner with custom logic for scaling a prefab. If not overridden, it throws a NotImplementedException.
Signature
virtual Vector2 Meta.XR.MRUtilityKit.AnchorPrefabSpawner.CustomPrefabScaling(Vector2 localScale)
Parameters
localScale: Vector2  The local scale of the prefab.
Returns
Vector2  The scaled local scale of the prefab.
CustomPrefabSelection ( anchor , prefabs )
Selects a prefab based on custom logic.
This method is intended to be overridden in a class that extends AnchorPrefabSpawner with custom logic for selecting a prefab. It will be called whenever the PrefabSelection of an AnchorPrefabGroup is set to Custom.
Signature
virtual GameObject Meta.XR.MRUtilityKit.AnchorPrefabSpawner.CustomPrefabSelection(MRUKAnchor anchor, List< GameObject > prefabs)
Parameters
anchor: MRUKAnchor  The anchor info to use.
prefabs: List< GameObject >  The list of prefabs to select from. Can be null.
Returns
GameObject  The selected prefab.
InitializeRandom ( seed )
Initializes a new instance of the Random class using the current seed.
Signature
void Meta.XR.MRUtilityKit.AnchorPrefabSpawner.InitializeRandom(ref int seed)
Parameters
seed: ref int
Returns
void

Inner Struct

AnchorPrefabGroup Struct

Extends IEquatable< AnchorPrefabGroup >

Fields

Alignment : AlignMode
Signature
AlignMode Meta.XR.MRUtilityKit.AnchorPrefabSpawner.AnchorPrefabGroup.Alignment
CalculateFacingDirection : bool
Signature
bool Meta.XR.MRUtilityKit.AnchorPrefabSpawner.AnchorPrefabGroup.CalculateFacingDirection
IgnorePrefabSize : bool
Signature
bool Meta.XR.MRUtilityKit.AnchorPrefabSpawner.AnchorPrefabGroup.IgnorePrefabSize
Labels : MRUKAnchor.SceneLabels
Signature
MRUKAnchor.SceneLabels Meta.XR.MRUtilityKit.AnchorPrefabSpawner.AnchorPrefabGroup.Labels
MatchAspectRatio : bool
Signature
bool Meta.XR.MRUtilityKit.AnchorPrefabSpawner.AnchorPrefabGroup.MatchAspectRatio
Prefabs : List< GameObject >
Signature
List<GameObject> Meta.XR.MRUtilityKit.AnchorPrefabSpawner.AnchorPrefabGroup.Prefabs
PrefabSelection : SelectionMode
Signature
SelectionMode Meta.XR.MRUtilityKit.AnchorPrefabSpawner.AnchorPrefabGroup.PrefabSelection
Scaling : ScalingMode
Signature
ScalingMode Meta.XR.MRUtilityKit.AnchorPrefabSpawner.AnchorPrefabGroup.Scaling

Methods

Equals ( other )
Signature
bool Meta.XR.MRUtilityKit.AnchorPrefabSpawner.AnchorPrefabGroup.Equals(AnchorPrefabGroup other)
Parameters
other: AnchorPrefabGroup
Returns
bool
Equals ( obj )
Signature
override bool Meta.XR.MRUtilityKit.AnchorPrefabSpawner.AnchorPrefabGroup.Equals(object obj)
Parameters
obj: object
Returns
override bool
GetHashCode ()
Signature
override int Meta.XR.MRUtilityKit.AnchorPrefabSpawner.AnchorPrefabGroup.GetHashCode()
Returns
override int

Static Methods

operator!= ( left , right )
Signature
static bool Meta.XR.MRUtilityKit.AnchorPrefabSpawner.AnchorPrefabGroup.operator!=(AnchorPrefabGroup left, AnchorPrefabGroup right)
Parameters
left: AnchorPrefabGroup
right: AnchorPrefabGroup
Returns
bool
operator== ( left , right )
Signature
static bool Meta.XR.MRUtilityKit.AnchorPrefabSpawner.AnchorPrefabGroup.operator==(AnchorPrefabGroup left, AnchorPrefabGroup right)
Parameters
left: AnchorPrefabGroup
right: AnchorPrefabGroup
Returns
bool

Inner Enums

ScalingMode Enum

Enumeration Constants

MemberDescription
Stretch
Stretch each axis to exactly match the size of the Plane/Volume.
UniformScaling
Scale each axis by the same amount to maintain the correct aspect ratio.
UniformXZScale
Scale the X and Z axes uniformly but the Y scale can be different.
NoScaling
Don't perform any scaling.
Custom
Custom logic, extend this class and override CustomPrefabScaling with your own implementation.

AlignMode Enum

Enumeration Constants

MemberDescription
Automatic
For volumes align to the base, for planes align to the center.
Bottom
Align the bottom of the prefab with the bottom of the volume or plane.
Center
Align the center of the prefab with the center of the volume or plane.
NoAlignment
Don't add any local offset to the prefab.
Custom
Custom logic, extend this class and override CustomPrefabAlignment with your own implementation.

SelectionMode Enum

Enumeration Constants

MemberDescription
Random
ClosestSize
Custom
Custom logic, extend this class and override CustomPrefabSelection with your own implementation.