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; } }
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); } }
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; } }
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; }
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"); }
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++; } }