Skip to main content

BottledLiquid

A class in Root.Township, Alta.Liquid.

Liquid surface visual for bottles: sets a fill plane on the bottle's shader from how full it is, following the liquid's up direction.

Constructors​

MemberWhat it is
BottledLiquid()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

7 private and internal fields
MemberWhat it is
private Transform dynamicRendererTransformTransform of the liquid renderer.
private float finalLevelThe fill height last worked out.
private static BottleLiquidMaterialCreator materialCreatorShared creator for the bottle liquid material and its shader properties.
private float maximumYHighest mesh point, relative to the renderer.
private Mesh meshThe bottle liquid mesh.
private float minimumYLowest mesh point, relative to the renderer.
private Vector3[] verticesCached vertices of the mesh.

Methods​

MemberWhat it is
protected override void Awake()Caches the bottle mesh vertices (skipped on a headless server).
protected override void SetLODRendererPropertyBlockFromLiquid(MaterialPropertyBlock propertyBlock, LiquidData liquid)Sets the liquid colour on the LOD renderer's property block.
protected override void SetPropertyBlockFromLiquid(MaterialPropertyBlock propertyBlock, LiquidData liquid)Sets the liquid colour on the renderer's property block.
protected override Material SetupMaterialFromLiquidVisualSettings(LiquidVisualData visualSettings, Material materialTemplate)Creates the bottle liquid material from the visual settings.
protected override void UpdateVisual()Works out the fill height between the mesh's lowest and highest points and sends it to the shader.
1 private and internal method
MemberWhat it is
private void EvaluateBounds()Finds the lowest and highest point of the mesh in world height.