예제 #1
0
        public static void ConvertTrailToBender(MenuCommand cmd)
        {
            TrailRenderer t = (TrailRenderer)cmd.context;

            if (!t.gameObject.GetComponent <GrassBender>())
            {
                GrassBender bender = t.gameObject.AddComponent <GrassBender>();

                bender.benderType    = GrassBenderBase.BenderType.Trail;
                bender.trailRenderer = t;
            }
        }
예제 #2
0
        public static void ConvertParticleToBender(MenuCommand cmd)
        {
            ParticleSystem ps = (ParticleSystem)cmd.context;

            if (!ps.gameObject.GetComponent <GrassBender>())
            {
                GrassBender bender = ps.gameObject.AddComponent <GrassBender>();

                bender.benderType     = GrassBenderBase.BenderType.ParticleSystem;
                bender.particleSystem = ps.GetComponent <ParticleSystem>();

                GrassBenderBase.ValidateParticleSystem(bender);
            }
        }
예제 #3
0
        public static void ConvertMeshToBender(MenuCommand cmd)
        {
            MeshFilter   mf = (MeshFilter)cmd.context;
            MeshRenderer mr = mf.gameObject.GetComponent <MeshRenderer>();

            if (!mf.gameObject.GetComponent <GrassBender>())
            {
                GrassBender bender = mf.gameObject.AddComponent <GrassBender>();

                bender.benderType   = GrassBenderBase.BenderType.Mesh;
                bender.meshFilter   = mf;
                bender.meshRenderer = mr;
            }
        }
예제 #4
0
        public static void ValidateParticleSystem(GrassBender b)
        {
            if (!b.particleSystem)
            {
                return;
            }

            if (!b.particleRenderer)
            {
                b.particleRenderer = b.particleSystem.GetComponent <ParticleSystemRenderer>();
            }

            b.psGrad            = b.particleSystem.colorOverLifetime;
            b.hasParticleTrails = b.particleSystem.trails.enabled;
        }
예제 #5
0
        public static void UnRegisterBender(GrassBender gb)
        {
            if (GrassBenders.ContainsKey(gb.sortingLayer))
            {
                GrassBenders.TryGetValue(gb.sortingLayer, out BenderLayer);

                BenderLayer.Remove(gb);
                benderCount--;

                //If layer is now empty, remove it
                if (GrassBenders[gb.sortingLayer].Count == 0)
                {
                    GrassBenders.Remove(gb.sortingLayer);
                }
            }
        }
        private void OnEnable()
        {
            bender = (GrassBender)target;

            benderType      = serializedObject.FindProperty("benderType");
            m_benderType    = benderType.intValue;
            strength        = serializedObject.FindProperty("strength");
            heightOffset    = serializedObject.FindProperty("heightOffset");
            scaleMultiplier = serializedObject.FindProperty("scaleMultiplier");
            pushStrength    = serializedObject.FindProperty("pushStrength");
            alphaBlending   = serializedObject.FindProperty("alphaBlending");

            meshFilter    = serializedObject.FindProperty("meshFilter");
            meshRenderer  = serializedObject.FindProperty("meshRenderer");
            trailRenderer = serializedObject.FindProperty("trailRenderer");

            particleSystem       = serializedObject.FindProperty("particleSystem");
            trailLifetime        = serializedObject.FindProperty("trailLifetime");
            trailRadius          = serializedObject.FindProperty("trailRadius");
            strengthOverLifetime = serializedObject.FindProperty("strengthOverLifetime");
            widthOverLifetime    = serializedObject.FindProperty("widthOverLifetime");
        }
예제 #7
0
        public static void RegisterBender(GrassBender gb)
        {
            if (GrassBenders.ContainsKey(gb.sortingLayer))
            {
                GrassBenders.TryGetValue(gb.sortingLayer, out BenderLayer);

                if (BenderLayer.Contains(gb) == false)
                {
                    BenderLayer.Add(gb);
                    GrassBenders[gb.sortingLayer] = BenderLayer;
                    benderCount++;
                }
            }
            //Create new layer
            else
            {
                BenderLayer = new List <GrassBender>();
                BenderLayer.Add(gb);

                GrassBenders.Add(gb.sortingLayer, BenderLayer);
                benderCount++;
            }
        }