unity_component_set_reference
Set an object reference on a component property by specifying a scene GameObject, asset path, or instance ID. Resolves references more accurately than general property setters for wiring GameObjects, components, and assets.
Instructions
Set an object reference on a component property. Dedicated tool for wiring references between GameObjects, components, and assets. More powerful than set_property for ObjectReference fields — supports resolution by asset path, scene GameObject name, component type, or instance ID.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | No | Hierarchy path or name of the target GameObject | |
| instanceId | No | Instance ID of the target GameObject (alternative to path) | |
| componentType | No | Component type containing the property (optional — will auto-search all components) | |
| propertyName | Yes | Name of the ObjectReference property to set | |
| assetPath | No | Asset path to assign (e.g. 'Assets/Materials/MyMat.mat', 'Assets/Prefabs/Enemy.prefab') | |
| referenceGameObject | No | Name or hierarchy path of a scene GameObject to assign | |
| referenceComponentType | No | When referencing a scene object, get a specific component instead of the GameObject itself (e.g. 'Camera', 'AudioSource') | |
| referenceInstanceId | No | Instance ID of the object to assign | |
| clear | No | Set to true to clear/null the reference | |
| port | No | Target Unity instance port for parallel-safe routing. Get this from unity_select_instance. When working with multiple Unity instances, ALWAYS include this parameter. |