protected override object WriteToImpl(object obj)
 {
     obj = base.WriteToImpl(obj);
     ParticleSystem.SubEmittersModule uo = (ParticleSystem.SubEmittersModule)obj;
     uo.enabled = enabled;
     return(uo);
 }
Esempio n. 2
0
    public static void ParticleSubSettings(this ParticleSystem PS,
                                           bool enabled            = true,
                                           GameObject SPSContainer = null // Contains Particle System
                                           )
    {                                                                     // In progress
        ParticleSystem.SubEmittersModule subEmittersModule = PS.subEmitters;
        // Sub Emitters
        subEmittersModule.enabled = enabled;
        ParticleSystem SPS = SPSContainer.GetComponent <ParticleSystem>();

        subEmittersModule.AddSubEmitter(SPS, ParticleSystemSubEmitterType.Birth, ParticleSystemSubEmitterProperties.InheritNothing);
    }
Esempio n. 3
0
    void setupSubEmitter(ParticleSystem ps, SystemScrambler ss, ParticleSystem ps2, SystemScrambler ss2)
    {
        ParticleSystem.SubEmittersModule se = ps.subEmitters;

        se.enabled = ss.Enabled [7];
        if (!ss.Enabled [7])
        {
            return;
        }

        setupParticleSystem(ps2, ss2);
        se.AddSubEmitter(ps2, ParticleSystemSubEmitterType.Birth, ParticleSystemSubEmitterProperties.InheritNothing);
    }
Esempio n. 4
0
        public static void MulSize(ParticleSystem ps, float scale)
        {
            ParticleSystem.MainModule ps_main = ps.main;
            ps_main.startSize = ScaleCurve(ps_main.startSize, scale);

            ParticleSystem.SubEmittersModule ps_sub = ps.subEmitters;
            if (ps_sub.enabled)
            {
                for (int si = 0; si < ps_sub.subEmittersCount; si++)
                {
                    MulSize(ps_sub.GetSubEmitterSystem(si), scale);
                }
            }
        }
Esempio n. 5
0
 public static void SetSpeed(ParticleSystem ps, float speed)
 {
     ParticleSystem.MainModule main_module = ps.main;
     main_module.simulationSpeed = speed;
     ParticleSystem.SubEmittersModule sub_module = ps.subEmitters;
     if (sub_module.enabled)
     {
         for (int sub_i = 0; sub_i < sub_module.subEmittersCount; sub_i++)
         {
             ParticleSystem sub_sys = sub_module.GetSubEmitterSystem(sub_i);
             SetSpeed(sub_sys, speed);
         }
     }
 }
Esempio n. 6
0
        public override void GetDepsFrom(object obj, GetDepsFromContext context)
        {
            base.GetDepsFrom(obj, context);
            if (obj == null)
            {
                return;
            }

            ParticleSystem.SubEmittersModule o = (ParticleSystem.SubEmittersModule)obj;
            for (int i = 0; i < o.subEmittersCount; ++i)
            {
                AddDep(o.GetSubEmitterSystem(i), context);
            }
        }
Esempio n. 7
0
    void EmitPush(Vector3 force)
    {
        GameObject push = Instantiate(power.gameObject, null);

        push.GetComponent <PushPower> ().enabled = true;
        push.GetComponent <PushPower> ().emitted = true;
        push.transform.position = power.transform.position;
        push.GetComponent <Rigidbody> ().isKinematic = false;
        push.GetComponent <Rigidbody> ().AddForce(force);
        ParticleSystem.MainModule pm = push.GetComponent <ParticleSystem> ().main;
        pm.simulationSpace = ParticleSystemSimulationSpace.World;
        push.GetComponent <ParticleSystem> ().Play();
        ParticleSystem.SubEmittersModule ps = push.GetComponent <ParticleSystem> ().subEmitters;
        ps.enabled = true;
        Destroy(push, 5);
    }
