Example #1
0
        internal static TrailRenderer AddTrail(GameObject mainObj, WispSkinnedEffect skin, MaterialType matType, Single width, Single startWidth, Single endWidth, Single time, Boolean applyColor = true)
        {
            if (!trailCounter.ContainsKey(mainObj))
            {
                trailCounter[mainObj] = 0u;
            }
            var obj = new GameObject("Trail" + trailCounter[mainObj]++);

            obj.transform.parent        = mainObj.transform;
            obj.transform.localPosition = Vector3.zero;
            obj.transform.localScale    = Vector3.one;
            obj.transform.localRotation = Quaternion.identity;

            var trail = obj.AddComponent <TrailRenderer>();

            if (matType != MaterialType.Constant)
            {
                skin.AddRenderer(trail, matType);
            }
            if (applyColor)
            {
                skin.AddTrail(trail);
            }

            trail.time            = time;
            trail.startWidth      = startWidth;
            trail.endWidth        = endWidth;
            trail.widthMultiplier = width;

            trail.textureMode                   = LineTextureMode.Stretch;
            trail.alignment                     = LineAlignment.View;
            trail.shadowCastingMode             = UnityEngine.Rendering.ShadowCastingMode.Off;
            trail.motionVectorGenerationMode    = MotionVectorGenerationMode.Object;
            trail.lightProbeUsage               = UnityEngine.Rendering.LightProbeUsage.Off;
            trail.reflectionProbeUsage          = UnityEngine.Rendering.ReflectionProbeUsage.Off;
            trail.sortingLayerName              = "Default";
            trail.lightProbeProxyVolumeOverride = null;
            trail.probeAnchor                   = null;
            trail.lightmapScaleOffset           = new Vector4(1f, 1f, 0f, 0f);
            trail.realtimeLightmapScaleOffset   = new Vector4(1f, 1f, 0f, 0f);
            trail.minVertexDistance             = 0.025f;
            trail.shadowBias                    = 0f;
            trail.autodestruct                  = false;
            trail.emitting                  = true;
            trail.generateLightingData      = false;
            trail.receiveShadows            = true;
            trail.allowOcclusionWhenDynamic = true;
            trail.numCornerVertices         = 64;
            trail.numCapVertices            = 64;
            trail.renderingLayerMask        = 1;
            trail.rendererPriority          = 0;
            trail.sortingLayerID            = 0;
            trail.sortingOrder              = 0;
            trail.lightmapIndex             = -1;
            trail.realtimeLightmapIndex     = -1;

            return(trail);
        }
Example #2
0
        internal LineRenderer AddBeamLine(WispSkinnedEffect skin, MaterialType matType, Single radius, Single rippleStrength = 0f, Int32 rippleCount = 0)
        {
            this.beamLine = base.gameObject.AddComponent <LineRenderer>();
            if (matType != MaterialType.Constant)
            {
                skin.AddRenderer(this.beamLine, matType);
            }

            if (rippleStrength > 0f && rippleCount >= 0)
            {
                var rippleMin   = radius * (1f - rippleStrength);
                var rippleMax   = radius * (1f + rippleStrength);
                var numSegments = 1 + rippleCount;
                var numPoints   = 1 + 2 * numSegments;
                var rippleDist  = 1f / (numPoints - 1);
                var rippleKeys  = new Keyframe[numPoints];

                rippleKeys[0] = new Keyframe(0f, 1f, 0f, 0f);

                var loopPoints = numPoints - 2;
                var counter    = 1;
                var high       = false;
                while (counter <= loopPoints)
                {
                    var height = high ? rippleMax : rippleMin;
                    rippleKeys[counter] = new Keyframe(rippleDist * counter++, height, 0f, 0f);
                    high = !high;
                }

                rippleKeys[numPoints - 1] = new Keyframe(1f, 1f, 0f, 0f);
                this.beamLine.widthCurve  = new AnimationCurve(rippleKeys);
            }
            else
            {
                this.beamLine.endWidth   = radius;
                this.beamLine.startWidth = radius;
            }

            this.beamLine.alignment   = LineAlignment.View;
            this.beamLine.textureMode = LineTextureMode.Tile;

            this.beamLine.useWorldSpace = true;

            this.beamLine.numCapVertices    = 64;
            this.beamLine.numCornerVertices = 64;

            return(this.beamLine);
        }
Example #3
0
        internal static Light AddLight(GameObject mainObj, WispSkinnedEffect skin, Boolean applyColor, Single range, Single intensity)
        {
            if (!lightCounter.ContainsKey(mainObj))
            {
                lightCounter[mainObj] = 0u;
            }
            var obj = new GameObject("Light" + lightCounter[mainObj]++);

            obj.transform.parent = mainObj.transform;

            var light = obj.AddComponent <Light>();

            if (applyColor)
            {
                skin.AddLight(light);
            }

            light.type      = LightType.Point;
            light.intensity = intensity;
            light.range     = range;
            light.color     = Color.white;

            return(light);
        }
