Class UnityMaterialApplier
Applies MaterialDelta changes to Unity renderers using MaterialPropertyBlock. Uses per-instance property overrides to avoid polluting shared materials.
Inherited Members
Namespace: Serenity.ProceduralExpression.Infrastructure.Services
Assembly: Serenity.UnityProceduralExpression.Infrastructure.dll
Syntax
public class UnityMaterialApplier
Constructors
UnityMaterialApplier()
Declaration
public UnityMaterialApplier()
Properties
TargetCount
Gets the number of registered targets.
Declaration
public int TargetCount { get; }
Property Value
| Type | Description |
|---|---|
| int |
Methods
Apply(MaterialDelta)
Applies a MaterialDelta to all registered targets. Uses MaterialPropertyBlock for per-instance changes.
Declaration
public void Apply(MaterialDelta delta)
Parameters
| Type | Name | Description |
|---|---|---|
| MaterialDelta | delta | The material delta to apply. |
ClearPropertyBlocks()
Clears all per-instance property overrides from registered targets. Restores renderers to their shared material appearance.
Declaration
public void ClearPropertyBlocks()
ClearTargets()
Clears all registered targets.
Declaration
public void ClearTargets()
RegisterTarget(MaterialId, Renderer, int, int, Color, Material, Shader)
Registers a material target for receiving property changes. Must be called during initialization for each target the layers will affect. Caches material and shader references for runtime change detection.
Declaration
public void RegisterTarget(MaterialId id, Renderer renderer, int materialIndex, int colorPropertyId, Color originalColor, Material material, Shader shader)
Parameters
| Type | Name | Description |
|---|---|---|
| MaterialId | id | The MaterialId used by layers to reference this target. |
| Renderer | renderer | The renderer to affect. |
| int | materialIndex | Material slot index for multi-material renderers. |
| int | colorPropertyId | Cached Shader.PropertyToID for the color property. |
| Color | originalColor | The original color from the sharedMaterial (for blending). |
| Material | material | The material instance to cache (for detecting material changes). |
| Shader | shader | The shader reference to cache (for detecting shader changes). |
UnregisterTarget(MaterialId)
Unregisters a material target.
Declaration
public void UnregisterTarget(MaterialId id)
Parameters
| Type | Name | Description |
|---|---|---|
| MaterialId | id | The MaterialId to unregister. |