LiquidStencilShaderController
A class in Root.Township, Alta.Liquid.
Client: gives a liquid container's volume and surface renderers a stencil number from a shared pool while it's visible and has liquid, and releases it otherwise.
- Listed in Stats, effects, heat and liquid
- Inherits or implements
MonoBehaviour
Constructors
| Member | What it is |
|---|---|
LiquidStencilShaderController() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
8 private and internal fields
| Member | What it is |
|---|---|
private ILiquidContainer container | The liquid container on this object. |
private bool isStencilAssigned | Whether a stencil number is held. |
private int stencilNumber | The held stencil number. |
private Renderer surfaceRenderer | Liquid surface renderer. |
private MaterialPropertyBlock surfaceRendererPropertyBlock | The surface visual's property block. |
private Renderer volumeRenderer | Liquid volume renderer. |
private MaterialPropertyBlock volumeRendererPropertyBlock | Property block for the volume renderer. |
private VisibilityDetector volumeVisibilityDetector | Tells when the volume becomes visible or not. |
Methods
9 private and internal methods
| Member | What it is |
|---|---|
private void Awake() | Gets the container and listens for its surface material changing. |
private void CheckForStencil() | Takes a stencil number when visible with liquid, otherwise releases it. |
private void HandleLiquidLevelChanged(ILiquidContainer container) | Rechecks the stencil when the shown amount changes. |
private void OnDisable() | Unhooks the liquid level and visibility events. |
private void OnEnable() | Hooks the liquid level and visibility events. |
private void ReleaseStencilBufferNumber() | Gives the stencil number back to the pool. |
private void SetRenderersStencilBufferNumber(bool isForced) | Takes a stencil number (if none or forced) and sets it on both materials. |
private void Start() | Checks the stencil and sets up property blocks. |
private void UpdateStencilOnNewMaterial() | Assigns a fresh stencil number when the surface material is replaced. |