void UpdateMaterial() { if (material == null) { return; } Vector2 position = Vector2.zero; int joystickState = 0; float[] lifetimes = new float[maxDrops]; Vector4[] origins = new Vector4[maxDrops]; RippleDroplet droplet = null; for (int i = 0; i < maxDrops; i++) { if (i <= (droplets.Count - 1)) { droplet = droplets[i]; } else { droplet = null; } lifetimes[i] = (droplet == null)? 0f:droplet.lifetime; origins[i] = (droplet == null)? Vector2.zero:droplet.origin; } joystickState = (joystick != null)? (joystick as MovementJoystick).state:0; position = (joystick != null)? joystick.Direction:Vector2.zero; material.SetInt(stateEnumName, joystickState); material.SetVector(inputPosName, new Vector4(position.x, position.y, 0f, 0f)); material.SetFloatArray(lifetimesArrName, lifetimes); material.SetVectorArray(originsArrName, origins); }
void AddDroplet() { RippleDroplet droplet = new RippleDroplet(joystick.position, dropLifetime); droplets.Add(droplet); }