River Modeler Documentation

River Modeler

River Modeler
Version: 1.0.1
Review

5.Scripting #

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

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

Whenever using the API, ensure you add using sc.modeling.river.runtime; to include the namespace.

Events

There are two events to subscribe to, that fire before the river is rebuild and after…
RiverModeler.onPostRebuildRiver += OnRiverRebuild;
RiverModeler.onPreRebuildRiver += OnRiverRebuild;

The accompanying method has two parameters

  • The instance being rebuild
  • The change flags, to indicate which aspect is being rebuild
private void OnRiverRebuild(RiverModeler instance, RiverModeler.ChangeFlags updateFlags)
{
    if (updateFlags.HasFlag(RiverModeler.ChangeFlags.Geometry))
    {
        DoSomething();
    }
}

Never call the Rebuild function from these methods! This creates an infinite loop.

Geometry generation

The sc.modeling.river.runtime.Geometry.Create() function takes in all the parameters required to generate a river mesh from a spline. This is what the River component uses.

This is for advanced use cases where rivers are created in a completely procedural manner.

Yes No Suggest edit
Last updated on February 29, 2024
0 of 0 users found this section helpful
Suggest Edit