You are on page 1of 4

Exercise_EventsSOs_00

* Launch Unity Hub and create a blank new project (3D)

* Import TMP Essential Resources


* Import this Unity package: Exercise_EventsSOs_00_package

* Load scene VGVR_EventsSOs_00:

* Adjust the game screen size to see something similar to:


* Check the existing game objects (GOs) in the scene and the scripts attached to them to
understand what happens when the program is launched. Generate a diagram where the GOs
and their components are shown and the coupling between them depicted.
For example:

Method01 of ComponentX in GO_01 calls Method03 of ComponentZ in GO_02.


Method02 of ComponentZ in GO_02 calls Method03 of ComponentX in GO_01.

* Once the relationship between components and GOs is studied, and actions are understood,
now solve the compilation errors shown in the console to run the program.
* Read warnings and solve them.
* Run the program and test it thoroughly to notice any execution errors that may happen.

* FindObjectOfType<>() method is used to find the references. Be aware: time consuming!


Other methods to find a reference?
Check: GameObject.Find(), transform.Find(), GameObject.FindWithTag(),
GameObject.FindGameObjectsWithTag().

* In fact, each reference is not held and is searched again and again every time is used. Find a
way to initialize a reference once and keep it to be used when needed.
Check: try a public field and drag the target GO in the Inspector slot.

* Refactorize the code that holds the references and move it to the Start() section. Any
reference that remains unmodified can be placed there.

End of exercise --------------------------------------------

You might also like