Miscellaneous ************* Button ====== A UI Button is essentially a label with a button-like texture that can handle mouse events. * In the Hierarchy window, right click and add a **UI > Button - TextMeshPro** .. image:: button1.png :scale: 50% * Use the Rect Tool to move/enlarge/shrink the button * In the Inspector window, you can select colors for specific events: .. image:: redbutton.png :scale: 50% * In the Hierarchy, select the button * In the Inspector, find the *On Click()* Event section .. image:: _onclick.png :scale: 50% * You need to link a GameObject and one of its internal function * This function will be called when the button is clicked Variable qualifiers =================== .. code-block:: csharp class test { [SerializeField] private float speed; // show a private variable in the Inspector private const float maxspeed; // create const variable private static float nbinstances; // class variable shared among instances, write test.nbinstances [range(0f,100f)] [SerializeField] float test; // limit range values of the variable in the Inspector } Event Functions =============== .. code-block:: csharp FixedUpdate() { ... } // called at a regular pace, useful for applying forces independently of the framerate Update(){...} LateUpdate() { .. } // called after the completion of all the update() calls, useful when scripting a follow camera Awake() { ... } // called immediately after instantiation, before any call of the start() function, useful to load resources Start() { ... } // called just before the first render on screen Objects Pooling =============== Instead of instantiating and destroying lots of objects, it is more effective to create a pool of objects, activate them when needed, and deactivate them instead of destroying them. For this, we need to: * Create a bunch of objects at the beginning * Set up a list of objects in the spawn manager