Scripting¶
Resources¶
Crest does not use the Resources folder. Instead a scriptable object which holds the references to all our compute and internal shaders is stored on the Water Renderer. This will tell Unity to include these files in a standalone build.
If instantiating the Water Renderer via scripting in builds, and there is no reference to a Water Renderer in the scene (including via prefab), then you must add a reference to the Resources asset in a scene to include all the necessary assets in the build. The Resources asset will not include shaders that are exposed in the shader selection for materials.
Scripting API¶
Please see the API section in the sidebar.
Water Singleton¶
If you need a reference to the WaterRenderer, it can be obtained via the singleton WaterRenderer.Instance.
Assemblies¶
When using Assembly Definitions, there are two extra assemblies that need to be referenced: Shared and Scripting. The former is required to compile correctly, while the latter is optional.
The Scripting assembly provides extension methods necessary to adding input components:
// Add the foam input with the texture mode.
var input = gameObject.AddComponent<FoamLodInput>(LodInputMode.Texture);
// Retrieve the texture mode data and assign a texture.
var data = input.GetData<FoamTextureLodInputData>();
data.Texture = texture;