Instanced Object Link
A component that links a prefab model instance in the scene to an instanced mesh container.
Overview
The InstancedObjectLink
component is designed to link a GameObject to an instance in an InstancedMeshContainer
. It provides functionality for managing the link, including attaching and detaching the link, updating transforms, and querying bounds.
Key Features
Container Management: Attach and detach instances from an
InstancedMeshContainer
.Transform Updates: Synchronize the transform of the link with the instance.
Properties
Container: The container that this instance belongs to.
Instance Index: The index of this instance in the container.
Is Linked: Indicates whether the link points to a valid instance in a container.
Is Logic Only: Indicates whether the link is only used for logic and does not render.
Is Renderable: Indicates whether the link is renderable.
Usage Example
Here's an example of how to use the InstancedObjectLink
component in a script:
Detailed Documentation
Container Management
Attaching to a Container
You can attach the link to a container using the following method:
AttachToContainer(InstancedMeshContainer container, int instanceIndex = -1)
: Attaches the link to the specified container. IfinstanceIndex
is -1, the instance will be added at the current transform of the link.
Detaching from a Container
You can detach the link from a container using the following method:
DetachFromContainer(bool removeInstanceFromContainer = true)
: Detaches the link from the container. IfremoveInstanceFromContainer
is true, the instance will be removed from the container; otherwise, it will remain in the container.
Transform Updates
You can update the transform of the link to match the instance or vice versa using the following methods:
MarkTransformAsDirty()
: Updates the instance's transform to match the link's current transform. This method must be called manually after changing the transform of the link at runtime.TeleportToInstance()
: Refreshes the link's transform to align with its instance. This method is generally called automatically when the instance is updated in the container.
Last updated