public static void ParticleRotationSettings(this ParticleSystem PS, bool enabled = true) { ParticleSystem.RotationOverLifetimeModule rotationOverLifetimeModule = PS.rotationOverLifetime; // Rotation settings rotationOverLifetimeModule.enabled = enabled; }
/// Tell the block about its neighbours public void Initialize(ref GameObject[,] _grid, int _xPos, int _zPos) { grid = _grid; xPos = _xPos; zPos = _zPos; //fireParticles = GetComponentInChildren<ParticleSystem> (); fireEmission = fireParticles.emission; fireMain = fireParticles.main; fireRenderer = fireParticles.GetComponent <ParticleSystemRenderer> (); fireRotation = fireParticles.rotationOverLifetime; // rotate doors if (blockType == BlockType.Door) { if (zPos > 0) { if (grid [xPos, zPos - 1].GetComponentInChildren <BuildingBlock> ().blockType == BlockType.Wall) { // the block below is a wall // rotate 90 transform.RotateAround(transform.position, Vector3.up, 90); } } } }
public ParticleState(AmplifyMotionCamera owner, AmplifyMotionObjectBase obj) : base(owner, obj) { m_particleSystem = m_obj.GetComponent <ParticleSystem>(); m_renderer = m_particleSystem.GetComponent <ParticleSystemRenderer>(); rotationOverLifetime = m_particleSystem.rotationOverLifetime; rotationBySpeed = m_particleSystem.rotationBySpeed; }
void Start() { PS = this.GetComponent <ParticleSystem>(); myShape = PS.shape; myColor = PS.colorOverLifetime; grad = new Gradient(); mySize = PS.sizeOverLifetime; myRot = PS.rotationOverLifetime; }
private static void SetRotationOverLifetime( ParticleSystem.RotationOverLifetimeModule rotation, List <ParticleEffectContent.FloatStop> stops) { AnimationCurve rotationCurve = new AnimationCurve(); foreach (ParticleEffectContent.FloatStop stop in stops) { rotationCurve.AddKey(stop.position, stop.value); } rotation.z = new ParticleSystem.MinMaxCurve(1f, rotationCurve); }
void Start() { particleSystem = GetComponent <ParticleSystem>() ?? gameObject.AddComponent <ParticleSystem>(); particleSystem.playOnAwake = false; particleSystem.Stop(); particleSystem.startLifetime = LifeTime; particleSystem.loop = true; particleSystem.startColor = StartColor; particleSystem.simulationSpace = ParticleSystemSimulationSpace.World; particleSystem.maxParticles = 10240; particleSystem.gravityModifier = -0.02f; particleSystem.scalingMode = ParticleSystemScalingMode.Shape; ParticleSystem.ShapeModule sm = particleSystem.shape; sm.shapeType = ParticleSystemShapeType.ConeShell; sm.radius = Radius; sm.angle = Angle; sm.length = 1; sm.randomDirection = true; sm.enabled = true; ParticleSystem.SizeOverLifetimeModule sl = particleSystem.sizeOverLifetime; sl.size = new ParticleSystem.MinMaxCurve(Size, AnimationCurve.Linear(0f, StartSize, LifeTime, EndSize)); sl.enabled = true; ParticleSystem.RotationOverLifetimeModule rolm = particleSystem.rotationOverLifetime; rolm.enabled = true; rolm.x = new ParticleSystem.MinMaxCurve(0, 360); ParticleSystem.ColorOverLifetimeModule colm = particleSystem.colorOverLifetime; colm.color = new Gradient() { alphaKeys = new GradientAlphaKey[] { new GradientAlphaKey(StartAlpha, StartAlphaTime), new GradientAlphaKey(EndAlpha, EndAlphaTime) }, colorKeys = new GradientColorKey[] { new GradientColorKey(StartColor, StartColorTime), new GradientColorKey(EndColor, EndColorTime) } }; colm.enabled = true; ParticleSystem seb = particleSystem.subEmitters.birth0; seb = GetComponent <ParticleSystem>(); ParticleSystemRenderer particleSystemRenderer = particleSystem.GetComponent <ParticleSystemRenderer>(); particleSystemRenderer.sortMode = ParticleSystemSortMode.Distance; particleSystemRenderer.sortingFudge = 80; particleSystemRenderer.receiveShadows = true; particleSystemRenderer.sharedMaterial = new Material(Shader.Find("Particles/Alpha Blended")); particleSystemRenderer.sharedMaterial.mainTexture = (ModResource.GetTexture("Rocket Smoke Texture")); }
void Awake() { Canvas = GameObject.Find("Canvas").GetComponent <CanvasGame>(); PS = GetComponent <ParticleSystem>(); Emission = PS.emission; Particle = PS.main; Rotation = PS.rotationOverLifetime; Trail = PS.trails; Renderer = GetComponent <ParticleSystemRenderer>(); SetParticleMode(PlayerPrefs.GetInt("Mode")); }
protected override void ReadFromImpl(object obj) { base.ReadFromImpl(obj); ParticleSystem.RotationOverLifetimeModule uo = (ParticleSystem.RotationOverLifetimeModule)obj; enabled = uo.enabled; x = uo.x; xMultiplier = uo.xMultiplier; y = uo.y; yMultiplier = uo.yMultiplier; z = uo.z; zMultiplier = uo.zMultiplier; separateAxes = uo.separateAxes; }
protected override object WriteToImpl(object obj) { obj = base.WriteToImpl(obj); ParticleSystem.RotationOverLifetimeModule uo = (ParticleSystem.RotationOverLifetimeModule)obj; uo.enabled = enabled; uo.x = x; uo.xMultiplier = xMultiplier; uo.y = y; uo.yMultiplier = yMultiplier; uo.z = z; uo.zMultiplier = zMultiplier; uo.separateAxes = separateAxes; return(uo); }
private void MapRotationOverLifetimeParameters(ParticleSystem pSystem, int i) { ParticleSystem.RotationOverLifetimeModule rotationOverLifetimeModule = pSystem.rotationOverLifetime; try { rotationOverLifetimeModule.enabled = GetBoolParam(i, "rotationOverLifetime_enabled"); } catch (NullReferenceException) { rotationOverLifetimeModule.enabled = false; return; } rotationOverLifetimeModule.separateAxes = GetBoolParam(i, "rotationOverLifetime_separateAxes"); rotationOverLifetimeModule.x = NodeFXUtilities.InterpretStringToCurve(GetStringParam(i, "rotationOverLifetime_angularVelocity_x")); rotationOverLifetimeModule.y = NodeFXUtilities.InterpretStringToCurve(GetStringParam(i, "rotationOverLifetime_angularVelocity_y")); rotationOverLifetimeModule.z = NodeFXUtilities.InterpretStringToCurve(GetStringParam(i, "rotationOverLifetime_angularVelocity_z")); }
private static void HitparticlesystemAssign() { ParticleSystem ps = new GameObject().AddComponent <ParticleSystem>(); hitParticleSystem = ps; ParticleSystem.MainModule main = ps.main; ParticleSystem.EmissionModule emission = ps.emission; ParticleSystem.ShapeModule shape = ps.shape; ParticleSystem.RotationOverLifetimeModule rot = ps.rotationOverLifetime; ParticleSystem.SizeOverLifetimeModule size = ps.sizeOverLifetime; ParticleSystem.ColorOverLifetimeModule color = ps.colorOverLifetime; ParticleSystemRenderer rend = ps.GetComponent <ParticleSystemRenderer>(); main.startSize = 3f; main.startSpeed = 0f; main.startLifetime = 0.4f; main.startColor = new ParticleSystem.MinMaxGradient(new Color(0.4f, 0.5f, 0.51f, 1f), new Color(0.56f, 0.53f, 0.8679245f, 1)); main.startRotation = new ParticleSystem.MinMaxCurve(0, 360); main.simulationSpace = ParticleSystemSimulationSpace.World; main.loop = false; emission.enabled = false; shape.enabled = false; rot.enabled = true; rot.z = 360; size.enabled = true; size.size = new ParticleSystem.MinMaxCurve(1, new AnimationCurve(new Keyframe[] { new Keyframe(0, 0, 2, 2), new Keyframe(0.8007382f, 1, 0, 0), new Keyframe(1, 0, 0, 0), })); color.enabled = true; color.color = new ParticleSystem.MinMaxGradient(new Color(1, 1, 1, 1), new Color(1, 1, 1, 0)); Material mat1 = new Material(Shader.Find("Particles/Additive")) { mainTexture = Res.ResourceLoader.GetTexture(129) }; rend.material = mat1; }
static void WriteParticleSystemRotationOverLifetime(ParticleSystem.RotationOverLifetimeModule module) { m_writer.Write(module.enabled); if (!module.enabled) { return; } m_writer.Write(module.separateAxes); if (module.separateAxes) { WriteMinMaxCurve(module.x); WriteMinMaxCurve(module.y); WriteMinMaxCurve(module.z); } else { WriteMinMaxCurve(module.z); } }
void setupRotationOverLifetime(ParticleSystem ps, SystemScrambler ss) { ParticleSystem.RotationOverLifetimeModule rol = ps.rotationOverLifetime; rol.enabled = ss.Enabled [5]; if (!ss.Enabled [5]) { return; } rol.separateAxes = ss.Bools [3]; if (rol.separateAxes) { rol.x = ss.Floats [75]; rol.xMultiplier = ss.Floats [76]; rol.y = ss.Floats [77]; rol.yMultiplier = ss.Floats [78]; rol.z = ss.Floats [79]; rol.zMultiplier = ss.Floats [80]; } }
private void CopyParticle(ParticleSystem part, ParticleSystem newPart) { ParticleSystem.MainModule main = part.main; main.duration = newPart.main.duration; main.startLifetime = newPart.main.startLifetime; main.startSpeed = newPart.main.startSpeed; main.startSize = newPart.main.startSize; main.startColor = newPart.main.startColor; ParticleSystem.EmissionModule emis = part.emission; emis.rateOverTime = newPart.emission.rateOverTime; emis.rateOverDistance = newPart.emission.rateOverDistance; emis.burstCount = newPart.emission.burstCount; emis.SetBurst(0, newPart.emission.GetBurst(0)); ParticleSystem.ShapeModule shape = part.shape; shape.shapeType = newPart.shape.shapeType; shape.radius = newPart.shape.radius; shape.radiusThickness = newPart.shape.radiusThickness; shape.arc = newPart.shape.arc; shape.arcMode = newPart.shape.arcMode; shape.arcSpeed = newPart.shape.arcSpeed; shape.position = newPart.shape.position; shape.rotation = newPart.shape.rotation; ParticleSystem.RotationOverLifetimeModule rot = part.rotationOverLifetime; rot.enabled = newPart.rotationOverLifetime.enabled; rot.z = newPart.rotationOverLifetime.z; ParticleSystem.TextureSheetAnimationModule tex = part.textureSheetAnimation; tex.enabled = newPart.textureSheetAnimation.enabled; if (tex.enabled) { tex.mode = newPart.textureSheetAnimation.mode; tex.SetSprite(0, newPart.textureSheetAnimation.GetSprite(0)); } ParticleSystem.SubEmittersModule sub = part.subEmitters; sub.enabled = newPart.subEmitters.enabled; if (sub.enabled) { sub.AddSubEmitter(newPart.subEmitters.GetSubEmitterSystem(0), newPart.subEmitters.GetSubEmitterType(0), newPart.subEmitters.GetSubEmitterProperties(0)); } }
public static void ParticleRotationSettings(this ParticleSystem PS, bool enabled = true, float Scalar = 1.0f, float Velocity = 100f, ParticleSystemCurveMode curveMode = ParticleSystemCurveMode.Constant, float CurveMin = 45f, float CurveMax = 114f ) { ParticleSystem.RotationOverLifetimeModule rotationOverLifetimeModule = PS.rotationOverLifetime; // Rotation settings rotationOverLifetimeModule.enabled = enabled; if (curveMode == ParticleSystemCurveMode.Constant) { ParticleSystem.MinMaxCurve RotationCurveConst = new ParticleSystem.MinMaxCurve(Velocity); RotationCurveConst.mode = curveMode; rotationOverLifetimeModule.z = RotationCurveConst; } if (curveMode == ParticleSystemCurveMode.TwoConstants) { rotationOverLifetimeModule.z = new ParticleSystem.MinMaxCurve(1f, 3f); } }
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; }
public void UpdateParticleSystem() { ParticleSystem refSystem = referenceLine.GetComponent <ParticleSystem>(); ParticleSystem.MainModule refSetting = refSystem.main; ParticleSystem.EmissionModule refEmission = refSystem.emission; ParticleSystem.RotationOverLifetimeModule refRotationLifeTime = refSystem.rotationOverLifetime; ParticleSystem.SizeOverLifetimeModule refSizeLifetime = refSystem.sizeOverLifetime; ParticleSystemRenderer refRenderer = refSystem.GetComponent <ParticleSystemRenderer>(); ParticleSystem.Burst refBurst = refEmission.GetBurst(0); foreach (Line line in triangleComplex.lines) { ParticleSystem particleSystem = line.GetComponent <ParticleSystem>(); ParticleSystem.MainModule particleSettings = particleSystem.main; ParticleSystem.EmissionModule particleEmission = particleSystem.emission; ParticleSystem.RotationOverLifetimeModule particleRotationLifeTime = particleSystem.rotationOverLifetime; ParticleSystem.SizeOverLifetimeModule particleSizeLifetime = particleSystem.sizeOverLifetime; ParticleSystemRenderer particleRenderer = particleSystem.GetComponent <ParticleSystemRenderer>(); particleSettings.customSimulationSpace = refSetting.customSimulationSpace; particleSettings.duration = refSetting.duration; particleSettings.emitterVelocityMode = refSetting.emitterVelocityMode; particleSettings.flipRotation = refSetting.flipRotation; particleSettings.gravityModifier = refSetting.gravityModifier; particleSettings.gravityModifierMultiplier = refSetting.gravityModifierMultiplier; particleSettings.loop = refSetting.loop; particleSettings.maxParticles = refSetting.maxParticles; particleSettings.playOnAwake = refSetting.playOnAwake; particleSettings.prewarm = refSetting.prewarm; particleSettings.scalingMode = refSetting.scalingMode; particleSettings.simulationSpace = refSetting.simulationSpace; particleSettings.simulationSpeed = refSetting.simulationSpeed; particleSettings.startColor = refSetting.startColor; particleSettings.startDelay = refSetting.startDelay; particleSettings.startDelayMultiplier = refSetting.startDelayMultiplier; particleSettings.startLifetime = refSetting.startLifetime; particleSettings.startLifetimeMultiplier = refSetting.startLifetimeMultiplier; particleSettings.startRotation = refSetting.startRotation; particleSettings.startRotation3D = refSetting.startRotation3D; particleSettings.startRotationMultiplier = refSetting.startRotationMultiplier; particleSettings.startRotationX = refSetting.startRotationX; particleSettings.startRotationXMultiplier = refSetting.startRotationXMultiplier; particleSettings.startRotationY = refSetting.startRotationY; particleSettings.startRotationYMultiplier = refSetting.startRotationYMultiplier; particleSettings.startRotationZ = refSetting.startRotationZ; particleSettings.startRotationZMultiplier = refSetting.startRotationZMultiplier; particleSettings.startSize = refSetting.startSize; particleSettings.startSize3D = refSetting.startSize3D; particleSettings.startSizeMultiplier = refSetting.startSizeMultiplier; particleSettings.startSizeX = refSetting.startSizeX; particleSettings.startSizeXMultiplier = refSetting.startSizeXMultiplier; particleSettings.startSizeY = refSetting.startSizeY; particleSettings.startSizeYMultiplier = refSetting.startSizeYMultiplier; particleSettings.startSizeZ = refSetting.startSizeZ; particleSettings.startSizeZMultiplier = refSetting.startSizeZMultiplier; particleSettings.startSpeed = refSetting.startSpeed; particleSettings.startSpeedMultiplier = refSetting.startSpeedMultiplier; particleSettings.stopAction = refSetting.stopAction; particleSettings.useUnscaledTime = refSetting.useUnscaledTime; particleEmission.burstCount = refEmission.burstCount; particleEmission.enabled = refEmission.enabled; particleEmission.rateOverDistance = refEmission.rateOverDistance; particleEmission.rateOverDistanceMultiplier = refEmission.rateOverDistanceMultiplier; particleEmission.rateOverTime = refEmission.rateOverTime; particleEmission.rateOverTimeMultiplier = refEmission.rateOverTimeMultiplier; particleRotationLifeTime.enabled = refRotationLifeTime.enabled; particleRotationLifeTime.separateAxes = refRotationLifeTime.separateAxes; particleRotationLifeTime.x = refRotationLifeTime.x; particleRotationLifeTime.xMultiplier = refRotationLifeTime.xMultiplier; particleRotationLifeTime.y = refRotationLifeTime.y; particleRotationLifeTime.yMultiplier = refRotationLifeTime.yMultiplier; particleRotationLifeTime.z = refRotationLifeTime.z; particleRotationLifeTime.zMultiplier = refRotationLifeTime.zMultiplier; particleSizeLifetime.enabled = refSizeLifetime.enabled; particleSizeLifetime.separateAxes = refSizeLifetime.separateAxes; particleSizeLifetime.size = refSizeLifetime.size; particleSizeLifetime.sizeMultiplier = refSizeLifetime.sizeMultiplier; particleSizeLifetime.x = refSizeLifetime.x; particleSizeLifetime.xMultiplier = refSizeLifetime.xMultiplier; particleSizeLifetime.y = refSizeLifetime.y; particleSizeLifetime.yMultiplier = refSizeLifetime.yMultiplier; particleSizeLifetime.z = refSizeLifetime.z; particleSizeLifetime.zMultiplier = refSizeLifetime.zMultiplier; particleRenderer.minParticleSize = refRenderer.minParticleSize; particleEmission.SetBursts(new ParticleSystem.Burst[] { refBurst }); } }
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); }
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; }
// Start is called before the first frame update void Start() { Debug.Log("Branches: " + header.numBranches); particleSystem = gameObject.AddComponent <ParticleSystem>(); particleRenderer = GetComponent <ParticleSystemRenderer>(); // Get and activate all the required modules mainModule = particleSystem.main; emissionModule = particleSystem.emission; emissionModule.enabled = true; shapeModule = particleSystem.shape; shapeModule.enabled = true; colorModule = particleSystem.colorOverLifetime; colorModule.enabled = true; sizeModule = particleSystem.sizeOverLifetime; sizeModule.enabled = true; texAnimModule = particleSystem.textureSheetAnimation; texAnimModule.enabled = true; velocityModule = particleSystem.velocityOverLifetime; velocityModule.enabled = true; collisionModule = particleSystem.collision; collisionModule.enabled = true; rotationModule = particleSystem.rotationOverLifetime; rotationModule.enabled = true; limitVelocityModule = particleSystem.limitVelocityOverLifetime; limitVelocityModule.enabled = true; // Set main parameters mainModule.gravityModifier = emitterParameters.gravity; mainModule.startSize = emitterParameters.sizeStart; mainModule.startLifetime = emitterParameters.lifeExp; // Set collision parameters collisionModule.bounce = emitterParameters.bounceCoefficient; // Set emission parameters emissionModule.rateOverTime = new ParticleSystem.MinMaxCurve(emitterParameters.birthRate); // Set size parameters // TODO: Use x, y values of size? // TODO: Use size mid sizeModule.size = new ParticleSystem.MinMaxCurve( emitterParameters.sizeStart / SIZE_FACTOR, emitterParameters.sizeEnd / SIZE_FACTOR ); sizeModule.x = new ParticleSystem.MinMaxCurve( emitterParameters.sizeStartX / SIZE_FACTOR, emitterParameters.sizeEnd / SIZE_FACTOR ); sizeModule.y = new ParticleSystem.MinMaxCurve( emitterParameters.sizeStartY > 0 ? emitterParameters.sizeStartY / SIZE_FACTOR : emitterParameters.sizeStartX / SIZE_FACTOR, emitterParameters.sizeEnd / SIZE_FACTOR ); // Set color parameters // TODO: Support colorMid too //colorModule.color = new ParticleSystem.MinMaxGradient( // new Color( // emitterParameters.colorStart.r, // emitterParameters.colorStart.g, // emitterParameters.colorStart.b, // emitterParameters.alphaStart // ), // new Color( // emitterParameters.colorEnd.r, // emitterParameters.colorEnd.g, // emitterParameters.colorEnd.b, // emitterParameters.alphaEnd // ) //); // Set texture sheet parameters texAnimModule.animation = ParticleSystemAnimationType.WholeSheet; //texAnimModule.cycleCount = 1; texAnimModule.fps = emitterParameters.fps; texAnimModule.numTilesX = 4; texAnimModule.numTilesY = 4; texAnimModule.startFrame = emitterParameters.frameStart; texAnimModule.timeMode = ParticleSystemAnimationTimeMode.FPS; // Velocity parameters velocityModule.speedModifier = emitterParameters.velocity; // Velocity limit parameters limitVelocityModule.drag = emitterParameters.drag; // Rotation over lifetime rotationModule.separateAxes = false; rotationModule.x = emitterParameters.particleRotation; // Particle system render options particleRenderer.minParticleSize = 0f; particleRenderer.maxParticleSize = 1f; particleRenderer.alignment = ParticleSystemRenderSpace.Facing; // Source: https://forum.unity.com/threads/change-standard-shader-render-mode-in-runtime.318815/ mat.SetInt("_Mode", 2); mat.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One); mat.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha); mat.SetInt("_ZWrite", 0); mat.DisableKeyword("_ALPHATEST_ON"); mat.DisableKeyword("_ALPHABLEND_ON"); mat.EnableKeyword("_ALPHAPREMULTIPLY_ON"); mat.renderQueue = 3000; mat.SetFloat("_SoftParticlesEnabled", 1f); mat.SetFloat("_SoftParticlesNearFadeDistance", 5f); mat.SetFloat("_SoftParticlesFarFadeDistance", 1f); mat.SetFloat("_CameraFadingEnabled", 1f); mat.SetFloat("_CameraFarFadeDistance", 5f); mat.SetFloat("_CameraNearFadeDistance", 1f); mat.SetFloat("_FlipbookMode", 1f); particleRenderer.material = mat; switch (header.blend) { case "Normal": break; case "Punch-Through": Debug.Log("Punch-Through not yet supported"); break; case "Lighten": Debug.Log("Lighten not yet supported"); break; default: Debug.Log(header.blend + " blend type not yet supported"); break; } switch (header.render) { case "Normal": // Particles are billboards particleRenderer.renderMode = ParticleSystemRenderMode.VerticalBillboard; particleRenderer.alignment = ParticleSystemRenderSpace.Facing; break; case "Linked": // Particle "touch and are stretched where necessary to do so" Debug.LogWarning("Linked not yet supported"); break; case "Billboard to Local Z": // Particle faces the way they came out regardless of camera movement Debug.LogWarning("Billboard to Local Z not yet supported"); break; case "Billboard to World Z": // Particles face upwards particleRenderer.renderMode = ParticleSystemRenderMode.HorizontalBillboard; break; case "Aligned to World Z": Debug.LogWarning("Aligned to World Z not yet supported"); break; case "Aligned to Particle": // Particles are aligned at the angle they leave the emitter // Uses the deadspace parameter Debug.LogWarning("Aligned to Particle not yet supported"); break; case "Motion Blur": // Stretches the particles along the path of travel severely, // and overlaps them as well particleRenderer.renderMode = ParticleSystemRenderMode.Stretch; break; default: Debug.LogWarning("Did not recognize particle render mode " + header.render); break; } switch (header.update) { case "Fountain": shapeModule.angle = emitterParameters.spread; break; case "Single": break; case "Explosion": particleSystem.Stop(); break; case "Lightning": break; default: Debug.LogWarning("Emitter style " + header.style + " not found"); break; } }
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; }
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; }
private void SetParticleSystemProps(ParticleEffectContent content, GameObject go, bool stream) { ParticleSystem particleSystem = go.GetComponent <ParticleSystem>(); ParticleSystem.MainModule main = particleSystem.main; main.simulationSpace = content.isLocal ? ParticleSystemSimulationSpace.Local : ParticleSystemSimulationSpace.World; main.duration = content.duration; main.startLifetime = content.duration; main.gravityModifier = content.gravityModifier; ParticleSystem.ShapeModule shape = particleSystem.shape; switch (content.shapeType) { case ParticleEffectContent.ShapeType.Cone: shape.shapeType = ParticleSystemShapeType.Cone; break; case ParticleEffectContent.ShapeType.Sphere: shape.shapeType = ParticleSystemShapeType.Sphere; break; case ParticleEffectContent.ShapeType.Box: shape.shapeType = ParticleSystemShapeType.Box; break; case ParticleEffectContent.ShapeType.Circle: shape.shapeType = ParticleSystemShapeType.Circle; break; case ParticleEffectContent.ShapeType.Rectangle: shape.shapeType = ParticleSystemShapeType.Rectangle; break; } shape.scale = Vector3.one * content.shapeSize; ParticleSystem.EmissionModule emission = particleSystem.emission; emission.enabled = true; if (stream) { emission.rateOverTime = content.burstCount; } else { emission.rateOverTime = 0; emission.SetBursts( new ParticleSystem.Burst[] { new ParticleSystem.Burst(0.0f, content.burstCount) }); } ParticleSystem.VelocityOverLifetimeModule velocityOverLifetime = particleSystem.velocityOverLifetime; velocityOverLifetime.enabled = true; velocityOverLifetime.speedModifier = content.speed; ParticleSystem.RotationOverLifetimeModule rotationOverLifetime = particleSystem.rotationOverLifetime; rotationOverLifetime.enabled = true; SetRotationOverLifetime(rotationOverLifetime, content.rotationOverLifetime); ParticleSystem.SizeOverLifetimeModule sizeOverLifetime = particleSystem.sizeOverLifetime; sizeOverLifetime.enabled = true; SetSizeOverLifetime(sizeOverLifetime, content.startSize, content.endSize); ParticleSystem.ColorOverLifetimeModule colorOverLifetime = particleSystem.colorOverLifetime; colorOverLifetime.enabled = true; colorOverLifetime.color = ColorTuplesToGradient(content.colorOverLifetime); ParticleSystemRenderer renderer = go.GetComponent <ParticleSystemRenderer>(); renderer.material = particleMaterial; }
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; }
public static GameObject Create() { AnimationCurve sizecurve = new AnimationCurve(new Keyframe[] { new Keyframe(0, 0, 5.129462f, 5.129462f), new Keyframe(0.2449522f, 1, 0, 0), new Keyframe(1, 0, -1.242162f, -1.242162f), }); if (mat1 == null) { mat1 = new Material(Shader.Find("Particles/Multiply")); mat2 = new Material(Shader.Find("Particles/Additive")); mat1.color = Color.white; mat2.color = Color.white; mat1.mainTexture = Res.ResourceLoader.GetTexture(111); mat2.mainTexture = Res.ResourceLoader.GetTexture(111); mat1.renderQueue = 3050; mat2.renderQueue = 3000; } GameObject go = new GameObject("__BlackFlames__"); ParticleSystem ps = go.AddComponent <ParticleSystem>(); ParticleSystem.MainModule main = ps.main; ParticleSystem.EmissionModule emission = ps.emission; ParticleSystem.ShapeModule shape = ps.shape; ParticleSystem.RotationOverLifetimeModule rot = ps.rotationOverLifetime; ParticleSystem.SizeOverLifetimeModule size = ps.sizeOverLifetime; ParticleSystemRenderer rend = ps.GetComponent <ParticleSystemRenderer>(); main.startSize = 0.4f; main.startSpeed = -6f; main.startLifetime = 0.75f; main.startColor = new Color(0, 0, 1, 0.623f); main.startRotation = new ParticleSystem.MinMaxCurve(0, 90); emission.rateOverTime = 100; shape.shapeType = ParticleSystemShapeType.Cone; shape.angle = 0; shape.radius = 0.25f; rot.enabled = true; rot.z = 180; size.enabled = true; size.size = new ParticleSystem.MinMaxCurve(1, sizecurve); rend.renderMode = ParticleSystemRenderMode.Stretch; rend.lengthScale = 2; rend.normalDirection = 1; rend.material = mat1; GameObject go2 = GameObject.Instantiate(go, go.transform); ParticleSystem ps2 = go.GetComponent <ParticleSystem>(); ParticleSystemRenderer rend2 = go.GetComponent <ParticleSystemRenderer>(); ParticleSystem.MainModule main2 = ps2.main; main2.startColor = new Color(0, 0.15f, 1, 0.623f); main2.startLifetime = 1; main2.startSpeed = -4; rend2.material = mat2; var light = go2.AddComponent <Light>(); light.shadowStrength = 1; light.shadows = LightShadows.Hard; light.type = LightType.Point; light.range = 20; light.color = new Color(0.6f, 0.3f, 1f); light.intensity = 0.6f; return(go); }
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); }