using System.Collections; using UnityEngine; namespace DynamicFogAndMist { public class BonusCylinderHit : MonoBehaviour { private void OnCollisionEnter(Collision collision) { Game.instance.AnnotateScore(100); GameObject gameObject = collision.collider.gameObject; StartCoroutine(DestroyCylinder(gameObject)); Object.Destroy(gameObject.GetComponent()); gameObject.transform.Find("Sounds/Hit").GetComponent().Play(); } private IEnumerator DestroyCylinder(GameObject ball) { GetComponent().sharedMaterial.color = Color.cyan; for (int k = 10; k > 0; k++) { base.transform.localScale *= 0.8f; yield return new WaitForSeconds(0.1f); if (ball != null) { ball.GetComponent().enabled = !ball.GetComponent().enabled; } } Object.Destroy(ball); Object.Destroy(base.gameObject); } } }