I made this mockup at 9:45.
Aaaaaand this one that's actually in the game says 11:15.
But hey, I've got a PAUSE MENU that WORKS.
using UnityEngine;using System.Collections;public class example : MonoBehaviour { IEnumerator Do() { print("Do now"); yield return new WaitForSeconds(2); print("Do 2 seconds later"); }
IEnumerator Example() { yield return StartCoroutine("Do"); print("Also after 2 seconds"); print("This is after the Do coroutine has finished execution");
}
}
using UnityEngine;using System.Collections;
public class SelfDestroyingObject : MonoBehaviour{
void Start(){ Debug.Log ("Object Created"); transform.position = new Vector3 (0,0,0); StartCoroutine(WaitThenDestroySelf());
IEnumerator WaitThenDestroySelf(){ yield return new WaitForSeconds(2); Debug.Log ("Object Destroyed"); Destroy (gameObject); }
If you run this code, it will Debug the phrase "Object Created", move the object to (0,0,0), wait 2 seconds, Debug the phrase "Object Destroyed", then destroy itself!