Coroutines and Crosshair Flashcards
1
Q
How do you make a coroutine?
A
IEnumerator
e.g. private IEnumerator Sphere(Vector3 pos)
2
Q
How do you pause and resume a coroutine?
A
Use the yield keyword.
Often used like:
yield return new WaitForSeconds(1)
3
Q
How do you initialise a GUI?
A
Make the function:
void OnGUI() { }
4
Q
How do you add text to the GUI?
A
GUI.Label(new Rect(posX, posY, size, size), “text”)
5
Q
How do you make a new primitive shape?
A
GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere)
6
Q
How do you delete GameObjects?
A
Destroy(GameObject)
7
Q
What are coroutines?
A
Similar to functions but executes incrementally over time instead of waiting until it is finished.