Example #4
0
        internal static Renderer AddMeshIndicator(GameObject mainObj, WispSkinnedEffect skin, MaterialType matType, MeshIndex mesh, Boolean useParticle = false, Boolean particleScaleToSize = false, Single timeToFullsize = 1f, Single duration = 10f, Boolean scaleX = true, Boolean scaleY = true, Boolean scaleZ = true)
        {
            if (!meshIndCounter.ContainsKey(mainObj))
            {
                meshIndCounter[mainObj] = 0u;
            }
            var obj = new GameObject("MeshIndicator" + meshIndCounter[mainObj]++);

            obj.transform.parent        = mainObj.transform;
            obj.transform.localPosition = Vector3.zero;
            obj.transform.localScale    = Vector3.one;
            obj.transform.localRotation = Quaternion.identity;

            Renderer renderer = null;
            Mesh     m        = AssetsCore.LoadAsset <Mesh>(mesh);

            if (useParticle)
            {
                var ps  = obj.AddComponent <ParticleSystem>();
                var psr = obj.AddOrGetComponent <ParticleSystemRenderer>();
                renderer       = psr;
                psr.renderMode = ParticleSystemRenderMode.Mesh;
                psr.alignment  = ParticleSystemRenderSpace.World;
                psr.mesh       = m;

                BasicSetup(ps);

                ps.useAutoRandomSeed = true;

                var psMain = ps.main;
                psMain.duration            = duration;
                psMain.loop                = false;
                psMain.startDelay          = 0f;
                psMain.startLifetime       = duration;
                psMain.startSpeed          = 0f;
                psMain.startSize3D         = false;
                psMain.startSize           = 1f;
                psMain.startRotation3D     = false;
                psMain.startRotation       = 0f;
                psMain.flipRotation        = 0f;
                psMain.startColor          = Color.white;
                psMain.gravityModifier     = 0f;
                psMain.simulationSpace     = ParticleSystemSimulationSpace.Local;
                psMain.useUnscaledTime     = false;
                psMain.scalingMode         = ParticleSystemScalingMode.Hierarchy;
                psMain.playOnAwake         = true;
                psMain.emitterVelocityMode = ParticleSystemEmitterVelocityMode.Transform;
                psMain.maxParticles        = 1;
                psMain.stopAction          = ParticleSystemStopAction.None;
                psMain.cullingMode         = ParticleSystemCullingMode.PauseAndCatchup;
                psMain.ringBufferMode      = ParticleSystemRingBufferMode.Disabled;

                var psEmis = ps.emission;
                psEmis.enabled    = true;
                psEmis.burstCount = 1;
                psEmis.SetBurst(0, new ParticleSystem.Burst(0f, 1));
                psEmis.rateOverTime     = 0f;
                psEmis.rateOverDistance = 0f;

                if (particleScaleToSize)
                {
                    var frac  = timeToFullsize / duration;
                    var psSOL = ps.sizeOverLifetime;
                    psSOL.enabled = true;
                    if (scaleX == false && scaleY == false && scaleZ == false)
                    {
                        psSOL.separateAxes = false;
                        psSOL.size         = new ParticleSystem.MinMaxCurve(1f, AnimationCurve.EaseInOut(0f, 0f, frac, 1f));
                    }
                    else
                    {
                        psSOL.separateAxes = true;
                        psSOL.x            = scaleX ? new ParticleSystem.MinMaxCurve(1f, AnimationCurve.EaseInOut(0f, 0f, frac, 1f)) : 1f;
                        psSOL.y            = scaleX ? new ParticleSystem.MinMaxCurve(1f, AnimationCurve.EaseInOut(0f, 0f, frac, 1f)) : 1f;
                        psSOL.z            = scaleX ? new ParticleSystem.MinMaxCurve(1f, AnimationCurve.EaseInOut(0f, 0f, frac, 1f)) : 1f;
                    }
                }
            }
            else
            {
                var meshRend   = obj.AddComponent <MeshRenderer>();
                var meshFilter = obj.AddOrGetComponent <MeshFilter>();
                renderer = meshRend;
                meshFilter.sharedMesh = m;
            }

            if (matType != MaterialType.Constant)
            {
                skin.AddRenderer(renderer, matType);
            }
            return(renderer);
        }
