Unity Coroutines: Wait a Second!

Unity Coroutines: Wait a Second!

void Whatever() { float delay = 1.0f; StartCoroutine(DoSomethingAfterWaiting(delay)); }   IEnumerator DoSomethingAfterWaiting(float delay) { yield return new WaitForSeconds(delay); // Add Code here to Do it, Do it, Do it till you’re satisfied… whatever it is yield break; }

Unity Sounds: Audio Clips

public AudioClip[] sndName; AudioSource sound = GetComponent<AudioSource>(); int sndDx = 0; float volume = .5; sound.PlayOneShot(sndName[sndDx], volume);

Unity Buttons: Disabled Color?

To ‘disable’ a Unity Button and show its disabled color, DO NOT DISABLE the button, simply set buttonName.interactable = false;

Unity Objects: To Show or Not To Show

Turn an object’s display on or off:  object.GetComponent <MeshRenderer>().enabled = true or false Turn Child object’s display on or off: foreach (Transform child in object.transform) { child.gameObject.GetComponent <MeshRenderer>().enabled = true or false; }

C# Lists

Create: List <type>   name = new  List <type>(); Add: name.Add( type/value ); Clear: name.Clear(); Number of Elements: name.Count;