Materials that are using Nature Shaders can be easily edited at runtime using the API in this article. The material can be accessed using the NatureMaterial class in the following namespace:
Edit a Material
To edit a material, create a new NatureMaterial instance for the material. The NatureMaterial class is a wrapper to edit the material, it does not create a copy of the material.
var natureMaterial = new NatureMaterial( material );
After creating the nature material, you can edit the properties directly through the Nature Material class. There is no need to check if a property is supported/enabled for the material, unsupported properties are automatically ignored.
For example, to change the color of the material use the following code:
natureMaterial.Tint = Color.red;
After changing the properties, the material needs to be applied and validated to ensure that the correct shader keywords are set.
Note: It is recommended to pass "false" as the parameter to the Validate method when editing the material at runtime. Using "true" will clear the existing settings, which may cause issues at runtime.
natureMaterial.Validate( false );
Manually Checking Material Properties
If, for any reason, you need to check the material properties or keywords without using the NatureMaterial class, then you can do so with the help of the NatureProperties and NatureKeywords classes.
The NatureProperties class contains the names of all material properties.
if( material.HasProperty( NatureProperties.Tint ) ) material.SetColor( NatureProperties.Tint, Color.red );
The NatureKeywords class contains all the keywords that are used by Nature Shaders.
material.EnableKeyword( NatureKeywords.AlphaTest );