Class ShapeMaterialCache
Lazily creates and caches the shared default UnityEngine.Material instances used by all ScyllaShapeBase3D subclasses. Two variants are exposed: a standard URP Lit material and a double-sided variant (backface culling disabled).
Inherited Members
Namespace: Scylla.Core.Util.Geom
Assembly: ScyllaCore.dll
Syntax
public static class ShapeMaterialCache
Remarks
All shapes that have not been assigned a custom material share these cached instances. Per-shape coloring is layered on top via UnityEngine.MaterialPropertyBlock so applying a tint does not allocate a new material and does not break SRP batching for the affected renderer beyond what the property block already implies.
The cached materials are marked UnityEngine.HideFlags.HideAndDontSave so they do not appear in the project window and are not serialized into scenes.
Methods
ApplyTint(Renderer, Color)
Applies a UnityEngine.MaterialPropertyBlock to renderer that
sets the material's base color property to color. Avoids
leaking new material instances, but prevents SRP batching for the affected renderer.
Declaration
public static void ApplyTint(Renderer renderer, Color color)
Parameters
| Type | Name | Description |
|---|---|---|
| Renderer | renderer | The renderer whose property block is set. Null is a no-op. |
| Color | color | The color value written into the base color property. |
Remarks
The property is _BaseColor (URP and HDRP Lit, and the shape vertex-lit
shader). When the renderer's shared material has no _BaseColor but has
_Color (the Built-in Standard shader), _Color is written
instead. A shader with neither property ignores the tint.
ClearTint(Renderer)
Clears any per-renderer color override previously applied via ApplyTint(Renderer, Color). After this call the renderer falls back to the material's intrinsic color.
Declaration
public static void ClearTint(Renderer renderer)
Parameters
| Type | Name | Description |
|---|---|---|
| Renderer | renderer | The renderer whose property block is cleared. Null is a no-op. |
GetDefault()
Returns the shared default URP Lit UnityEngine.Material used by all shape
renderers that have not been assigned a custom material. Falls back to the
Built-in Standard shader if URP is not present.
Declaration
public static Material GetDefault()
Returns
| Type | Description |
|---|---|
| Material | The cached default material, or |
GetDoubleSided()
Returns the shared double-sided variant of the default material. Backface culling is
disabled by setting the _Cull shader property to 0. Use this for flat
meshes (planes, quads, single-sided floor tiles) whose winding may not match the
viewing direction.
Declaration
public static Material GetDoubleSided()
Returns
| Type | Description |
|---|---|
| Material | The cached double-sided material, or |
GetVertexLit()
Returns the shared vertex-lit UnityEngine.Material backed by the
Scylla/Core/ShapeVertexLit shader, which multiplies the per-renderer
_BaseColor tint by the mesh's per-vertex color channel. Used by shapes that
emit per-face vertex colors via an IFaceColorResolver. Falls back to
GetDefault() when the vertex-lit shader cannot be located.
Declaration
public static Material GetVertexLit()
Returns
| Type | Description |
|---|---|
| Material | The cached vertex-lit material, or the default material if the shader is missing. |
GetVertexLitDoubleSided()
Returns the shared double-sided variant of the vertex-lit material. Backface culling
is disabled by setting the _Cull shader property to 0.
Declaration
public static Material GetVertexLitDoubleSided()
Returns
| Type | Description |
|---|---|
| Material | The cached double-sided vertex-lit material, or the vertex-lit material if it could not be created. |
IsCachedShapeMaterial(Material)
Returns true when material is one of the shared cached
materials this class hands out (default, double-sided, vertex-lit, or vertex-lit
double-sided). Used by ScyllaShapeBase3D to decide whether it may swap
the renderer's material without clobbering a user-assigned custom material.
Declaration
public static bool IsCachedShapeMaterial(Material material)
Parameters
| Type | Name | Description |
|---|---|---|
| Material | material | The material to test. Null returns |
Returns
| Type | Description |
|---|---|
| bool |
|