Example #5
0
        internal static ParticleSystem AddFlamePillar(GameObject mainObj, WispSkinnedEffect skin, MaterialType matType, Single height, Single radius, Single lifetime, Int16 count = 4)
        {
            var calcHeight = height * 0.15f;
            var calcRad    = radius * 0.3f;

            if (!flamePillarCounter.ContainsKey(mainObj))
            {
                flamePillarCounter[mainObj] = 0u;
            }
            var obj = new GameObject("FlamePillar" + flamePillarCounter[mainObj]++);

            obj.transform.parent        = mainObj.transform;
            obj.transform.localPosition = Vector3.zero;
            obj.transform.localScale    = Vector3.one;
            obj.transform.localRotation = Quaternion.identity;

            var ps  = obj.AddComponent <ParticleSystem>();
            var psr = obj.AddOrGetComponent <ParticleSystemRenderer>();

            if (matType != MaterialType.Constant)
            {
                skin.AddRenderer(psr, matType);
            }


            BasicSetup(ps);

            ps.useAutoRandomSeed = true;

            var psMain = ps.main;

            psMain.duration            = lifetime * 2f;
            psMain.loop                = false;
            psMain.prewarm             = false;
            psMain.startDelay          = 0.0f;
            psMain.startLifetime       = new ParticleSystem.MinMaxCurve(lifetime * 0.75f, lifetime * 1.25f);
            psMain.startSpeed          = 0f;
            psMain.startSize3D         = true;
            psMain.startSizeX          = new ParticleSystem.MinMaxCurve(calcRad * 0.75f, calcRad * 1.25f);
            psMain.startSizeY          = new ParticleSystem.MinMaxCurve(0.8f, 1.2f);
            psMain.startSizeZ          = calcHeight;
            psMain.startRotation3D     = true;
            psMain.startRotationX      = Mathf.PI / 2f;
            psMain.startRotationY      = new ParticleSystem.MinMaxCurve(0f, Mathf.PI * 2f);
            psMain.startRotationZ      = 0f;
            psMain.flipRotation        = 1f;
            psMain.startColor          = Color.white;
            psMain.gravityModifier     = 0f;
            psMain.simulationSpace     = ParticleSystemSimulationSpace.World;
            psMain.simulationSpeed     = 1f;
            psMain.useUnscaledTime     = false;
            psMain.scalingMode         = ParticleSystemScalingMode.Local;
            psMain.playOnAwake         = true;
            psMain.emitterVelocityMode = ParticleSystemEmitterVelocityMode.Transform;
            psMain.maxParticles        = 1000;
            psMain.stopAction          = ParticleSystemStopAction.None;
            psMain.cullingMode         = ParticleSystemCullingMode.PauseAndCatchup;
            psMain.ringBufferMode      = ParticleSystemRingBufferMode.Disabled;

            var psEmis = ps.emission;

            psEmis.enabled    = true;
            psEmis.burstCount = 1;
            psEmis.SetBurst(0, new ParticleSystem.Burst(0f, count, count, 1, 0.01f));
            psEmis.rateOverTime     = 0f;
            psEmis.rateOverDistance = 0f;

            //var psShape = ps.shape;
            //psShape.enabled = true;
            //psShape.shapeType = ParticleSystemShapeType.BoxEdge;
            //psShape.radius = 0.01f;
            //psShape.arcMode = ParticleSystemShapeMultiModeValue.Random;
            //psShape.arcSpread = 0f;
            //psShape.texture = null;
            //psShape.alignToDirection = true;
            //psShape.randomDirectionAmount = 0f;
            //psShape.sphericalDirectionAmount = 0f;


            var psCOL = ps.colorOverLifetime;

            psCOL.enabled = true;
            psCOL.color   = new ParticleSystem.MinMaxGradient(new Gradient
            {
                mode      = GradientMode.Blend,
                alphaKeys = new[]
                {
                    new GradientAlphaKey(1f, 0f),
                    new GradientAlphaKey(0f, 1f),
                },
                colorKeys = new[]
                {
                    new GradientColorKey(Color.white, 0f),
                    new GradientColorKey(Color.white, 1f),
                }
            });


            var psSOL = ps.sizeOverLifetime;

            psSOL.enabled      = true;
            psSOL.separateAxes = true;
            psSOL.x            = new ParticleSystem.MinMaxCurve(1f, AnimationCurve.EaseInOut(0f, 1f, 1f, 0f));
            psSOL.y            = new ParticleSystem.MinMaxCurve(1f, AnimationCurve.EaseInOut(0f, 1f, 1f, 0f));
            psSOL.z            = new ParticleSystem.MinMaxCurve(1f, AnimationCurve.EaseInOut(0.5f, 1f, 1f, 0.75f));
            //psSOL.size = new ParticleSystem.MinMaxCurve( 1f, AnimationCurve.Linear( 0f, 0.5f, 1f, 1f ) );

            var psROL = ps.rotationOverLifetime;

            psROL.enabled      = true;
            psROL.separateAxes = true;
            psROL.x            = 0f;
            psROL.y            = new ParticleSystem.MinMaxCurve(Mathf.PI * 0.75f * 3f, Mathf.PI * 1.25f * 3f);
            psROL.z            = 0f;


            psr.renderMode = ParticleSystemRenderMode.Mesh;
            psr.mesh       = AssetsCore.LoadAsset <Mesh>(MeshIndex.Spiral1);
            //psr.normalDirection = 1f;
            //psr.sortMode = ParticleSystemSortMode.None;
            //psr.minParticleSize = 0f;
            //psr.maxParticleSize = 1.04f;
            psr.alignment = ParticleSystemRenderSpace.World;
            //psr.flip = Vector3.zero;
            psr.enableGPUInstancing = true;
            //psr.allowRoll = true;
            //psr.pivot = Vector3.zero;
            psr.maskInteraction = SpriteMaskInteraction.None;
            //psr.SetActiveVertexStreams( null );
            //psr.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
            //psr.receiveShadows = true;
            //psr.shadowBias = 0f;
            //psr.motionVectorGenerationMode = MotionVectorGenerationMode.Object;
            //psr.sortingLayerID = default;
            //psr.sortingOrder = 0;
            //psr.lightProbeUsage = UnityEngine.Rendering.LightProbeUsage.BlendProbes;
            //psr.reflectionProbeUsage = UnityEngine.Rendering.ReflectionProbeUsage.Simple;
            //psr.probeAnchor = null;

            return(ps);
        }