Esempio n. 8
0
        private void AddSubEmitter(ref ParticleSystem subPS, ParticleSystemSubEmitterType type,
                                   System.Action <Vector3> callback)
        {
            // Create SubEmitter object
            GameObject go = new GameObject("subemitter-" + type.ToString());

            go.transform.parent           = transform;
            go.transform.localPosition    = Vector3.zero;
            go.transform.localScale       = Vector3.one;
            go.transform.localEulerAngles = Vector3.zero;

            // Configure SubEmitter particle system
            subPS = go.AddComponent <ParticleSystem>();
            subPS.Stop();
            // go.GetComponent<ParticleSystemRenderer>().material = new Material(Shader.Find("Particles/Additive"));
            ParticleSystem.MainModule main = subPS.main;
            main.duration      = 10f;
            main.startLifetime = 10f;
            main.startSize     = 0f;
            main.startSpeed    = 0f;
            main.maxParticles  = ps.main.maxParticles;
            main.loop          = true;
            main.playOnAwake   = true;
            ParticleSystem.EmissionModule emission = subPS.emission;
            emission.rateOverTime = 0f;
            emission.SetBursts(new ParticleSystem.Burst[]
            {
                new ParticleSystem.Burst(0f, 1, 1, 1, 0)
            });
            ParticleSystem.ShapeModule shape = subPS.shape;
            shape.shapeType = ParticleSystemShapeType.Box;
            shape.scale     = Vector3.zero;
            subPS.Play();

            // Add SubEmitter callback
            SubEmitterHandler handler = go.AddComponent <SubEmitterHandler>();

            handler.callback = callback;

            // Attach subemitter to to main emitter
            ParticleSystem.SubEmittersModule subEmitters = ps.subEmitters;
            subEmitters.AddSubEmitter(subPS, type, ParticleSystemSubEmitterProperties.InheritNothing);
            subEmitters.enabled = true;
        }
    // Update is called once per frame
    void Update()
    {
        if (!system.isEmitting)
        {
            ParticleSystem.SubEmittersModule sub = system.subEmitters;

            bool done = true;
            for (int i = 0; i < sub.subEmittersCount; i++)
            {
                ParticleSystem subemitter = sub.GetSubEmitterSystem(i);
                done = done && subemitter.isEmitting;
            }

            if (done)
            {
                Destroy(gameObject);
            }
        }
    }
Esempio n. 10
0
        FireworkControl CreateFirework(FireworkStyle style, FireworkControlMode mode, Vector3 startpoint, GameObject prefab)
        {
            if (prefab == null)
            {
                LogErr("prefab not loaded");
                return(null);
            }
            GameObject newparticle = Instantiate(prefab);

            newparticle.transform.position = startpoint;

            ParticleSystem mainparticle = newparticle.GetComponent <ParticleSystem>();

            ParticleSystem.MainModule mainm = mainparticle.main;
            mainm.startSpeed    = new ParticleSystem.MinMaxCurve(style.vmin, style.vmax);
            mainm.startColor    = new ParticleSystem.MinMaxGradient(style.color_from, style.color_to);
            mainm.startLifetime = new ParticleSystem.MinMaxCurve(style.vmin / 9.81f, style.vmax / 9.81f);

            ParticleSystem.ShapeModule shapem = mainparticle.shape;
            shapem.angle = style.angle;

            ParticleSystem.SubEmittersModule subm = mainparticle.subEmitters;
            //if (subm.subEmittersCount != 0)
            //{
            //    ParticleSystem subparticle = subm.GetSubEmitterSystem(0);
            //    ParticleSystem.MainModule submainm = subparticle.main;
            //    submainm.startSpeed = new ParticleSystem.MinMaxCurve(style.exp_vel_from, style.exp_vel_to);
            //}

            FireworkControl.MulSize(mainparticle, style.mul_particle_size);
            FireworkControl.MulExpVel(mainparticle, style.mul_exp_vel, false, true);

            FireworkControl control = newparticle.AddComponent <FireworkControl>();

            control.particle = mainparticle;
            control.mode     = mode;

            return(control);

            //mainparticle.Play();
            //Destroy(newparticle, 100);
        }
