Stylized Water 2 – Underwater Rendering docs

Stylized Water 2 - Underwater Rendering (Extension)

Stylized Water 2 - Underwater Rendering (Extension)
Version: 1.0.5

6.Scripting #

Familiarity with C# and OOP programming is assumed. Support cannot be extended to coding help. Most specific functionality and use cases really need to be handled on a project-specific basis

As far as scripting is concerned, underwater rendering is fairly straightforward. The Underwater Renderer component is always set up with a specific water material and water level. This is in turn required for its functionality.

If you are using an assembly definition, ensure you add a reference to the sc.stylizedwater2.runtime assembly, otherwise you won’t be able to access the StylizedWater2 namespace and classes.

Public static functions

These functions are primarily in place to accommodate worlds with more than one water body, and varying water levels.

They must be used, since they also trigger functionality that updates shader properties.

StylizedWater2.UnderwaterRenderer.SetCurrentWaterLevel (Transform or Float input)

You could, for example, use these functions to alter the water- material and level, based on Box Collider triggers. An example script can be viewed here.

Usage notes

  • The component is a faux-Singleton, and can be accessed through UnderwaterRenderer.Instance (it can be null if not present!).
  • You can change any public fields on the component directly (eg. water level or fog). Though this must be followed up by calling UpdateProperties() to ensure the values are also passed on to shaderland.
  • The static UnderwaterRenderer.EnableRendering boolean can be freely toggled (true by default).
Yes No Suggest edit
Last updated on May 12, 2022
1 of 1 users found this section helpful
Suggest Edit