Example #6
0
        internal static ParticleSystem AddSparks(GameObject mainObj, WispSkinnedEffect skin, MaterialType matType, Int32 count, Single size, Single lifetime)
        {
            var burstOn = count > 0;

            if (!sparkCounter.ContainsKey(mainObj))
            {
                sparkCounter[mainObj] = 0u;
            }
            var obj = new GameObject("Sparks" + sparkCounter[mainObj]++);

            obj.transform.parent        = mainObj.transform;
            obj.transform.localPosition = Vector3.zero;
            obj.transform.localScale    = Vector3.one;
            obj.transform.localRotation = Quaternion.identity;

            var ps  = obj.AddComponent <ParticleSystem>();
            var psr = obj.AddOrGetComponent <ParticleSystemRenderer>();

            if (matType != MaterialType.Constant)
            {
                skin.AddRenderer(psr, matType);
            }


            BasicSetup(ps);

            ps.useAutoRandomSeed = true;

            var psMain = ps.main;

            psMain.duration            = lifetime * 2f;
            psMain.loop                = false;
            psMain.startDelay          = 0f;
            psMain.startLifetime       = new ParticleSystem.MinMaxCurve(lifetime * 0.75f, lifetime * 1.25f);
            psMain.startSpeed          = new ParticleSystem.MinMaxCurve(1f, 3f);
            psMain.startSize3D         = false;
            psMain.startSize           = new ParticleSystem.MinMaxCurve(size * 0.75f, size * 1.25f);
            psMain.startRotation3D     = false;
            psMain.startRotation       = 0f;
            psMain.flipRotation        = 0f;
            psMain.startColor          = Color.white;
            psMain.gravityModifier     = 0f;
            psMain.simulationSpace     = ParticleSystemSimulationSpace.World;
            psMain.useUnscaledTime     = false;
            psMain.scalingMode         = ParticleSystemScalingMode.Hierarchy;
            psMain.playOnAwake         = true;
            psMain.emitterVelocityMode = ParticleSystemEmitterVelocityMode.Transform;
            psMain.maxParticles        = Mathf.Abs(count) * 2;
            psMain.stopAction          = ParticleSystemStopAction.None;
            psMain.cullingMode         = ParticleSystemCullingMode.AlwaysSimulate;
            psMain.ringBufferMode      = ParticleSystemRingBufferMode.Disabled;

            var psEmis = ps.emission;

            psEmis.enabled = true;
            if (burstOn)
            {
                psEmis.burstCount = 1;
                psEmis.SetBurst(0, new ParticleSystem.Burst(0f, count));
                psEmis.rateOverTime     = 0f;
                psEmis.rateOverDistance = 0f;
            }
            else
            {
                psEmis.burstCount                 = 0;
                psEmis.rateOverTime               = 50f;
                psEmis.rateOverDistance           = 0f;
                psEmis.rateOverTimeMultiplier     = 1f;
                psEmis.rateOverDistanceMultiplier = 1f;
            }


            var psShape = ps.shape;

            psShape.enabled                  = false;
            psShape.arcMode                  = ParticleSystemShapeMultiModeValue.Random;
            psShape.arcSpread                = 0f;
            psShape.texture                  = null;
            psShape.position                 = Vector3.zero;
            psShape.rotation                 = Vector3.zero;
            psShape.scale                    = Vector3.one;
            psShape.randomDirectionAmount    = 0f;
            psShape.randomPositionAmount     = 0f;
            psShape.sphericalDirectionAmount = 0f;
            //psShape.

            var psLimVOL = ps.limitVelocityOverLifetime;

            psLimVOL.enabled      = true;
            psLimVOL.separateAxes = false;
            psLimVOL.limit        = 1f;
            psLimVOL.dampen       = 0.1f;
            psLimVOL.drag         = 0f;
            psLimVOL.multiplyDragByParticleSize     = true;
            psLimVOL.multiplyDragByParticleVelocity = true;

            var psCOL = ps.colorOverLifetime;

            psCOL.enabled = true;
            psCOL.color   = new ParticleSystem.MinMaxGradient(new Gradient
            {
                mode      = GradientMode.Blend,
                alphaKeys = new[]
                {
                    new GradientAlphaKey(1f, 0f),
                    new GradientAlphaKey(0f, 1f),
                },
                colorKeys = new[]
                {
                    new GradientColorKey(Color.white, 0f),
                    new GradientColorKey(Color.white, 1f),
                },
            });

            var psNoise = ps.noise;

            psNoise.enabled          = true;
            psNoise.separateAxes     = false;
            psNoise.strength         = 2f;
            psNoise.frequency        = 0.5f;
            psNoise.scrollSpeed      = 0f;
            psNoise.damping          = false;
            psNoise.octaveCount      = 1;
            psNoise.octaveMultiplier = 0.5f;
            psNoise.octaveScale      = 2f;
            psNoise.quality          = ParticleSystemNoiseQuality.Medium;
            psNoise.remapEnabled     = false;
            psNoise.positionAmount   = 1f;
            psNoise.rotationAmount   = 0f;
            psNoise.sizeAmount       = 0f;



            psr.renderMode      = ParticleSystemRenderMode.Billboard;
            psr.normalDirection = 1f;
            psr.sortMode        = ParticleSystemSortMode.None;
            psr.minParticleSize = 0f;
            psr.maxParticleSize = size;
            psr.alignment       = ParticleSystemRenderSpace.View;
            psr.flip            = Vector3.zero;
            psr.allowRoll       = true;
            psr.pivot           = Vector3.zero;
            psr.maskInteraction = SpriteMaskInteraction.None;
            //psr.SetActiveVertexStreams( null );
            psr.shadowCastingMode          = UnityEngine.Rendering.ShadowCastingMode.Off;
            psr.receiveShadows             = true;
            psr.shadowBias                 = 0f;
            psr.motionVectorGenerationMode = MotionVectorGenerationMode.Object;
            psr.sortingLayerID             = default;
            psr.sortingOrder               = 0;
            psr.lightProbeUsage            = UnityEngine.Rendering.LightProbeUsage.BlendProbes;
            psr.reflectionProbeUsage       = UnityEngine.Rendering.ReflectionProbeUsage.Simple;
            psr.probeAnchor                = null;

            return(ps);
        }
