I have used particles to create a “starfield”.
int numstars = 500;
Particle[] starparticles = GetComponent<ParticleEmitter>().particles;
for(int i = 0; i < numstars; i++)
{
starparticles[i].position = new Vector3(Random.value*10f,Random.value*10f,Random.value* 10f);
starparticles[i].color = new Color(1.0f, 1.0f, 1.0f, 1.0f);
}
GetComponent<ParticleEmitter>().particles = starparticles; // reassign the changed data
To change the colors:
ParticleAnimator particleAni;
particleAni = ((ParticleAnimator)(tmpobj.GetComponentInChildren<ParticleAnimator>()));
Color[] aniColors = particleAni.colorAnimation;
for (int j = 0; j < aniColors.Length;j++)
{
aniColors[j] = Universe.Stars[i].starcolor;
}
particleAni.colorAnimation = aniColors; // das temoräre array auch wieder zuweisen um nicht auf der kopie zu arbeiten die dann verworfen wird
Note that this is for the old/ancient/legacy particle system. Not for Shuriken. But you could look if there are similar possibilities.
And AFAIK particles could also have a world particle collider but I have never messed with this. Maybe that helps to physically simulate them?
The world of particles in Unity is a bit confusing to say at least. There is legacy particles, Shuriken and now Visual FX graph. And there are dozens of custom particle solutions in the store (for GPU too, fe this one ). So If I were OP I would have a look around becauses chances are that there is something close to what you want to achieve.