Exemple #1
0
 public static void AdjustParticlesToWorld(GameObject oModel)
 {
     if (oModel == null)
     {
         return;
     }
     ParticleSystem[] componentsInChildren = oModel.GetComponentsInChildren <ParticleSystem>(true);
     if (componentsInChildren != null)
     {
         for (int i = 0; i < componentsInChildren.Length; i++)
         {
             ParticleSystem particleSystem = componentsInChildren[i];
             if (particleSystem.transform.gameObject.layer == LayerMask.NameToLayer("UIEffect"))
             {
                 int hashCode = particleSystem.transform.GetHashCode();
                 if (NGUITools.mAdjustTransDict.ContainsKey(hashCode))
                 {
                     NGUITools.ParticleInfo particleInfo = NGUITools.mAdjustTransDict[hashCode];
                     particleSystem.startSize       = particleInfo.fStartSize;
                     particleSystem.startSpeed      = particleInfo.fStartSpeed;
                     particleSystem.maxParticles    = particleInfo.iMaxParticles;
                     particleSystem.gravityModifier = particleInfo.fGravityModifier;
                     ParticleSystemRenderer component = particleSystem.GetComponent <ParticleSystemRenderer>();
                     if (component)
                     {
                         component.maxParticleSize = particleInfo.fMaxParticleSize;
                     }
                     NGUITools.mAdjustTransDict.Remove(hashCode);
                 }
                 particleSystem.transform.gameObject.layer = LayerMask.NameToLayer("UI");
             }
         }
     }
 }
Exemple #2
0
 public static void AdjustParticlesToUI(GameObject oModel, float scaleRate)
 {
     if (oModel == null)
     {
         return;
     }
     ParticleSystem[] componentsInChildren = oModel.GetComponentsInChildren <ParticleSystem>(true);
     for (int i = 0; i < componentsInChildren.Length; i++)
     {
         ParticleSystem particleSystem = componentsInChildren[i];
         if (particleSystem != null)
         {
             NGUITools.ParticleInfo zero = NGUITools.ParticleInfo.Zero;
             zero.fStartSize                 = particleSystem.startSize;
             zero.fStartSpeed                = particleSystem.startSpeed;
             zero.iMaxParticles              = particleSystem.maxParticles;
             zero.fScaleRate                 = scaleRate;
             zero.fGravityModifier           = particleSystem.gravityModifier;
             particleSystem.startSize       *= scaleRate;
             particleSystem.startSpeed      *= scaleRate;
             particleSystem.gravityModifier *= scaleRate;
             ParticleSystemRenderer component = particleSystem.GetComponent <ParticleSystemRenderer>();
             if (component)
             {
                 zero.fMaxParticleSize      = component.maxParticleSize;
                 component.maxParticleSize *= scaleRate;
             }
             int hashCode = particleSystem.transform.GetHashCode();
             if (!NGUITools.mAdjustTransDict.ContainsKey(hashCode))
             {
                 NGUITools.mAdjustTransDict.Add(hashCode, zero);
             }
             particleSystem.transform.gameObject.layer = LayerMask.NameToLayer("UIEffect");
         }
     }
 }