Example #7
0
        internal static ParticleSystem AddFlashLines(GameObject mainObj, WispSkinnedEffect skin, MaterialType matType, Int32 count, Single lifetime, Single size = 0.5f, Single speed = 15f)
        {
            if (!flashLinesCounter.ContainsKey(mainObj))
            {
                flashLinesCounter[mainObj] = 0u;
            }
            var obj = new GameObject("FlashLines" + flashLinesCounter[mainObj]++);

            obj.transform.parent        = mainObj.transform;
            obj.transform.localPosition = Vector3.zero;
            obj.transform.localScale    = Vector3.one;
            obj.transform.localRotation = Quaternion.identity;

            var ps  = obj.AddComponent <ParticleSystem>();
            var psr = obj.AddOrGetComponent <ParticleSystemRenderer>();

            if (matType != MaterialType.Constant)
            {
                skin.AddRenderer(psr, matType);
            }
            BasicSetup(ps);

            ps.useAutoRandomSeed = true;

            var psMain = ps.main;

            psMain.duration            = 2f;
            psMain.loop                = false;
            psMain.startDelay          = 0f;
            psMain.startLifetime       = new ParticleSystem.MinMaxCurve(lifetime * 0.75f, lifetime * 1.25f);
            psMain.startSpeed          = new ParticleSystem.MinMaxCurve(speed * 0.75f, speed * 1.25f);
            psMain.startSize3D         = false;
            psMain.startSize           = size;
            psMain.startRotation3D     = false;
            psMain.startRotation       = 0f;
            psMain.flipRotation        = 0f;
            psMain.startColor          = Color.white;
            psMain.gravityModifier     = 0f;
            psMain.simulationSpace     = ParticleSystemSimulationSpace.Local;
            psMain.useUnscaledTime     = false;
            psMain.scalingMode         = ParticleSystemScalingMode.Hierarchy;
            psMain.playOnAwake         = true;
            psMain.emitterVelocityMode = ParticleSystemEmitterVelocityMode.Transform;
            psMain.maxParticles        = count * 2;
            psMain.stopAction          = ParticleSystemStopAction.None;
            psMain.cullingMode         = ParticleSystemCullingMode.PauseAndCatchup;
            psMain.ringBufferMode      = ParticleSystemRingBufferMode.Disabled;

            var psEmis = ps.emission;

            psEmis.enabled    = true;
            psEmis.burstCount = 1;
            psEmis.SetBurst(0, new ParticleSystem.Burst(0f, count));
            psEmis.rateOverTime     = 0f;
            psEmis.rateOverDistance = 0f;

            var psShape = ps.shape;

            psShape.enabled                  = false;
            psShape.arcMode                  = ParticleSystemShapeMultiModeValue.Random;
            psShape.arcSpread                = 0f;
            psShape.texture                  = null;
            psShape.position                 = Vector3.zero;
            psShape.rotation                 = Vector3.zero;
            psShape.scale                    = Vector3.one;
            psShape.randomDirectionAmount    = 0f;
            psShape.randomPositionAmount     = 0f;
            psShape.sphericalDirectionAmount = 0f;

            var psCOL = ps.colorOverLifetime;

            psCOL.enabled = true;
            psCOL.color   = new ParticleSystem.MinMaxGradient(new Gradient
            {
                mode      = GradientMode.Blend,
                alphaKeys = new[]
                {
                    new GradientAlphaKey(1f, 0f),
                    new GradientAlphaKey(0f, 1f),
                },
                colorKeys = new[]
                {
                    new GradientColorKey(Color.white, 0f),
                    new GradientColorKey(Color.white, 1f),
                },
            });

            var psSOL = ps.sizeOverLifetime;

            psSOL.enabled      = true;
            psSOL.separateAxes = true;
            psSOL.x            = new ParticleSystem.MinMaxCurve(1f, AnimationCurve.EaseInOut(0f, 1f, 1f, 0f));
            psSOL.y            = 1f;
            psSOL.z            = 1f;


            psr.renderMode          = ParticleSystemRenderMode.Stretch;
            psr.cameraVelocityScale = 0f;
            psr.velocityScale       = -1.27f;
            psr.lengthScale         = 2f;
            psr.normalDirection     = 1f;
            psr.sortMode            = ParticleSystemSortMode.None;
            psr.sortingFudge        = -20;
            psr.minParticleSize     = 0f;
            psr.maxParticleSize     = 1.04f;
            psr.flip            = Vector3.zero;
            psr.pivot           = new Vector3(0f, -2.03f, 0f);
            psr.maskInteraction = SpriteMaskInteraction.None;
            //psr.SetActiveVertexStreams( null );
            psr.shadowCastingMode          = UnityEngine.Rendering.ShadowCastingMode.Off;
            psr.receiveShadows             = true;
            psr.shadowBias                 = 0f;
            psr.motionVectorGenerationMode = MotionVectorGenerationMode.Object;
            psr.sortingLayerID             = default;
            psr.sortingOrder               = 0;
            psr.lightProbeUsage            = UnityEngine.Rendering.LightProbeUsage.BlendProbes;
            psr.reflectionProbeUsage       = UnityEngine.Rendering.ReflectionProbeUsage.Simple;
            psr.probeAnchor                = null;

            return(ps);
        }
