void start()
{
Color color = new Color(0.5f, 0.5f, 0.1f, 0.8f);
//Fetch the Renderer from the GameObject
Renderer rend = GetComponent<Renderer>();
//Set the main Color of the Material to green
rend.material.shader = Shader.Find("_Color");
rend.material.SetColor("_Color", color);
}
But it generates an Hidden/InternalShaderError error in the shader. Can anyone point me in the right direction?
public class MaterialTest : MonoBehaviour
{
[SerializeField]
public Material myMaterial;
//public GameObject Sphere;
[SerializeField]
public Renderer rend;
[SerializeField]
public Color red = new Color(255, 0.4f, 0.6f, 255f);
// Start is called before the first frame update
void Start()
{
//Set the main Color of the Material to green
rend.material.shader = Shader.Find("HDRP/Lit");
rend.material.SetColor("_BaseColor", red);
}