public override void ReadFrom(object obj) { base.ReadFrom(obj); if (obj == null) { return; } ParticleSystem.CustomDataModule o = (ParticleSystem.CustomDataModule)obj; m_mode1 = o.GetMode(ParticleSystemCustomData.Custom1); m_mode2 = o.GetMode(ParticleSystemCustomData.Custom2); m_color1 = o.GetColor(ParticleSystemCustomData.Custom1); m_color2 = o.GetColor(ParticleSystemCustomData.Custom2); m_vectorComponentCount1 = o.GetVectorComponentCount(ParticleSystemCustomData.Custom1); m_vectorComponentCount2 = o.GetVectorComponentCount(ParticleSystemCustomData.Custom2); if (m_vectorComponentCount1 > 0) { m_vectors1 = new ParticleSystem.MinMaxCurve[m_vectorComponentCount1]; for (int i = 0; i < m_vectors1.Length; ++i) { m_vectors1[i] = o.GetVector(ParticleSystemCustomData.Custom1, i); } } if (m_vectorComponentCount2 > 0) { m_vectors2 = new ParticleSystem.MinMaxCurve[m_vectorComponentCount2]; for (int i = 0; i < m_vectors2.Length; ++i) { m_vectors2[i] = o.GetVector(ParticleSystemCustomData.Custom2, i); } } }
protected override void InitialiseIfNeeded() { base.InitialiseIfNeeded(); if (_particleCustomData == null) { for (int i = 0; i < _materials.Length; i++) { _animationTexture.SetMaterialProperties(_materials[i]); } _mesh = AnimationTexture.AddExtraMeshData(_mesh, 4); _particleCurrentFrame = new float[_particles.Length]; _particleCustomData = new List <Vector4>(_particles.Length); ParticleSystem.CustomDataModule customData = _particleSystem.customData; customData.SetMode(_customDataChannel, ParticleSystemCustomDataMode.Vector); customData.SetVector(_customDataChannel, 0, new ParticleSystem.MinMaxCurve(kDefaultData.x)); customData.SetVector(_customDataChannel, 1, new ParticleSystem.MinMaxCurve(kDefaultData.y)); customData.SetVector(_customDataChannel, 2, new ParticleSystem.MinMaxCurve(kDefaultData.z)); customData.SetVector(_customDataChannel, 3, new ParticleSystem.MinMaxCurve(kDefaultData.w)); } }
protected override void SetUpComponents() { base.SetUpComponents(); main = observedComponent.main; custom = observedComponent.customData; UpdateColor(); }
protected override object WriteToImpl(object obj) { obj = base.WriteToImpl(obj); ParticleSystem.CustomDataModule uo = (ParticleSystem.CustomDataModule)obj; uo.enabled = enabled; return(uo); }
protected virtual void GetParticleSystem() { _particleSystem = GetComponentInChildren <ParticleSystem>(); particleRenderer = GetComponentInChildren <ParticleSystemRenderer>(); // Modules - for ease of access mainModule = _particleSystem.main; collisionModule = _particleSystem.collision; colorBySpeedModule = _particleSystem.colorBySpeed; colorOverTimeModule = _particleSystem.colorOverLifetime; customDataModule = _particleSystem.customData; emissionModule = _particleSystem.emission; externalForcesModule = _particleSystem.externalForces; forceOverTimeModule = _particleSystem.forceOverLifetime; inheritVelocityModule = _particleSystem.inheritVelocity; lightsModule = _particleSystem.lights; limitVelocityOverTimeModule = _particleSystem.limitVelocityOverLifetime; noiseModule = _particleSystem.noise; rotationBySpeedModule = _particleSystem.rotationBySpeed; sizeBySpeedModule = _particleSystem.sizeBySpeed; sizeOverTimeModule = _particleSystem.sizeOverLifetime; trailModule = _particleSystem.trails; triggerModule = _particleSystem.trigger; shapeModule = _particleSystem.shape; velOverTimeModule = _particleSystem.velocityOverLifetime; }
public override void GetDepsFrom(object obj, GetDepsFromContext context) { base.GetDepsFrom(obj, context); ParticleSystem.CustomDataModule o = (ParticleSystem.CustomDataModule)obj; int count = o.GetVectorComponentCount(ParticleSystemCustomData.Custom1); for (int i = 0; i < count; ++i) { AddSurrogateDeps(o.GetVector(ParticleSystemCustomData.Custom1, i), v_ => (PersistentParticleSystemNestedMinMaxCurve)v_, context); } count = o.GetVectorComponentCount(ParticleSystemCustomData.Custom2); for (int i = 0; i < count; ++i) { AddSurrogateDeps(o.GetVector(ParticleSystemCustomData.Custom2, i), v_ => (PersistentParticleSystemNestedMinMaxCurve)v_, context); } }
public override object WriteTo(object obj) { obj = base.WriteTo(obj); if (obj == null) { return(null); } ParticleSystem.CustomDataModule o = (ParticleSystem.CustomDataModule)obj; o.SetMode(ParticleSystemCustomData.Custom1, m_mode1); o.SetMode(ParticleSystemCustomData.Custom1, m_mode2); if (m_mode1 == ParticleSystemCustomDataMode.Color) { o.SetColor(ParticleSystemCustomData.Custom1, m_color1); } else if (m_mode1 == ParticleSystemCustomDataMode.Vector) { o.SetVectorComponentCount(ParticleSystemCustomData.Custom1, m_vectorComponentCount1); for (int i = 0; i < m_vectorComponentCount1; ++i) { o.SetVector(ParticleSystemCustomData.Custom1, i, m_vectors1[i]); } } if (m_mode2 == ParticleSystemCustomDataMode.Color) { o.SetColor(ParticleSystemCustomData.Custom2, m_color2); } else if (m_mode2 == ParticleSystemCustomDataMode.Vector) { o.SetVectorComponentCount(ParticleSystemCustomData.Custom2, m_vectorComponentCount2); for (int i = 0; i < m_vectorComponentCount2; ++i) { o.SetVector(ParticleSystemCustomData.Custom2, i, m_vectors2[i]); } } return(obj); }
private void MapCustomDataParameters(ParticleSystem pSystem, int i) { ParticleSystem.CustomDataModule customDataModule = pSystem.customData; try { customDataModule.enabled = GetBoolParam(i, "customData_enabled"); } catch (NullReferenceException) { customDataModule.enabled = false; return; } customDataModule.SetMode(ParticleSystemCustomData.Custom1, ParticleSystemCustomDataMode.Vector); customDataModule.SetMode(ParticleSystemCustomData.Custom2, ParticleSystemCustomDataMode.Vector); customDataModule.SetVector(ParticleSystemCustomData.Custom1, 0, GetFloatParam(i, "customData_1", 0)); customDataModule.SetVector(ParticleSystemCustomData.Custom1, 0, GetFloatParam(i, "customData_1", 1)); customDataModule.SetVector(ParticleSystemCustomData.Custom1, 0, GetFloatParam(i, "customData_1", 2)); customDataModule.SetVector(ParticleSystemCustomData.Custom1, 0, GetFloatParam(i, "customData_1", 3)); customDataModule.SetVector(ParticleSystemCustomData.Custom2, 0, GetFloatParam(i, "customData_1", 0)); customDataModule.SetVector(ParticleSystemCustomData.Custom2, 0, GetFloatParam(i, "customData_1", 1)); customDataModule.SetVector(ParticleSystemCustomData.Custom2, 0, GetFloatParam(i, "customData_1", 2)); customDataModule.SetVector(ParticleSystemCustomData.Custom2, 0, GetFloatParam(i, "customData_1", 3)); }
internal ParticleElementTemplate(ParticleElement element) { this.element = element; this.partSys = element.partSys; this.partRend = element.partRend; this.main = this.partSys.main; this.collision = this.partSys.collision; this.collision.enabled = false; this.colorBySpeed = this.partSys.colorBySpeed; this.colorBySpeed.enabled = false; this.colorOverLifetime = this.partSys.colorOverLifetime; this.colorOverLifetime.enabled = false; this.customData = this.partSys.customData; this.customData.enabled = false; this.emission = this.partSys.emission; this.emission.enabled = false; this.externalForces = this.partSys.externalForces; this.externalForces.enabled = false; this.forceOverLifetime = this.partSys.forceOverLifetime; this.forceOverLifetime.enabled = false; this.inheritVelocity = this.partSys.inheritVelocity; this.inheritVelocity.enabled = false; this.lights = this.partSys.lights; this.lights.enabled = false; this.limitVelocityOverLifetime = this.partSys.limitVelocityOverLifetime; this.limitVelocityOverLifetime.enabled = false; this.noise = this.partSys.noise; this.noise.enabled = false; this.rotationBySpeed = this.partSys.rotationBySpeed; this.rotationBySpeed.enabled = false; this.rotationOverLifetime = this.partSys.rotationOverLifetime; this.rotationOverLifetime.enabled = false; this.shape = this.partSys.shape; this.shape.enabled = false; this.sizeBySpeed = this.partSys.sizeBySpeed; this.sizeBySpeed.enabled = false; this.sizeOverLifetime = this.partSys.sizeOverLifetime; this.sizeOverLifetime.enabled = false; this.subEmitters = this.partSys.subEmitters; this.subEmitters.enabled = false; this.textureSheetAnimation = this.partSys.textureSheetAnimation; this.textureSheetAnimation.enabled = false; this.trails = this.partSys.trails; this.trails.enabled = false; this.trigger = this.partSys.trigger; this.trigger.enabled = false; this.velocityOverLifetime = this.partSys.velocityOverLifetime; this.velocityOverLifetime.enabled = false; }
internal static GameObject CreatePlasmaBurnPrefab() { var obj = PrefabsCore.CreatePrefab("PlasmaBurn", false); var holder = new GameObject("Particles"); holder.transform.parent = obj.transform; var mainPs = holder.AddComponent <ParticleSystem>(); var mainPsr = holder.AddOrGetComponent <ParticleSystemRenderer>(); mainPs .BurnMain() .BurnEmission() .BurnShape() .BurnCOL() .BurnSOL(); mainPsr .BurnRenderer(); ParticleSystem.VelocityOverLifetimeModule mainPsVol = mainPs.velocityOverLifetime; mainPsVol.enabled = false; ParticleSystem.LimitVelocityOverLifetimeModule mainPsLvol = mainPs.limitVelocityOverLifetime; mainPsLvol.enabled = false; ParticleSystem.InheritVelocityModule mainPsIvel = mainPs.inheritVelocity; mainPsIvel.enabled = false; ParticleSystem.ForceOverLifetimeModule mainPsFol = mainPs.forceOverLifetime; mainPsFol.enabled = false; ParticleSystem.ColorBySpeedModule mainPsCbs = mainPs.colorBySpeed; mainPsCbs.enabled = false; ParticleSystem.SizeBySpeedModule mainPsSbs = mainPs.sizeBySpeed; mainPsSbs.enabled = false; ParticleSystem.RotationOverLifetimeModule mainPsRol = mainPs.rotationOverLifetime; mainPsRol.enabled = false; ParticleSystem.RotationBySpeedModule mainPsRbs = mainPs.rotationBySpeed; mainPsRbs.enabled = false; ParticleSystem.ExternalForcesModule mainPsExt = mainPs.externalForces; mainPsExt.enabled = false; ParticleSystem.NoiseModule mainPsNoise = mainPs.noise; mainPsNoise.enabled = false; ParticleSystem.CollisionModule mainPsColl = mainPs.collision; mainPsColl.enabled = false; ParticleSystem.TriggerModule mainPsTrig = mainPs.trigger; mainPsTrig.enabled = false; ParticleSystem.SubEmittersModule mainPsSub = mainPs.subEmitters; mainPsSub.enabled = false; ParticleSystem.TextureSheetAnimationModule mainPsTex = mainPs.textureSheetAnimation; mainPsTex.enabled = false; ParticleSystem.LightsModule mainPsLigh = mainPs.lights; mainPsLigh.enabled = false; ParticleSystem.TrailModule mainPsTrail = mainPs.trails; mainPsTrail.enabled = false; ParticleSystem.CustomDataModule mainPsData = mainPs.customData; mainPsData.enabled = false; return(obj); }
internal static GameObject CreateSmallAmmoTracer(Material mainMat, Material trailMat) { GameObject obj = PrefabsCore.CreatePrefab("Standard Tracer", false); Transform tracerHead = new GameObject("TracerHead").transform; tracerHead.parent = obj.transform; tracerHead.localPosition = Vector3.zero; tracerHead.localRotation = Quaternion.identity; //tracerHead.localEulerAngles = new Vector3( 0f, 90f, 0f ); tracerHead.localScale = Vector3.one; Transform tracerTail = new GameObject("TracerTail").transform; tracerTail.parent = obj.transform; tracerTail.localPosition = Vector3.zero; tracerTail.localRotation = Quaternion.identity; tracerTail.localScale = Vector3.one; Transform trail = new GameObject("trail").transform; trail.parent = tracerTail; trail.localPosition = Vector3.zero; trail.localRotation = Quaternion.identity; trail.localScale = Vector3.one; Transform headBeam = new GameObject("HeadBeam").transform; headBeam.parent = tracerTail; headBeam.localPosition = Vector3.zero; headBeam.localEulerAngles = new Vector3(0f, 90f, 0f); headBeam.localScale = Vector3.one; EffectComponent effectComp = obj.AddComponent <EffectComponent>(); Tracer tracer = obj.AddComponent <Tracer>(); VFXAttributes vfxAtrib = obj.AddComponent <VFXAttributes>(); Rigidbody headRb = tracerHead.AddComponent <Rigidbody>(); Rigidbody tailRb = tracerTail.AddComponent <Rigidbody>(); ParticleSystem mainPs = headBeam.AddComponent <ParticleSystem>(); ParticleSystemRenderer mainPsr = headBeam.AddOrGetComponent <ParticleSystemRenderer>(); ParticleSystem trailPs = trail.AddComponent <ParticleSystem>(); ParticleSystemRenderer trailPsr = trail.AddOrGetComponent <ParticleSystemRenderer>(); DestroyTracerOnDelay cleanup = obj.AddComponent <DestroyTracerOnDelay>(); cleanup.delay = 2f; cleanup.tracer = tracer; ZeroTracerLengthOverDuration zeroLength = obj.AddComponent <ZeroTracerLengthOverDuration>(); zeroLength.tracer = tracer; DestroyOnTimer timer = obj.AddComponent <DestroyOnTimer>(); timer.duration = 10f; effectComp.effectIndex = EffectIndex.Invalid; effectComp.positionAtReferencedTransform = false; effectComp.parentToReferencedTransform = false; effectComp.applyScale = false; effectComp.soundName = null; effectComp.disregardZScale = false; tracer.startTransform = null; tracer.beamObject = null; tracer.beamDensity = 0f; tracer.speed = 600f; tracer.headTransform = tracerHead; tracer.tailTransform = tracerTail; tracer.length = 20f; tracer.reverse = false; headRb.isKinematic = true; headRb.useGravity = false; tailRb.isKinematic = true; tailRb.useGravity = false; vfxAtrib.optionalLights = null; vfxAtrib.secondaryParticleSystem = null; vfxAtrib.vfxIntensity = VFXAttributes.VFXIntensity.Low; vfxAtrib.vfxPriority = VFXAttributes.VFXPriority.Always; mainPs.PlayOnStart(); mainPs.SetupSmallTracerMain(); mainPs.SetupSmallTracerEmission(); mainPs.SetupSmallTracerShape(); mainPs.SetupSmallTracerColorOverLifetime(); mainPs.SetupSmallTracerSizeOverLifetime(); mainPsr.SetupSmallTracerRenderer(mainMat); ParticleSystem.VelocityOverLifetimeModule mainPsVol = mainPs.velocityOverLifetime; mainPsVol.enabled = false; ParticleSystem.LimitVelocityOverLifetimeModule mainPsLvol = mainPs.limitVelocityOverLifetime; mainPsLvol.enabled = false; ParticleSystem.InheritVelocityModule mainPsIvel = mainPs.inheritVelocity; mainPsIvel.enabled = false; ParticleSystem.ForceOverLifetimeModule mainPsFol = mainPs.forceOverLifetime; mainPsFol.enabled = false; ParticleSystem.ColorBySpeedModule mainPsCbs = mainPs.colorBySpeed; mainPsCbs.enabled = false; ParticleSystem.SizeBySpeedModule mainPsSbs = mainPs.sizeBySpeed; mainPsSbs.enabled = false; ParticleSystem.RotationOverLifetimeModule mainPsRol = mainPs.rotationOverLifetime; mainPsRol.enabled = false; ParticleSystem.RotationBySpeedModule mainPsRbs = mainPs.rotationBySpeed; mainPsRbs.enabled = false; ParticleSystem.ExternalForcesModule mainPsExt = mainPs.externalForces; mainPsExt.enabled = false; ParticleSystem.NoiseModule mainPsNoise = mainPs.noise; mainPsNoise.enabled = false; ParticleSystem.CollisionModule mainPsColl = mainPs.collision; mainPsColl.enabled = false; ParticleSystem.TriggerModule mainPsTrig = mainPs.trigger; mainPsTrig.enabled = false; ParticleSystem.SubEmittersModule mainPsSub = mainPs.subEmitters; mainPsSub.enabled = false; ParticleSystem.TextureSheetAnimationModule mainPsTex = mainPs.textureSheetAnimation; mainPsTex.enabled = false; ParticleSystem.LightsModule mainPsLight = mainPs.lights; mainPsLight.enabled = false; ParticleSystem.TrailModule mainPsTrail = mainPs.trails; mainPsTrail.enabled = false; ParticleSystem.CustomDataModule mainPsData = mainPs.customData; mainPsData.enabled = false; trailPs.PlayOnStart(); trailPs.SetupSmallTracerTrailMain(); trailPs.SetupSmallTracerTrailEmission(); trailPs.SetupSmallTracerTrailNoise(); trailPs.SetupSmallTracerTrailTrail(); trailPsr.SetupSmallTracerTrailRenderer(trailMat); ParticleSystem.ShapeModule trailPsShape = trailPs.shape; trailPsShape.enabled = false; ParticleSystem.VelocityOverLifetimeModule trailPsVol = trailPs.velocityOverLifetime; trailPsVol.enabled = false; ParticleSystem.LimitVelocityOverLifetimeModule trailPsLvol = trailPs.limitVelocityOverLifetime; trailPsLvol.enabled = false; ParticleSystem.InheritVelocityModule trailPsIvel = trailPs.inheritVelocity; trailPsIvel.enabled = false; ParticleSystem.ForceOverLifetimeModule trailPsFol = trailPs.forceOverLifetime; trailPsFol.enabled = false; ParticleSystem.ColorOverLifetimeModule trailPsCol = trailPs.colorOverLifetime; trailPsCol.enabled = false; ParticleSystem.ColorBySpeedModule trailPsCbs = trailPs.colorBySpeed; trailPsCbs.enabled = false; ParticleSystem.SizeOverLifetimeModule trailPsSol = trailPs.sizeOverLifetime; trailPsSol.enabled = false; ParticleSystem.SizeBySpeedModule trailPsSbs = trailPs.sizeBySpeed; trailPsSbs.enabled = false; ParticleSystem.RotationOverLifetimeModule trailPsRol = trailPs.rotationOverLifetime; trailPsRol.enabled = false; ParticleSystem.RotationBySpeedModule trailPsRbs = trailPs.rotationBySpeed; trailPsRbs.enabled = false; ParticleSystem.ExternalForcesModule trailPsExt = trailPs.externalForces; trailPsExt.enabled = false; ParticleSystem.NoiseModule trailPsNoise = trailPs.noise; trailPsNoise.enabled = true; ParticleSystem.CollisionModule trailPsColl = trailPs.collision; trailPsColl.enabled = false; ParticleSystem.TriggerModule trailPsTrig = trailPs.trigger; trailPsTrig.enabled = false; ParticleSystem.SubEmittersModule trailPsSub = trailPs.subEmitters; trailPsSub.enabled = false; ParticleSystem.TextureSheetAnimationModule trailPsTex = trailPs.textureSheetAnimation; trailPsTex.enabled = false; ParticleSystem.LightsModule trailPsLigh = trailPs.lights; trailPsLigh.enabled = false; ParticleSystem.CustomDataModule trailPsData = trailPs.customData; trailPsData.enabled = false; return(obj); }
private static void BasicSetup(ParticleSystem ps) { ParticleSystem.EmissionModule ps1Emission = ps.emission; ps1Emission.enabled = false; ParticleSystem.ShapeModule ps1Shape = ps.shape; ps1Shape.enabled = false; ParticleSystem.VelocityOverLifetimeModule ps1VOL = ps.velocityOverLifetime; ps1VOL.enabled = false; ParticleSystem.LimitVelocityOverLifetimeModule ps1LimVOL = ps.limitVelocityOverLifetime; ps1LimVOL.enabled = false; ParticleSystem.InheritVelocityModule ps1InhVel = ps.inheritVelocity; ps1InhVel.enabled = false; ParticleSystem.ForceOverLifetimeModule ps1FOL = ps.forceOverLifetime; ps1FOL.enabled = false; ParticleSystem.ColorOverLifetimeModule ps1COL = ps.colorOverLifetime; ps1COL.enabled = false; ParticleSystem.ColorBySpeedModule ps1CBS = ps.colorBySpeed; ps1CBS.enabled = false; ParticleSystem.SizeOverLifetimeModule ps1SOL = ps.sizeOverLifetime; ps1SOL.enabled = false; ParticleSystem.SizeBySpeedModule ps1SBS = ps.sizeBySpeed; ps1SBS.enabled = false; ParticleSystem.RotationOverLifetimeModule ps1ROL = ps.rotationOverLifetime; ps1ROL.enabled = false; ParticleSystem.RotationBySpeedModule ps1RBS = ps.rotationBySpeed; ps1RBS.enabled = false; ParticleSystem.ExternalForcesModule ps1ExtFor = ps.externalForces; ps1ExtFor.enabled = false; ParticleSystem.NoiseModule ps1Noise = ps.noise; ps1Noise.enabled = false; ParticleSystem.CollisionModule ps1Collis = ps.collision; ps1Collis.enabled = false; ParticleSystem.TriggerModule ps1Trig = ps.trigger; ps1Trig.enabled = false; ParticleSystem.SubEmittersModule ps1SubEmit = ps.subEmitters; ps1SubEmit.enabled = false; ParticleSystem.TextureSheetAnimationModule ps1TexAnim = ps.textureSheetAnimation; ps1TexAnim.enabled = false; ParticleSystem.LightsModule ps1Light = ps.lights; ps1Light.enabled = false; ParticleSystem.TrailModule ps1Trails = ps.trails; ps1Trails.enabled = false; ParticleSystem.CustomDataModule ps1Cust = ps.customData; ps1Cust.enabled = false; }
public override object WriteTo(object obj) { obj = base.WriteTo(obj); if (obj == null) { return(null); } ParticleSystem.CustomDataModule o = (ParticleSystem.CustomDataModule)obj; o.SetMode(ParticleSystemCustomData.Custom1, m_mode1); o.SetMode(ParticleSystemCustomData.Custom1, m_mode2); if (m_mode1 == ParticleSystemCustomDataMode.Color) { if (m_color1 != null) { ParticleSystem.MinMaxGradient grad = new ParticleSystem.MinMaxGradient(); m_color1.WriteTo(grad); o.SetColor(ParticleSystemCustomData.Custom1, grad); } } else if (m_mode1 == ParticleSystemCustomDataMode.Vector) { o.SetVectorComponentCount(ParticleSystemCustomData.Custom1, m_vectorComponentCount1); if (m_vectors1 != null) { for (int i = 0; i < m_vectorComponentCount1; ++i) { if (m_vectors1[i] != null) { ParticleSystem.MinMaxCurve v = new ParticleSystem.MinMaxCurve(); m_vectors1[i].WriteTo(v); o.SetVector(ParticleSystemCustomData.Custom1, i, v); } } } } if (m_mode2 == ParticleSystemCustomDataMode.Color) { if (m_color2 != null) { ParticleSystem.MinMaxGradient grad = new ParticleSystem.MinMaxGradient(); m_color2.WriteTo(grad); o.SetColor(ParticleSystemCustomData.Custom2, grad); } } else if (m_mode2 == ParticleSystemCustomDataMode.Vector) { o.SetVectorComponentCount(ParticleSystemCustomData.Custom2, m_vectorComponentCount2); if (m_vectors2 != null) { for (int i = 0; i < m_vectorComponentCount2; ++i) { if (m_vectors2[i] != null) { ParticleSystem.MinMaxCurve v = new ParticleSystem.MinMaxCurve(); m_vectors2[i].WriteTo(v); o.SetVector(ParticleSystemCustomData.Custom2, i, v); } } } } return(obj); }
protected override void ReadFromImpl(object obj) { base.ReadFromImpl(obj); ParticleSystem.CustomDataModule uo = (ParticleSystem.CustomDataModule)obj; enabled = uo.enabled; }
private void SetupFlameParticleSystem(ParticleSystem ps, Int32 skinIndex, FlamePSInfo psi) { ParticleSystem.MainModule main = ps.main; main.duration = 1f; main.loop = true; main.prewarm = false; main.startDelay = 0f; main.startLifetime = new ParticleSystem.MinMaxCurve { mode = ParticleSystemCurveMode.Constant, constant = 0.65f }; main.startSpeed = new ParticleSystem.MinMaxCurve { mode = ParticleSystemCurveMode.Constant, constant = psi.startSpeed }; main.startSize3D = false; main.startSize = new ParticleSystem.MinMaxCurve { mode = ParticleSystemCurveMode.Constant, constant = psi.startSize * 0.75f }; main.startRotation3D = false; main.startRotation = new ParticleSystem.MinMaxCurve { mode = ParticleSystemCurveMode.TwoConstants, constantMin = 0f, constantMax = 360f }; main.flipRotation = 0f; main.startColor = new ParticleSystem.MinMaxGradient { mode = ParticleSystemGradientMode.Color, color = new Color(1f, 1f, 1f, 1f) }; main.gravityModifier = new ParticleSystem.MinMaxCurve { mode = ParticleSystemCurveMode.Constant, constant = psi.gravity }; main.simulationSpace = ParticleSystemSimulationSpace.Local; main.simulationSpeed = 1f; main.useUnscaledTime = false; main.scalingMode = ParticleSystemScalingMode.Local; main.playOnAwake = true; main.emitterVelocityMode = ParticleSystemEmitterVelocityMode.Transform; main.maxParticles = 1000; main.stopAction = ParticleSystemStopAction.None; main.cullingMode = ParticleSystemCullingMode.AlwaysSimulate; main.ringBufferMode = ParticleSystemRingBufferMode.Disabled; ParticleSystem.EmissionModule emission = ps.emission; emission.enabled = true; emission.rateOverTime = new ParticleSystem.MinMaxCurve { mode = ParticleSystemCurveMode.Constant, constant = 10f }; emission.rateOverDistance = new ParticleSystem.MinMaxCurve { mode = ParticleSystemCurveMode.Constant, constant = 0f }; emission.rateOverDistanceMultiplier = 0f; emission.rateOverTimeMultiplier = psi.rate; ParticleSystem.ShapeModule shape = ps.shape; shape.enabled = true; shape.shapeType = ParticleSystemShapeType.Cone; shape.angle = 38.26f; shape.radius = psi.radius * 0.75f; shape.radiusThickness = 1f; shape.arc = 360f; shape.arcMode = ParticleSystemShapeMultiModeValue.Random; shape.arcSpread = 0f; shape.position = psi.position; shape.rotation = psi.rotation; shape.scale = psi.scale; shape.alignToDirection = false; ParticleSystem.VelocityOverLifetimeModule velOverLife = ps.velocityOverLifetime; velOverLife.enabled = false; ParticleSystem.LimitVelocityOverLifetimeModule limVelOverLife = ps.limitVelocityOverLifetime; limVelOverLife.enabled = false; ParticleSystem.InheritVelocityModule inheritVel = ps.inheritVelocity; inheritVel.enabled = false; ParticleSystem.ForceOverLifetimeModule forceOverLife = ps.forceOverLifetime; forceOverLife.enabled = false; ParticleSystem.ColorOverLifetimeModule colorOverLife = ps.colorOverLifetime; colorOverLife.enabled = true; colorOverLife.color = new ParticleSystem.MinMaxGradient { mode = ParticleSystemGradientMode.Gradient, gradient = new Gradient { mode = GradientMode.Blend, colorKeys = new GradientColorKey[1] { new GradientColorKey(new Color(1f, 1f, 1f), 0f) }, alphaKeys = new GradientAlphaKey[4] { new GradientAlphaKey(0f, 0f), new GradientAlphaKey(0.9f, 0.1f), new GradientAlphaKey(0.6f, 0.6f), new GradientAlphaKey(0f, 1f) } } }; ParticleSystem.ColorBySpeedModule colorBySpeed = ps.colorBySpeed; colorBySpeed.enabled = false; ParticleSystem.SizeOverLifetimeModule sizeOverLife = ps.sizeOverLifetime; sizeOverLife.enabled = true; sizeOverLife.size = new ParticleSystem.MinMaxCurve { mode = ParticleSystemCurveMode.Curve, curve = new AnimationCurve { postWrapMode = WrapMode.Clamp, preWrapMode = WrapMode.Clamp, keys = new Keyframe[3] { new Keyframe(0f, 0.2f), new Keyframe(0.47f, 0.71f), new Keyframe(1f, 0.025f) } } }; sizeOverLife.sizeMultiplier = 1f; ParticleSystem.SizeBySpeedModule sizeBySpeed = ps.sizeBySpeed; sizeBySpeed.enabled = false; ParticleSystem.RotationOverLifetimeModule rotOverLife = ps.rotationOverLifetime; rotOverLife.enabled = true; rotOverLife.separateAxes = false; rotOverLife.z = new ParticleSystem.MinMaxCurve { mode = ParticleSystemCurveMode.Constant, constant = 3f }; ParticleSystem.RotationBySpeedModule rotBySpeed = ps.rotationBySpeed; rotBySpeed.enabled = false; ParticleSystem.ExternalForcesModule extForce = ps.externalForces; extForce.enabled = false; ParticleSystem.NoiseModule noise = ps.noise; noise.enabled = false; ParticleSystem.CollisionModule col = ps.collision; col.enabled = false; ParticleSystem.TriggerModule trig = ps.trigger; trig.enabled = false; ParticleSystem.SubEmittersModule subEmit = ps.subEmitters; subEmit.enabled = false; ParticleSystem.TextureSheetAnimationModule texSheet = ps.textureSheetAnimation; texSheet.enabled = false; ParticleSystem.LightsModule light = ps.lights; light.enabled = false; ParticleSystem.TrailModule trails = ps.trails; trails.enabled = false; ParticleSystem.CustomDataModule custData = ps.customData; custData.enabled = false; }
protected void InitializeParticleSystem(ParticleSystem ps, ParticleSystemRenderer renderer, int max_particles) { ParticleSystem.MainModule main = ps.main; main.loop = false; main.playOnAwake = false; main.maxParticles = max_particles; main.startColor = new ParticleSystem.MinMaxGradient(new Color(1.0f, 1.0f, 1.0f, 0.0f)); renderer.sortMode = ParticleSystemSortMode.Distance; renderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off; renderer.receiveShadows = false; renderer.enableGPUInstancing = true; Material particleMaterial = new Material(Shader.Find(shader)); renderer.material = particleMaterial; PrepareMaterial(particleMaterial); particleMaterial.SetColor("_Color", new Color(1.0f, 1.0f, 1.0f, 1.0f)); particleMaterial.SetColor("_EmissionColor", new Color(0.8f, 0.8f, 0.8f, 1.0f)); ParticleSystem.EmissionModule em = ps.emission; em.enabled = false; ParticleSystem.ShapeModule sh = ps.shape; sh.enabled = false; ParticleSystem.VelocityOverLifetimeModule vol = ps.velocityOverLifetime; vol.enabled = false; ParticleSystem.LimitVelocityOverLifetimeModule lvol = ps.limitVelocityOverLifetime; lvol.enabled = false; ParticleSystem.InheritVelocityModule ivm = ps.inheritVelocity; ivm.enabled = false; ParticleSystem.ForceOverLifetimeModule fol = ps.forceOverLifetime; fol.enabled = false; ParticleSystem.ColorOverLifetimeModule col = ps.colorOverLifetime; col.enabled = false; ParticleSystem.ColorBySpeedModule cbs = ps.colorBySpeed; cbs.enabled = false; ParticleSystem.SizeOverLifetimeModule sol = ps.sizeOverLifetime; sol.enabled = false; ParticleSystem.SizeBySpeedModule sbs = ps.sizeBySpeed; sbs.enabled = false; ParticleSystem.RotationOverLifetimeModule rol = ps.rotationOverLifetime; rol.enabled = false; ParticleSystem.RotationBySpeedModule rbs = ps.rotationBySpeed; rbs.enabled = false; ParticleSystem.ExternalForcesModule extf = ps.externalForces; extf.enabled = false; ParticleSystem.NoiseModule noise = ps.noise; noise.enabled = false; ParticleSystem.CollisionModule collision = ps.collision; collision.enabled = false; ParticleSystem.TriggerModule triggers = ps.trigger; triggers.enabled = false; ParticleSystem.SubEmittersModule subem = ps.subEmitters; subem.enabled = false; ParticleSystem.TextureSheetAnimationModule tsa = ps.textureSheetAnimation; tsa.enabled = false; ParticleSystem.LightsModule lights = ps.lights; lights.enabled = false; ParticleSystem.CustomDataModule cd = ps.customData; cd.enabled = false; }
protected void InitializeParticleSystem(ParticleSystem ps, ParticleSystemRenderer renderer, int max_particles) { ParticleSystem.MainModule main = ps.main; main.loop = false; main.playOnAwake = false; main.maxParticles = max_particles; main.startColor = new ParticleSystem.MinMaxGradient(new Color(1.0f, 1.0f, 1.0f, 0.0f)); renderer.sortMode = ParticleSystemSortMode.Distance; renderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off; renderer.receiveShadows = false; renderer.renderMode = ParticleSystemRenderMode.Billboard; //GameObject gameObj = GameObject.CreatePrimitive(PrimitiveType.Sphere); //renderer.mesh = gameObj.GetComponent<MeshFilter>().mesh; //Destroy(gameObj); renderer.enableGPUInstancing = true; renderer.alignment = ParticleSystemRenderSpace.Facing; ps_material = new Material(Shader.Find(shader)); renderer.material = ps_material; PrepareMaterial(ps_material, m_Particle); SetDefaultColor(new Color(1.0f, 1.0f, 1.0f, 1.0f)); SetDefaultEmission(new Color(1f, 1f, 1f, 1f)); ParticleSystem.EmissionModule em = ps.emission; em.enabled = false; ParticleSystem.ShapeModule sh = ps.shape; sh.enabled = false; ParticleSystem.VelocityOverLifetimeModule vol = ps.velocityOverLifetime; vol.enabled = false; ParticleSystem.LimitVelocityOverLifetimeModule lvol = ps.limitVelocityOverLifetime; lvol.enabled = false; ParticleSystem.InheritVelocityModule ivm = ps.inheritVelocity; ivm.enabled = false; ParticleSystem.ForceOverLifetimeModule fol = ps.forceOverLifetime; fol.enabled = false; ParticleSystem.ColorOverLifetimeModule col = ps.colorOverLifetime; col.enabled = false; ParticleSystem.ColorBySpeedModule cbs = ps.colorBySpeed; cbs.enabled = false; ParticleSystem.SizeOverLifetimeModule sol = ps.sizeOverLifetime; sol.enabled = false; ParticleSystem.SizeBySpeedModule sbs = ps.sizeBySpeed; sbs.enabled = false; ParticleSystem.RotationOverLifetimeModule rol = ps.rotationOverLifetime; rol.enabled = false; ParticleSystem.RotationBySpeedModule rbs = ps.rotationBySpeed; rbs.enabled = false; ParticleSystem.ExternalForcesModule extf = ps.externalForces; extf.enabled = false; ParticleSystem.NoiseModule noise = ps.noise; noise.enabled = false; ParticleSystem.CollisionModule collision = ps.collision; collision.enabled = false; ParticleSystem.TriggerModule triggers = ps.trigger; triggers.enabled = false; ParticleSystem.SubEmittersModule subem = ps.subEmitters; subem.enabled = false; ParticleSystem.TextureSheetAnimationModule tsa = ps.textureSheetAnimation; tsa.enabled = false; ParticleSystem.LightsModule lights = ps.lights; lights.enabled = false; ParticleSystem.CustomDataModule cd = ps.customData; cd.enabled = false; }