Example #8
0
        internal static ParticleSystem AddDistortion(GameObject mainObj, WispSkinnedEffect skin, MaterialType matType, Single radius, Single duration, Single spinSpeed)
        {
            if (!distortionCounter.ContainsKey(mainObj))
            {
                distortionCounter[mainObj] = 0u;
            }
            var obj = new GameObject("Distortion" + distortionCounter[mainObj]++);

            obj.transform.parent        = mainObj.transform;
            obj.transform.localPosition = Vector3.zero;
            obj.transform.localScale    = Vector3.one;
            obj.transform.localRotation = Quaternion.identity;

            var ps  = obj.AddComponent <ParticleSystem>();
            var psr = obj.AddOrGetComponent <ParticleSystemRenderer>();

            if (matType != MaterialType.Constant)
            {
                skin.AddRenderer(psr, matType);
            }


            BasicSetup(ps);

            ps.useAutoRandomSeed = true;

            var psMain = ps.main;

            psMain.duration            = duration * 2f;
            psMain.loop                = false;
            psMain.startDelay          = 0f;
            psMain.startLifetime       = new ParticleSystem.MinMaxCurve(duration * 0.75f, duration * 1.25f);
            psMain.startSpeed          = 0f;
            psMain.startSize3D         = false;
            psMain.startSize           = new ParticleSystem.MinMaxCurve(radius * 0.75f, radius * 1.25f);
            psMain.startRotation3D     = false;
            psMain.startRotation       = 0f;
            psMain.flipRotation        = 0f;
            psMain.startColor          = Color.white;
            psMain.gravityModifier     = 0f;
            psMain.simulationSpace     = ParticleSystemSimulationSpace.World;
            psMain.useUnscaledTime     = false;
            psMain.scalingMode         = ParticleSystemScalingMode.Hierarchy;
            psMain.playOnAwake         = true;
            psMain.emitterVelocityMode = ParticleSystemEmitterVelocityMode.Transform;
            psMain.maxParticles        = 100000;
            psMain.stopAction          = ParticleSystemStopAction.None;
            psMain.cullingMode         = ParticleSystemCullingMode.AlwaysSimulate;
            psMain.ringBufferMode      = ParticleSystemRingBufferMode.Disabled;

            var psEmis = ps.emission;

            psEmis.enabled          = false;
            psEmis.burstCount       = 0;
            psEmis.rateOverDistance = 0f;
            psEmis.rateOverTime     = 0f;


            var psShape = ps.shape;

            psShape.enabled                  = false;
            psShape.arcMode                  = ParticleSystemShapeMultiModeValue.Random;
            psShape.arcSpread                = 0f;
            psShape.texture                  = null;
            psShape.position                 = Vector3.zero;
            psShape.rotation                 = Vector3.zero;
            psShape.scale                    = Vector3.one;
            psShape.randomDirectionAmount    = 0f;
            psShape.randomPositionAmount     = 0f;
            psShape.sphericalDirectionAmount = 0f;
            //psShape.


            var psSOL = ps.sizeOverLifetime;

            psSOL.enabled = true;
            psSOL.size    = new ParticleSystem.MinMaxCurve(radius, AnimationCurve.EaseInOut(0f, 1f, 1f, 0f));

            var psROL = ps.rotationOverLifetime;

            psROL.enabled      = true;
            psROL.separateAxes = true;
            psROL.x            = 0f;
            psROL.y            = 0f;
            psROL.z            = spinSpeed;



            psr.renderMode      = ParticleSystemRenderMode.Billboard;
            psr.normalDirection = 1f;
            psr.sortMode        = ParticleSystemSortMode.None;
            psr.minParticleSize = 0f;
            psr.maxParticleSize = radius * 2f;
            psr.alignment       = ParticleSystemRenderSpace.View;
            psr.flip            = Vector3.zero;
            psr.allowRoll       = true;
            psr.pivot           = Vector3.zero;
            psr.maskInteraction = SpriteMaskInteraction.None;
            //psr.SetActiveVertexStreams( null );
            psr.shadowCastingMode          = UnityEngine.Rendering.ShadowCastingMode.Off;
            psr.receiveShadows             = true;
            psr.shadowBias                 = 0f;
            psr.motionVectorGenerationMode = MotionVectorGenerationMode.Object;
            psr.sortingLayerID             = default;
            psr.sortingOrder               = 0;
            psr.lightProbeUsage            = UnityEngine.Rendering.LightProbeUsage.BlendProbes;
            psr.reflectionProbeUsage       = UnityEngine.Rendering.ReflectionProbeUsage.Simple;
            psr.probeAnchor                = null;

            return(ps);
        }
