New: Nature Shaders

Interaction, Wind, Dynamic Masking, and Better Shading for your vegetation.

Learn more
This page may not work correctly inside the Unity editor. Open in browser

Overlay API

Nature Overlays can be created and edited at runtime using the API described in this article. The overlay can be accessed using the NatureOverlay class, in the following namespace:

using VisualDesignCafe.Nature.Overlay;

Create a new Overlay

To create a new overlay, create a game object and then add a collider component and a Nature Overlay component:

var gameObject = new GameObject( "name" );
var collider = gameObject.AddComponent<BoxCollider>();
var overlay = gameObject.AddComponent<NatureOverlay>();

Refresh Overlay

The colliders and bounds for the overlay are cached and are not updated when adding, removing, or changing colliders. If you change the colliders on the overlay then you have to use "RecalculateBounds" to update the overlay:

// Use "RecalculateBounds" to update the overlay if 
// the colliders on the object changed.
overlay.RecalculateBounds( true );

Edit Overlay

The following properties can be set for the overlay:

var overlay = GetComponent<NatureOverlay>();

// Enable the color overlay, and set the color to red.
overlay.ColorOverlay = true;
overlay.Color = Color.red;

// Use a color texture instead of a solid color for the overlay.
// When set to "true" the texture is used for the color,
// if "false" the color above is used ("red" in this example). overlay.SampleColorTexture = true; overlay.ColorTexture = Texture2D.blackTexture; // Enable the alpha overlay, and set the alpha value. overlay.AlphaOverlay = true; overlay.Alpha = 0f; // Set a mask for the overlay. The overlay is only used
// where the mask texture is white. Set to "null" to
// disable the mask. overlay.Mask = Texture2D.whiteTexture;
Was this article helpful?
0 out of 0 found this helpful