02-11-2021, 02:35 PM
So is it something like this?
This gives me the correct color which is 0,1,0 Green in that case. But GetComponent calls so much. Is it actually the most optimized way to get particle color or am I missing something over here?
I tried this too but it gives me 1,1,1 White color. I have fluid renderer in the scene on MainCamera and (On ObiEmitter object) Obi Particle Renderer has green color 0,1,0.
Code:
private void OnCollision(object sender, Obi.ObiSolver.ObiCollisionEventArgs e)
{
var world = ObiColliderWorld.GetInstance();
foreach (Oni.Contact contact in e.contacts)
{
if (contact.distance < 0.01)
{
ObiColliderBase col = world.colliderHandles[contact.bodyB].owner;
if (col.CompareTag("Detect"))
{
int particleIndex = _obiSolver.simplices[contact.bodyA];
ObiSolver.ParticleInActor pa = _obiSolver.particleToActor[particleIndex];
ObiEmitter emitter = pa.actor as ObiEmitter;
Color color = emitter.GetComponent<ObiParticleRenderer>().particleColor;
Debug.Log(color);
}
}
}
}
This gives me the correct color which is 0,1,0 Green in that case. But GetComponent calls so much. Is it actually the most optimized way to get particle color or am I missing something over here?
I tried this too but it gives me 1,1,1 White color. I have fluid renderer in the scene on MainCamera and (On ObiEmitter object) Obi Particle Renderer has green color 0,1,0.
Code:
private void OnCollision(object sender, Obi.ObiSolver.ObiCollisionEventArgs e)
{
var world = ObiColliderWorld.GetInstance();
foreach (Oni.Contact contact in e.contacts)
{
if (contact.distance < 0.01)
{
ObiColliderBase col = world.colliderHandles[contact.bodyB].owner;
if (col.CompareTag("Detect"))
{
int particleIndex = _obiSolver.simplices[contact.bodyA];
ObiSolver.ParticleInActor pa = _obiSolver.particleToActor[particleIndex];
ObiEmitter emitter = pa.actor as ObiEmitter;
Color color = pa.actor.GetParticleColor(particleIndex);
Debug.Log(color);
}
}
}
}