private void OnEnable() { if (targets.Length == 1) { FastSoftParticle _target = (FastSoftParticle)target; ParticleSystemRenderer particleSystemRenderer = _target.GetComponent <ParticleSystemRenderer>(); if (particleSystemRenderer.AreVertexStreamsEnabled(ParticleSystemVertexStreams.Custom1) == false) { Undo.RecordObject(_target, "EnableVertexStreams,ParticleSystemVertexStreams.Custom1"); particleSystemRenderer.EnableVertexStreams(ParticleSystemVertexStreams.Custom1); } } }
void Start() { ps = GetComponent <ParticleSystem>(); psr = GetComponent <ParticleSystemRenderer>(); // emit in a sphere with no speed var main = ps.main; main.startSpeedMultiplier = 0.0f; main.simulationSpace = ParticleSystemSimulationSpace.World; // so our particle positions don't require any extra transformation, to compare with the mouse position var emission = ps.emission; emission.rateOverTimeMultiplier = 200.0f; var shape = ps.shape; shape.shapeType = ParticleSystemShapeType.Sphere; shape.radius = 400.0f; shape.texture = Resources.Load <Texture2D>("WaterDropParticle.tif"); psr.sortMode = ParticleSystemSortMode.YoungestInFront; // send custom data to the shader psr.EnableVertexStreams(ParticleSystemVertexStreams.Custom1); psr.material = m; }