示例#1
0
 public void SetComponentEnabled(bool state)
 {
     try
     {
         if (!state)
         {
             for (int index = 0; index < this.renderers.Length; ++index)
             {
                 Renderer renderer = this.renderers[index];
                 this.rendererStates[index] = renderer.get_enabled();
                 renderer.set_enabled(false);
             }
             for (int index = 0; index < this.lodgroups.Length; ++index)
             {
                 LODGroup lodgroup = this.lodgroups[index];
                 this.lodgroupStates[index] = lodgroup.get_enabled();
                 lodgroup.set_enabled(false);
             }
             for (int index = 0; index < this.colliders.Length; ++index)
             {
                 Collider collider = this.colliders[index];
                 this.colliderStates[index] = collider.get_enabled();
                 collider.set_enabled(false);
             }
             for (int index = 0; index < this.rigidbodies.Length; ++index)
             {
                 Rigidbody rigidbody = this.rigidbodies[index];
                 this.rigidbodyStates[index] = rigidbody.get_isKinematic();
                 rigidbody.set_isKinematic(true);
                 rigidbody.set_detectCollisions(false);
             }
         }
         else
         {
             for (int index = 0; index < this.renderers.Length; ++index)
             {
                 this.renderers[index].set_enabled(this.rendererStates[index]);
             }
             for (int index = 0; index < this.lodgroups.Length; ++index)
             {
                 this.lodgroups[index].set_enabled(this.lodgroupStates[index]);
             }
             for (int index = 0; index < this.colliders.Length; ++index)
             {
                 this.colliders[index].set_enabled(this.colliderStates[index]);
             }
             for (int index = 0; index < this.rigidbodies.Length; ++index)
             {
                 Rigidbody rigidbody = this.rigidbodies[index];
                 rigidbody.set_isKinematic(this.rigidbodyStates[index]);
                 rigidbody.set_detectCollisions(true);
             }
         }
     }
     catch (Exception ex)
     {
         Debug.LogError((object)("Pooling error: " + ((Object)this).get_name() + " (" + ex.Message + ")"));
     }
 }