Example #9
0
        internal static ParticleSystem AddArcaneCircle(GameObject mainObj, WispSkinnedEffect skin, MaterialType matType, Single size, Single lifetime)
        {
            if (!arcaneCircleCounter.ContainsKey(mainObj))
            {
                arcaneCircleCounter[mainObj] = 0u;
            }
            var obj = new GameObject("ArcaneCircle" + arcaneCircleCounter[mainObj]++);

            obj.transform.parent        = mainObj.transform;
            obj.transform.localPosition = Vector3.zero;
            obj.transform.localScale    = Vector3.one;
            obj.transform.localRotation = Quaternion.identity;

            //var rb = obj.AddComponent<Rigidbody>();
            //rb.useGravity = false;
            //rb.isKinematic = false;
            //rb.interpolation = RigidbodyInterpolation.Extrapolate;

            var ps  = obj.AddComponent <ParticleSystem>();
            var psr = obj.AddOrGetComponent <ParticleSystemRenderer>();

            if (matType != MaterialType.Constant)
            {
                skin.AddRenderer(psr, matType);
            }
            BasicSetup(ps);

            ps.useAutoRandomSeed = true;

            var psMain = ps.main;

            psMain.duration            = lifetime * 2;
            psMain.loop                = true;
            psMain.startDelay          = 0f;
            psMain.startLifetime       = lifetime;
            psMain.startSpeed          = 0f;
            psMain.startSize3D         = false;
            psMain.startSize           = size;
            psMain.startRotation3D     = false;
            psMain.startRotation       = 0f;
            psMain.flipRotation        = 0f;
            psMain.startColor          = Color.white;
            psMain.gravityModifier     = 0f;
            psMain.simulationSpace     = ParticleSystemSimulationSpace.World;
            psMain.useUnscaledTime     = false;
            psMain.scalingMode         = ParticleSystemScalingMode.Hierarchy;
            psMain.playOnAwake         = true;
            psMain.emitterVelocityMode = ParticleSystemEmitterVelocityMode.Rigidbody;
            psMain.maxParticles        = 10000;
            psMain.stopAction          = ParticleSystemStopAction.None;
            psMain.cullingMode         = ParticleSystemCullingMode.AlwaysSimulate;
            psMain.ringBufferMode      = ParticleSystemRingBufferMode.Disabled;

            var psEmis = ps.emission;

            psEmis.enabled          = true;
            psEmis.rateOverTime     = 0f;
            psEmis.rateOverDistance = 0f;
            psEmis.burstCount       = 0;

            var psShape = ps.shape;

            psShape.enabled                  = false;
            psShape.arcMode                  = ParticleSystemShapeMultiModeValue.Random;
            psShape.arcSpread                = 0f;
            psShape.texture                  = null;
            psShape.position                 = Vector3.zero;
            psShape.rotation                 = Vector3.zero;
            psShape.scale                    = Vector3.one;
            psShape.randomDirectionAmount    = 0f;
            psShape.randomPositionAmount     = 0f;
            psShape.sphericalDirectionAmount = 0f;

            var psCOL = ps.colorOverLifetime;

            psCOL.enabled = true;
            psCOL.color   = new ParticleSystem.MinMaxGradient(new Gradient
            {
                mode      = GradientMode.Blend,
                alphaKeys = new[]
                {
                    new GradientAlphaKey(1f, 0f),
                    new GradientAlphaKey(0f, 1f),
                },
                colorKeys = new[]
                {
                    new GradientColorKey(Color.white, 0f),
                    new GradientColorKey(Color.white, 1f),
                },
            });

            var psSOL = ps.sizeOverLifetime;

            psSOL.enabled = true;
            psSOL.size    = new ParticleSystem.MinMaxCurve(1f, AnimationCurve.EaseInOut(0f, 1f, 1f, 0f));


            psr.renderMode      = ParticleSystemRenderMode.Mesh;
            psr.mesh            = AssetsCore.LoadAsset <Mesh>(MeshIndex.Quad);
            psr.normalDirection = 1f;
            psr.sortMode        = ParticleSystemSortMode.None;
            psr.minParticleSize = 0f;
            psr.maxParticleSize = 1.04f;
            psr.alignment       = ParticleSystemRenderSpace.Local;
            psr.flip            = Vector3.zero;
            psr.allowRoll       = true;
            psr.pivot           = Vector3.zero;
            psr.maskInteraction = SpriteMaskInteraction.None;
            //psr.SetActiveVertexStreams( null );
            psr.shadowCastingMode          = UnityEngine.Rendering.ShadowCastingMode.Off;
            psr.receiveShadows             = true;
            psr.shadowBias                 = 0f;
            psr.motionVectorGenerationMode = MotionVectorGenerationMode.Object;
            psr.sortingLayerID             = default;
            psr.sortingOrder               = 0;
            psr.lightProbeUsage            = UnityEngine.Rendering.LightProbeUsage.BlendProbes;
            psr.reflectionProbeUsage       = UnityEngine.Rendering.ReflectionProbeUsage.Simple;
            psr.probeAnchor                = null;

            return(ps);
        }
