Obi Official Forum
Scripting color changes - Printable Version

+- Obi Official Forum (https://obi.virtualmethodstudio.com/forum)
+-- Forum: Obi Users Category (https://obi.virtualmethodstudio.com/forum/forum-1.html)
+--- Forum: Obi Fluid (https://obi.virtualmethodstudio.com/forum/forum-3.html)
+--- Thread: Scripting color changes (/thread-3934.html)



Scripting color changes - glipkowitz - 13-07-2023

I would like a script that changes the color of an Obi fluid emitter. Sorry for the newby question, I'm new...


RE: Scripting color changes - josemendez - 14-07-2023

(13-07-2023, 05:47 PM)glipkowitz Wrote: I would like a script that changes the color of an Obi fluid emitter. Sorry for the newby question, I'm new...

Hi there,

I'd recommend learning C# before moving on to more advanced subjects like fluid simulation, otherwise you'll get stuck at quite literally every step of the way.

Particle color is a public property of the ObiParticleRenderer component, so you can set it like you would normally in Unity: get a reference to the component, and set the property:

Code:
public class ChangeColor : MonoBehaviour
{

   public ObiEmitter emitter;

   public void Awake()
   {
      emitter.GetComponent<ObiParticleRenderer>().particleColor = new Color (1,0,0,1);
   }
}

kind regards,