set_asset_reference
Assigns a Unity asset (material, texture, prefab, audio clip, or ScriptGraphAsset) to an object-reference field on a scene component by path or GUID, with optional type checking and clearing.
Instructions
Assign a Unity project asset to an object-reference field on a scene component. Use this for ScriptGraphAsset, material, texture, audio clip, prefab, and other AssetDatabase references. Native serialized properties are preferred. Guarded nested CLR paths are also supported for custom serializers; use nest.macro for Unity.VisualScripting.ScriptMachine. Select the asset by Assets/... or Packages/... path, or by its 32-character Unity GUID. Set clear=true to remove the reference. Exactly one of assetPath, assetGuid, or clear=true is accepted. expectedAssetType provides an optional fail-closed type check. Requires BanterMCPBridge extension.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| clear | No | Set true to clear the asset reference | |
| objectId | No | Preferred: source GameObject globalObjectId from scene-hierarchy.json | |
| assetGuid | No | Unity asset GUID, normally returned by search_unity_assets | |
| assetPath | No | Unity asset path under Assets/ or Packages/ | |
| objectPath | No | Legacy path selector for the GameObject containing the component | |
| componentId | No | Preferred: component globalObjectId from scene-hierarchy.json | |
| propertyName | Yes | Object-reference path (for example, 'material' or ScriptMachine's custom-serialized 'nest.macro') | |
| componentType | No | Component type name when it is unique on the object | |
| expectedAssetType | No | Optional exact or assignable Unity type (for example, Unity.VisualScripting.ScriptGraphAsset) |