Example #10
0
        internal static ParticleSystem AddFlash(GameObject mainObj, WispSkinnedEffect skin, MaterialType matType, Single size = 10f)
        {
            if (!flashCounter.ContainsKey(mainObj))
            {
                flashCounter[mainObj] = 0u;
            }
            var obj = new GameObject("Flash" + flashCounter[mainObj]++);

            obj.transform.parent        = mainObj.transform;
            obj.transform.localPosition = Vector3.zero;
            obj.transform.localScale    = Vector3.one;
            obj.transform.localRotation = Quaternion.identity;

            var ps  = obj.AddComponent <ParticleSystem>();
            var psr = obj.AddOrGetComponent <ParticleSystemRenderer>();

            if (matType != MaterialType.Constant)
            {
                skin.AddRenderer(psr, matType);
            }


            BasicSetup(ps);

            ps.useAutoRandomSeed = true;

            var psMain = ps.main;

            psMain.duration            = 2f;
            psMain.loop                = false;
            psMain.startDelay          = 0f;
            psMain.startLifetime       = 0.1f;
            psMain.startSpeed          = 0f;
            psMain.startSize3D         = false;
            psMain.startSize           = size;
            psMain.startRotation3D     = false;
            psMain.startRotation       = 0f;
            psMain.flipRotation        = 0f;
            psMain.startColor          = Color.white;
            psMain.gravityModifier     = 0f;
            psMain.simulationSpace     = ParticleSystemSimulationSpace.Local;
            psMain.useUnscaledTime     = false;
            psMain.scalingMode         = ParticleSystemScalingMode.Hierarchy;
            psMain.playOnAwake         = true;
            psMain.emitterVelocityMode = ParticleSystemEmitterVelocityMode.Transform;
            psMain.maxParticles        = 1;
            psMain.stopAction          = ParticleSystemStopAction.None;
            psMain.cullingMode         = ParticleSystemCullingMode.PauseAndCatchup;
            psMain.ringBufferMode      = ParticleSystemRingBufferMode.Disabled;

            var psEmis = ps.emission;

            psEmis.enabled    = true;
            psEmis.burstCount = 1;
            psEmis.SetBurst(0, new ParticleSystem.Burst(0f, 1));
            psEmis.rateOverTime     = 0f;
            psEmis.rateOverDistance = 0f;

            var psCOL = ps.colorOverLifetime;

            psCOL.enabled = true;
            psCOL.color   = new ParticleSystem.MinMaxGradient(new Gradient
            {
                mode      = GradientMode.Blend,
                alphaKeys = new[]
                {
                    new GradientAlphaKey(0f, 0f),
                    new GradientAlphaKey(1f, 0.35f),
                    new GradientAlphaKey(0.2f, 1f),
                }
            });

            var psSOL = ps.sizeOverLifetime;

            psSOL.enabled = true;
            psSOL.size    = new ParticleSystem.MinMaxCurve(1f, AnimationCurve.Linear(0f, 0.5f, 1f, 1f));


            psr.renderMode      = ParticleSystemRenderMode.Billboard;
            psr.normalDirection = 1f;
            psr.sortMode        = ParticleSystemSortMode.None;
            psr.minParticleSize = 0f;
            psr.maxParticleSize = 1.04f;
            psr.alignment       = ParticleSystemRenderSpace.View;
            psr.flip            = Vector3.zero;
            psr.allowRoll       = true;
            psr.pivot           = Vector3.zero;
            psr.maskInteraction = SpriteMaskInteraction.None;
            //psr.SetActiveVertexStreams( null );
            psr.shadowCastingMode          = UnityEngine.Rendering.ShadowCastingMode.Off;
            psr.receiveShadows             = true;
            psr.shadowBias                 = 0f;
            psr.motionVectorGenerationMode = MotionVectorGenerationMode.Object;
            psr.sortingLayerID             = default;
            psr.sortingOrder               = 0;
            psr.lightProbeUsage            = UnityEngine.Rendering.LightProbeUsage.BlendProbes;
            psr.reflectionProbeUsage       = UnityEngine.Rendering.ReflectionProbeUsage.Simple;
            psr.probeAnchor                = null;

            return(ps);
        }