Esempio n. 11
0
        public static void MulExpVel(ParticleSystem ps, float scale, bool self, bool child)
        {
            if (self)
            {
                ParticleSystem.MainModule ps_main = ps.main;
                ps_main.startSpeed = ScaleCurve(ps_main.startSpeed, scale);
            }

            if (child)
            {
                ParticleSystem.SubEmittersModule ps_sub = ps.subEmitters;
                if (ps_sub.enabled)
                {
                    for (int si = 0; si < ps_sub.subEmittersCount; si++)
                    {
                        MulExpVel(ps_sub.GetSubEmitterSystem(si), scale);
                    }
                }
            }
        }
Esempio n. 12
0
        public override void ReadFrom(object obj)
        {
            base.ReadFrom(obj);
            if (obj == null)
            {
                return;
            }

            ParticleSystem.SubEmittersModule o = (ParticleSystem.SubEmittersModule)obj;
            m_subSystems         = new long[o.subEmittersCount];
            m_subEmitProbability = new float[o.subEmittersCount];
            m_subProperties      = new ParticleSystemSubEmitterProperties[o.subEmittersCount];
            m_subTypes           = new ParticleSystemSubEmitterType[o.subEmittersCount];
            for (int i = 0; i < o.subEmittersCount; ++i)
            {
                m_subSystems[i]         = ToID(o.GetSubEmitterSystem(i));
                m_subEmitProbability[i] = o.GetSubEmitterEmitProbability(i);
                m_subProperties[i]      = o.GetSubEmitterProperties(i);
                m_subTypes[i]           = o.GetSubEmitterType(i);
            }
        }
Esempio n. 13
0
 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));
     }
 }
Esempio n. 14
0
        public override object WriteTo(object obj)
        {
            obj = base.WriteTo(obj);
            if (obj == null)
            {
                return(null);
            }

            ParticleSystem.SubEmittersModule o = (ParticleSystem.SubEmittersModule)obj;
            if (m_subSystems != null)
            {
                for (int i = 0; i < m_subSystems.Length; ++i)
                {
                    ParticleSystem ps = FromID <ParticleSystem>(m_subSystems[i]);
                    if (ps != null)
                    {
                        o.AddSubEmitter(ps, m_subTypes[i], m_subProperties[i], m_subEmitProbability[i]);
                    }
                }
            }

            return(obj);
        }
 void OnGUI()
 {
     EditorGUILayout.Space();
     mainParticle = (ParticleSystem)EditorGUILayout.ObjectField("Main particle", mainParticle, typeof(ParticleSystem), true);
     if (mainParticle == null)
     {
         disabled = true;
     }
     EditorGUILayout.Space();
     EditorGUILayout.HelpBox("Select the subparticles you want to put in the main particle in the hierarchy", MessageType.None);
     EditorGUILayout.Space();
     EditorGUILayout.Space();
     EditorGUI.BeginDisabledGroup(disabled);
     if (GUILayout.Button("apply selected subparticles"))
     {
         ParticleSystem.SubEmittersModule subModule = mainParticle.GetComponent <ParticleSystem>().subEmitters;
         subModule.enabled = true;
         foreach (ParticleSystem subParticle in subParticles.ToArray())
         {
             subModule.AddSubEmitter(subParticle, ParticleSystemSubEmitterType.Death, ParticleSystemSubEmitterProperties.InheritNothing);
         }
     }
     EditorGUI.EndDisabledGroup();
 }
Esempio n. 16
0
        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);
        }
Esempio n. 17
0
        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;
        }
        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;
        }
Esempio n. 19
0
    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;
    }
Esempio n. 20
0
        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);
        }
 protected override void ReadFromImpl(object obj)
 {
     base.ReadFromImpl(obj);
     ParticleSystem.SubEmittersModule uo = (ParticleSystem.SubEmittersModule)obj;
     enabled = uo.enabled;
 }
    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;
    }
Esempio n. 23
0
        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;
        }