Hi there!
I’m trying to change the color of a material attached to a prefab. Well, let me explain the current issue better:
When this prefab is instantiated, it activates a particle system… and this particle system uses an specific material, as following:
Captura de Tela 2018 01 03 a s 11 32 43 hosted at ImgBB — ImgBB (I tried to attach the image here, but it didn’t work)
So, my prefab has the 3 following components: Transform / Particle System / StarMaterial (a material I created).
I tried something like:
myPrefab.GetComponent ().GetComponent ().color = new Color32 (251, 10, 67, 255);
But it didn’t work. I don’t know how can I access my StarMaterial component to change its color.
Could you try to help me? Maybe I’m missing some basic concept.
Any hints are welcome.
Thanks.
UPDATE:
I tried this:
Renderer r = prefabParticleSystemBounceBasicCircle.GetComponent ();
foreach(Material material in r.sharedMaterials)
{
if(material != null){
if(material.name == “StarMaterial”){
matt.color = new Color32 (251, 10, 67, 255);
}
}
}
Still missing something I can’t figure out now…