API reference
API reference
Select your platform
No SDKs available
No versions available

ICustomAnchorPrefabSpawner Interface

Defines methods for custom selection, scaling, and alignment of prefabs.
This interface is intended to be implemented by a class that extends AnchorPrefabSpawner, allowing for custom logic to be applied when selecting, scaling, and aligning prefabs. Once the interface is implemented, make sure to set the AnchorPrefabSpawner.SelectionMode, AnchorPrefabSpawner.AlignMode and AnchorPrefabSpawner.ScalingMode to Custom. The prefab selected can also be modified before being returned.
public class CustomPrefabSpawner : AnchorPrefabSpawner {
    public override GameObject CustomPrefabSelection(MRUKAnchor anchor, List<GameObject> prefabs)
    {
        prefabs[0].GetComponentInChildren<Collider>().enabled = true;
        return prefabs[0];
    }
}

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
Vector3 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
Vector3 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
Vector3 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
Vector2 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
GameObject 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.