Flora
Flora 6
Flora 6
  • Overview
  • Getting Started
  • Shaders and Materials
  • Tools
  • Rendering
    • Occlusion
  • Requirements
  • Components
    • Instanced Prototype
    • Instanced Mesh Container
    • Instanced Object Link
    • Instanced Terrain Foliage
    • Instancing Camera Settings
    • Instancing Scene Settings
Powered by GitBook
On this page
  • Overview
  • Key Features
  • Properties
  • Usage Example
  • Detailed Documentation
  • Container Management
  • Transform Updates
  1. Components

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:

using UnityEngine;
using MA.Flora;

public class Example : MonoBehaviour
{
    public InstancedObjectLink objectLink;
    public InstancedMeshContainer container;

    void Start()
    {
        // Attach the link to the container
        objectLink.AttachToContainer(container);

        // Update the instance's transform to match the link's current transform
        objectLink.MarkTransformAsDirty();

        // Refresh the link's transform to align with its instance
        objectLink.TeleportToInstance();
    }
}

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. If instanceIndex 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. If removeInstanceFromContainer 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.

PreviousInstanced Mesh ContainerNextInstanced Terrain Foliage

Last updated 11 months ago

Page cover image