Unity 3D – On Click – Emit Particles
1. MAIN TOP MENU> GameObject> Create> Other> Cube
2. Hierarchy> select the Cube> Inspector> ‘Add Component’> Effects> Partycle System> UNCHECK ‘Play On Awake’
3. Hierarchy> select the Cube> Inspector> ‘Add Component’> New Script> OnClick.JS
OnClick.JS:
#pragma strict function Start () { } function OnMouseDown () { // When you click over the object // the particle system will emit 5 particles particleSystem.Emit(5); } function Update () { }
NOTICE: the components structure into Inspector will be:
– Cube
– Cube (Mesh Filter)
– Box Collider -> there is no ‘OnMouseDown’ effect without it!
– Mesh Renderer
– Particle System
– OnClick.JS -> it calls particleSystem as effect attached to the Object