コード例 #1
0
 public static void Scale(ParticleSystem particles, float scale, bool includeChildren = true, ParticleScalerOptions options = null) {
     ScaleSystem(particles, scale, false, options);
     if (includeChildren) {
         var children = particles.GetComponentsInChildren<ParticleSystem>(includeInactive: true);   // my includeInactive addition
         for (var i = children.Length; i-- > 0;) {
             if (children[i] == particles) { continue; }
             ScaleSystem(children[i], scale, true, options);
         }
     }
 }
コード例 #2
0
        public void Initialize(Diggable diggable)
        {
            this.diggable = diggable;

            if (diggable.DigFX != null) {
                parentFX = Instantiate(diggable.DigFX).GetComponent<ParticleSystem>();
                parentFX.transform.parent = transform;
                parentFX.enableEmission = false;
                FXs = parentFX.GetComponentsInChildren<ParticleSystem>();
                initialized = true;
            }
        }
コード例 #3
0
        public static void ScaleByTransform(ParticleSystem particles, float scale, bool includeChildren = true) {
            var mainModule = particles.main;  // particles.scalingMode = ParticleSystemScalingMode.Local; Deprecated in Unity 5.5

            mainModule.scalingMode = ParticleSystemScalingMode.Local;
            particles.transform.localScale = particles.transform.localScale * scale;
            mainModule.gravityModifierMultiplier *= scale;    //particles.gravityModifier *= scale; Deprecated in Unity 5.5
            if (includeChildren) {
                var children = particles.GetComponentsInChildren<ParticleSystem>(includeInactive: true);    // my includeInactive addition
                for (var i = children.Length; i-- > 0;) {
                    if (children[i] == particles) {
                        continue;
                    }
                    var childMainModule = children[i].main;
                    childMainModule.scalingMode = ParticleSystemScalingMode.Local;   //children[i].scalingMode = ParticleSystemScalingMode.Local; Deprecated in Unity 5.5
                    children[i].transform.localScale = children[i].transform.localScale * scale;
                    childMainModule.gravityModifierMultiplier *= scale; // children[i].gravityModifier *= scale; Deprecated in Unity 5.5
                }
            }
        }