Unity Reflect Viewer API
Pipeline Overview
The Pipeline API is used to convert Reflect models into Unity GameObjects at runtime. It's also used to sync any changes happening at the same time to the original CAD model source.
Reflect models are represented by different types of ISyncModel:
- SyncObjectInstance represents an object in the model with its transform and metadata.
- SyncMesh, SyncTexture and SyncMaterials represent the different types of asset that can be used by a SyncObjectInstance.
The Pipeline API uses a node-based approach where each node manipulates Reflect models in order to filter or convert them. As in any node-based API, the pipeline can be extended and customized using new nodes or by changing the pipeline connection structure.
Pipelines can be saved into Assets and reused across multiple Scenes and Projects.
Nodes communicate between each other using Stream Events:
- StreamBegin: Beginning of a batch of StreamEvents.
- StreamEvents: Add/Changed/Removed
- StreamEnd: End of the batch
Pipeline diagram
Nodes
Node | Description |
---|---|
ProjectStreamer | Reads a Reflect Project content and streams the data as lightweight entries (Type, BoundingBox); reacts to live changes in the Reflect Project and streams the deltas. |
SyncInstanceProvider | Gets a more detailed description of the instance (Transform, Metadata, Dependencies). |
DataProvider | Loads all the dependencies of a given SyncInstance and streams them to the rest of the pipeline; manages the data so no duplicate information is loaded. The dependencies are SyncObjects, SyncMeshes, SyncTextures and SyncMaterials. |
MeshConverter, MaterialConverter, TextureConverter | Convert the Reflect data into a Unity Object. |
InstanceConverter | The last node that generates the final GameObject representing the SyncInstance. |
Running a Reflect Pipeline
PipelineAsset is a ScriptableObject that contains the ReflectNodes and connections that describe the Reflect pipeline.
ReflectPipeline is a MonoBehaviour that takes a PipelineAsset. When assigning a PipelineAsset to the ReflectPipeline, the inspector displays all public and serializable fields found in the pipeline nodes.
The method ReflectPipeline.InitializeAndRefreshPipeline can start the Pipeline.
If there are any changes to the data after the PipelineAsset is started, ReflectPipeline.RefreshPipeline can trigger a refresh.