I want to set the color of "Particle System" that I add to a game object in run time. Both game object and particle system are created in run time too.
I have the following code that works well on PC when I run it... But the problem is that in "Android" builds, color does not set correctly and particles are always "pink".
It should be:
But in Android it seen as:
Here is the code I use:
GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);
sphere.transform.position = new Vector3(x, y, z);
sphere.AddComponent<ParticleSystem>();
var ps = sphere.GetComponent<ParticleSystem>();
ps.startLifetime = 1;
ps.startSpeed = 0.01f;
ps.startSize = 0.03f;
ps.maxParticles = 10000;
ParticleSystemExtension.SetEmissionRate(ps, 10000);
var sh = ps.shape;
sh.shapeType = ParticleSystemShapeType.Circle;
sh.radius = 0.69f;
var cbl = ps.colorOverLifetime;
cbl.enabled = true;
Color mater = Color.green;
cbl.color = new ParticleSystem.MinMaxGradient(mater);