private static ParticleSystem.MinMaxCurve ScaleMinMaxCurve(ParticleSystem.MinMaxCurve curve, float scale) { curve.curveMultiplier *= scale; curve.constantMin *= scale; curve.constantMax *= scale; ScaleCurve(curve.curveMin, scale); ScaleCurve(curve.curveMax, scale); return(curve); }
// Start is called before the first frame update void Start() { rain = GetComponent <ParticleSystem>(); main = rain.main; emission = rain.emission; baseRate = emission.rateOverTime; baseSpeed = main.startSpeed; baseSize = main.startSize.constant; }
public void Evaluate(float t) { var curve = new ParticleSystem.MinMaxCurve(); curve.constantMin = modifier.Evaluate(t) * startCurve.constantMin; curve.constantMax = modifier.Evaluate(t) * startCurve.constantMax; curve.mode = startCurve.mode; setCurve.Invoke(curve); }
private static ParticleSystem.MinMaxCurve ScaleMinMaxCurve2(ParticleSystem.MinMaxCurve curve, float scale) { var nex = default(ParticleSystem.MinMaxCurve); nex.curveMultiplier = curve.curveMultiplier * scale; nex.constantMin = curve.constantMin * scale; nex.constantMax = curve.constantMax * scale; return(nex); }
void Start() { currentLayer = particleLayer; gameObject.layer = LayerMask.NameToLayer("ParticleLayer" + particleLayer); particleLayer = ((particleLayer + 1) % 20) + 1; rb = GetComponent <Rigidbody2D>(); if (rb == null) { rb = gameObject.AddComponent <Rigidbody2D>(); rb.gravityScale = 0; } ps = GetComponent <ParticleSystem>(); var emit = ps.emission; emit.rateOverTime = 0; var psNoise = ps.noise; noisyNoise = psNoise.strength; noiseStartEnabled = psNoise.enabled; var psCollision = ps.collision; psCollision.collidesWith = (int.MaxValue ^ (1 << LayerMask.NameToLayer("ParticleLayer" + currentLayer))); print("my layer: " + LayerMask.NameToLayer("ParticleLayer" + currentLayer)); Debug.Log("Is noise enabled on start?" + psNoise.enabled); if (currentShape == null) { SetShape(FormType.Ball); } var psFol = ps.forceOverLifetime; initialForce = new Vector3(); initialForce.x = psFol.x.Evaluate(0); initialForce.y = psFol.y.Evaluate(0); initialForce.z = psFol.z.Evaluate(0); var psVol = ps.velocityOverLifetime; psVol.enabled = false; var psLvol = ps.limitVelocityOverLifetime; psLvol.enabled = false; var psMain = ps.main; psMain.simulationSpace = ParticleSystemSimulationSpace.World; MeshFilter mf = gameObject.AddComponent <MeshFilter>(); MeshRenderer mr = gameObject.AddComponent <MeshRenderer>(); mr.sharedMaterial = new Material(Shader.Find("Standard")); mr.enabled = false; mf.mesh = currentShape.GetMesh(); }
private ParticleSystem.MinMaxCurve Multiply(ParticleSystem.MinMaxCurve minMaxCurve, float mul) { minMaxCurve.curveMultiplier *= mul; minMaxCurve.constant *= mul; minMaxCurve.constantMin *= mul; minMaxCurve.constantMax *= mul; return(minMaxCurve); }
private void Awake() { player = GameObject.FindGameObjectWithTag("Player"); rb = GetComponent <Rigidbody2D>(); coll = GetComponent <BoxCollider2D>(); attackEmission = attackParticle.emission; standardEmissionRate = attackEmission.rateOverDistance; attackEmission.rateOverDistance = 0f; }
void Update() { float newEmissionRate = (float)alphaScore; emissionModule = ps.emission; ParticleSystem.MinMaxCurve tempCurve = emissionModule.rateOverTime; tempCurve.constant = newEmissionRate; emissionModule.rateOverTime = tempCurve; }
private void Update() { foreach (ParticleSystem particle in particles) { var main = particle.main; ParticleSystem.MinMaxCurve curve = new ParticleSystem.MinMaxCurve(scale); main.startSize = curve; } }
private void DrawParticleMesh( ParticleSystem.Particle particle, VertexHelper vh, ParticleSystem.MinMaxCurve frameOverTime, bool isWorldSimulationSpace, ParticleSystem.TextureSheetAnimationModule textureSheetAnimationModule, Vector3[] verts, int[] triangles, Vector2[] uvs) { var center = particle.position; var rotation = Quaternion.Euler(particle.rotation3D); if (isWorldSimulationSpace) { center = rectTransform.InverseTransformPoint(center); } float timeAlive = particle.startLifetime - particle.remainingLifetime; float globalTimeAlive = timeAlive / particle.startLifetime; Vector3 size3D = particle.GetCurrentSize3D(ParticleSystem); Color32 color32 = particle.GetCurrentColor(ParticleSystem); Vector2 uv0; Vector2 uv1; Vector2 uv2; Vector2 uv3; CalculateUvs(particle, frameOverTime, textureSheetAnimationModule, timeAlive, out uv0, out uv1, out uv2, out uv3); var currentVertCount = vh.currentVertCount; for (int j = 0; j < verts.Length; j++) { Vector3 pos = verts[j]; pos.x *= size3D.x; pos.y *= size3D.y; pos.z *= size3D.z; pos = rotation * pos + center; var uvXpercent = uvs[j].x; var uvYpercent = uvs[j].y; var newUvx = Mathf.Lerp(uv0.x, uv2.x, uvXpercent); var newUvy = Mathf.Lerp(uv0.y, uv2.y, uvYpercent); vh.AddVert(pos, color32, new Vector2(newUvx, newUvy)); } for (int i = 0; i < triangles.Length; i += 3) { vh.AddTriangle(currentVertCount + triangles[i], currentVertCount + triangles[i + 1], currentVertCount + triangles[i + 2]); } }
public YoooMinMaxCurve(ParticleSystem.MinMaxCurve curve) { Data = curve; constantMax = Data.constantMax; constantMin = Data.constantMin; curveMax = Data.curveMax; curveMin = Data.curveMin; curveScalar = Data.curveScalar; mode = Data.mode; }
public static void SetEmissionRate(float emissionRate, params ParticleSystem[] particleSystem) { for (int i = 0; i < particleSystem.Length; i++) { ParticleSystem.EmissionModule emission = particleSystem[i].emission; ParticleSystem.MinMaxCurve rate = emission.rateOverTime.constantMax; rate.constantMax = emissionRate; emission.rateOverTime = rate; } }
/// <param name="curve"></param> /// <param name="samples">Must be 2 or higher</param> public SampledMinMaxCurve(ParticleSystem.MinMaxCurve curve, int samples) { sampledFloat = new NativeArray <float>(samples, Allocator.Persistent); float timeStep = 1f / (samples - 1); for (int i = 0; i < samples; i++) { sampledFloat[i] = curve.Evaluate(i * timeStep); } }
internal void SetNumberOfPersons(int n) { numberOfpersons = n; var em = transform.GetChild(0).GetComponent <ParticleSystem>().emission; var rate = new ParticleSystem.MinMaxCurve(); rate.constantMin = n / 30f; rate.constantMax = n / 30f; em.rate = rate; }
private IEnumerator ResetMinMaxCurve(ParticleSystem ps, ParticleSystem.MinMaxCurve curve) { while (ps.isEmitting) { yield return(null); } ParticleSystem.MainModule main = ps.main; main.startSize = curve; }
IEnumerator ApplyVolumeCurve(AudioSource audioSource, ParticleSystem.MinMaxCurve volume) { AudioClip originalClip = audioSource.clip; while (audioSource != null && audioSource.isPlaying && audioSource.clip == originalClip) { audioSource.volume = volume.Evaluate(Mathf.Clamp(audioSource.time / audioSource.clip.length, 0, 1)); yield return(null); } }
private JSONObject ParseConstant(ParticleSystem.MinMaxCurve curveData, float num) { JSONObject res = new JSONObject(JSONObject.Type.OBJECT); JSONObject data = new JSONObject(JSONObject.Type.OBJECT); res.AddField("type", "Constant"); res.AddField("data", data); data.AddField("value", curveData.constant * num); return(res); }
public void Convert() { Curve = new ParticleSystem.MinMaxCurve(1, ACurve, ACurve); ITestOutputHelper output = new StringTestOutputHelper(); var serializer = new SerializerBuilder().Build(); var yaml = serializer.Serialize(Curve); output.WriteLine(yaml); Debug.Log(output); }
private void CalmParticleEffect() { foreach (ParticleSystem particle in _backgroundParticles) { ParticleSystem.EmissionModule module = particle.emission; ParticleSystem.MinMaxCurve rate = new ParticleSystem.MinMaxCurve(); rate.constantMax = _calmEmission; module.rateOverTime = rate; } }
private void Start() { base.Start(); DEFAULT_STEPPING_FREQUENCY = SteppingFrequency; DEFAULT_PARTICLE_LIFETIME = _particleSystem.main.startLifetime; _transform = GetComponent <Transform> (); SavePosition(); }
public void SetPersons(int newPersons) { persons = newPersons; var em = core.GetComponent <ParticleSystem>().emission; var rate = new ParticleSystem.MinMaxCurve(); rate.constantMin = persons / 30f; rate.constantMax = persons / 30f; em.rate = rate; }
private JSONObject ParseCurve(ParticleSystem.MinMaxCurve curveData, float multiplier) { JSONObject res = new JSONObject(JSONObject.Type.OBJECT); JSONObject data = new JSONObject(JSONObject.Type.OBJECT); res.AddField("type", "Curve"); res.AddField("data", data); data.AddField("curve", GetCurveData(curveData.curve, curveData.curveMultiplier * multiplier)); return(res); }
private void SetEmission() { ParticleSystem.MinMaxCurve newRate = new ParticleSystem.MinMaxCurve { constant = originalROT * (vitality / 100) }; var emission = particles.emission; emission.rateOverTime = newRate.constant; }
/// <summary> /// (获得最大粒子时长) ParticleSystem.MinMaxCurve 扩充 /// </summary> /// <param name="minMaxCurve"></param> /// <returns></returns> public static float YGetMaxValue(this ParticleSystem.MinMaxCurve minMaxCurve) { float maxCurve = 0; switch (minMaxCurve.mode) { case ParticleSystemCurveMode.Constant: maxCurve = minMaxCurve.constant; break; case ParticleSystemCurveMode.Curve: for (int j = 0; j < minMaxCurve.curve.keys.Length; j++) { if (minMaxCurve.curve.keys[j].value > maxCurve) { maxCurve = minMaxCurve.curve.keys[j].value; } } break; case ParticleSystemCurveMode.TwoConstants: if (minMaxCurve.constantMax > minMaxCurve.constantMin) { maxCurve = minMaxCurve.constantMax; } else { maxCurve = minMaxCurve.constantMin; } break; case ParticleSystemCurveMode.TwoCurves: for (int j = 0; j < minMaxCurve.curveMax.keys.Length; j++) { if (minMaxCurve.curveMax.keys[j].value > maxCurve) { maxCurve = minMaxCurve.curveMax.keys[j].value; } } for (int j = 0; j < minMaxCurve.curveMin.keys.Length; j++) { if (minMaxCurve.curveMin.keys[j].value > maxCurve) { maxCurve = minMaxCurve.curveMin.keys[j].value; } } break; } return(maxCurve); }
public void Init(GridCell from, GridCell to) { transform.position = GridManager.CellToWorldPos(from); ParticleSystem.MinMaxCurve curveX = new ParticleSystem.MinMaxCurve(); ParticleSystem.MinMaxCurve curveZ = new ParticleSystem.MinMaxCurve(); curveX.constant = (from.columnPos - to.columnPos) * -velOverTimeStart; curveZ = (from.rowPos - to.rowPos) * velOverTimeStart; velOverLifeTime.x = curveX; velOverLifeTime.z = curveZ; }
private void SetVelocity(ParticleSystem ps, Vector3 vel) { ParticleSystem.VelocityOverLifetimeModule v = ps.velocityOverLifetime; ParticleSystem.MinMaxCurve velocityCurve = new ParticleSystem.MinMaxCurve(); velocityCurve.constantMax = vel.x; v.x = velocityCurve; velocityCurve.constantMax = vel.y; v.y = velocityCurve; velocityCurve.constantMax = vel.z; v.z = velocityCurve; }
// Start is called before the first frame update void Start() { pSys = GetComponent <ParticleSystem>(); var main = pSys.main; var originalLifetime = main.startLifetime; ParticleSystem.MinMaxCurve burstLifetime = new ParticleSystem.MinMaxCurve(0.0f, 30.0f); main.startLifetime = burstLifetime; pSys.Emit(300); main.startLifetime = originalLifetime; }
private void Awake() { psMain = ps.main; psShape = ps.shape; psVelOverLife = ps.velocityOverLifetime; baseConstant = ps.main.startSize.constant; baseMinMax = ps.main.startSize; baseShapeSize = ps.shape.radius; baseShapePosition = ps.shape.position; baseShapeRotation = ps.shape.rotation; }
private JSONObject ParseTwoConstants(ParticleSystem.MinMaxCurve curveData, float multiplier) { JSONObject res = new JSONObject(JSONObject.Type.OBJECT); JSONObject data = new JSONObject(JSONObject.Type.OBJECT); res.AddField("type", "TwoConstants"); res.AddField("data", data); data.AddField("max", curveData.constantMax * multiplier); data.AddField("min", curveData.constantMin * multiplier); return(res); }
private JSONObject ParseTwoCurves(ParticleSystem.MinMaxCurve curveData) { JSONObject res = new JSONObject(JSONObject.Type.OBJECT); JSONObject data = new JSONObject(JSONObject.Type.OBJECT); res.AddField("type", "TwoCurves"); res.AddField("data", data); data.AddField("max", GetCurveData(curveData.curveMax, curveData.curveMultiplier)); data.AddField("min", GetCurveData(curveData.curveMin, curveData.curveMultiplier)); return(res); }