Learn how to access custom shader properties using GameDriver
Custom shader properties may need to be accessed sometimes to perform certain checks. In this case, api.CallMethod() can be used to call the respective Get / Set methods from the object's material, just like how they are accessed in Unity.
Shader code
Properties
{
_CustomColorProperty("Custom Color Property", Color) = (1,1,1,1)
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_Glossiness ("Smoothness", Range(0,1)) = 0.5
_Metallic ("Metallic", Range(0,1)) = 0.0
}
Test script code
api.CallMethod<Color>("//*[@name='TestObject']/fn:component('UnityEngine.MeshRenderer')/@material", "GetColor", new object[]{ "_CustomColorProperty" });