Class PrefabMetadata
Container for prefab overrides
Inherited Members
Namespace: Unity.RuntimeSceneSerialization.Prefabs
Syntax
public class PrefabMetadata : MonoBehaviour
Properties
Guid
The guid of this prefab
Declaration
public string Guid { get; set; }
Property Value
| Type | Description |
|---|---|
| String |
Methods
AddComponentOverride(Component)
Add a component as an override to its parent prefab, if one exists
Declaration
public static void AddComponentOverride(Component component)
Parameters
| Type | Name | Description |
|---|---|---|
| Component | component | The component to add |
SetAddedComponent(String, Component)
Add or update a property override to this prefab
Declaration
public void SetAddedComponent(string transformPath, Component addedComponent)
Parameters
| Type | Name | Description |
|---|---|---|
| String | transformPath | The transform path of the GameObject relative to the prefab root |
| Component | addedComponent | The added Component to be applied as an override |
SetAddedGameObject(String, GameObject, SerializationMetadata)
Add a GameObject to this prefab as an override
Declaration
public void SetAddedGameObject(string transformPath, GameObject addedGameObject, SerializationMetadata metadata)
Parameters
| Type | Name | Description |
|---|---|---|
| String | transformPath | The transform path of the GameObject relative to the prefab root |
| GameObject | addedGameObject | The added GameObject to be applied as an override |
| SerializationMetadata | metadata | SerializationMetadata to be used when serializing the scene |
SetPropertyOverride<TValue>(String, String, Int32, TValue, SerializationMetadata)
Add or update a property override to this prefab
Declaration
public void SetPropertyOverride<TValue>(string propertyPath, string transformPath, int componentIndex, TValue value, SerializationMetadata metadata = null)
Parameters
| Type | Name | Description |
|---|---|---|
| String | propertyPath | The path of the property relative to its component |
| String | transformPath | The transform path of the GameObject relative to the prefab root |
| Int32 | componentIndex | The index of the component on the target transform |
| TValue | value | The value to be applied as an override |
| SerializationMetadata | metadata | SerializationMetadata to use for scene object or asset references |
Type Parameters
| Name | Description |
|---|---|
| TValue | The property value type |
SetRemovedComponents(String, Int32)
Remove a component from this prefab as an override
Declaration
public void SetRemovedComponents(string transformPath, int componentIndex)
Parameters
| Type | Name | Description |
|---|---|---|
| String | transformPath | The transform path of the GameObject relative to the prefab root |
| Int32 | componentIndex | The index of the component to be removed as an override |