User Interface Flashcards
Use TextMeshPro instead of Unity GUI Text, as it’s now a Legacy component.
TMP has multiple reasons to be used over GUI Text, including, better control, better rendering, font flexibility, etc.
You will need to install the TMP package with the package manager.
Canvas, TMP, Text and unity may auto prompt you to install the package if you have not already.
True
Buttons in unity
Buttons in unity are use for a variety of reasons, including, scene changes, bring up menus, editing settings, controlling and modify certain aspects of the game Ie, on touch screen, movement and attacking. Accessing a shop and buying items etc.
Buttons
A Standard button that can be clicked to trigger an event
Properties include
onClick, Unity event that is triggered when the button is pressed
Public methods
OnPointerClick, registered IPointerClickHandler callback
OnSubmit, registered ISubmitHandler callback
Inherited members, static properties
AllSelectables, List of all the selectable objects active in the scene
Properties Tag, Transform GameObject Name Image Colors Navigation hideFlags spriteState Transition TargetGraphic
Button public methods
BroadcastMessage CompareTag GetComponent GetComponentInChildren GetComponentInParent GetComponents Invoke CancelInvoke SendMessage isActive isDestroyed
Button static methods
Print. Logs message to the Unity console, identical to Debug.Log
Destroy. Removes a GameObject, component or asset.
DestroyImmediate, destroys the object obj immediately. You are strongly recommended to use destroy instead.
DontDestroyOnLoad. Do not destroy the target object when loading a new scene.
FindObjectOfType. Returns the first active loaded object of Type type.
FindObjectsOfType. Returns a list of all active loaded objects of Type type
Instantiate. Clones the object original and returns the clone.
Gizmos
The scene view and the game view both have a gizmos menu
Click the gizmos button in the toolbar of the scene or the game view to access the gizmos menu
Gizmos are graphics associated with Game Objects in the scene. Some Gizmos are only drawn when the GameObject is selected, while others are drawn by the editor regardless of which GameObjects are selected
Gizmos and Icons
The move, scale, rotate and transform tools are also interactive gizmos
You can implement custom Gizmos in your scripts. OnDrawGizmos functions is used for this. You can display icons in the Game view or Scene view. They are flat, billboard style overlaps which you can use to clearly indicate a GameObjects position while you work on your game.
The camera and light gizmos are examples of built in icons, you can also assign your own to GameObjects or individual scripts.
Assigning icons to Gizmos
When you change an assets icon, Unity marks the asset as modified, and version control systems register the change.
Open the item In an inspector window
Click the select icon button
Choose an icon from the select icon menu.
Assign Icons
You can assign custom icons to GameObjects, prefabs, and scripts from the inspector window. Custom icons appear in the Scene view in the same way as default icons for items such as lights and cameras
To control how unity draws custom icons in the scene view, use the Gizmos menu
When you assign an icon to a GameObject, the icon appears in the scene view over that GameObject, and any duplicates.
When you assign an icon to a prefab, the icon appears in the scene view over any instances of that prefab.
When you assign an icon to a script, the icon appears in the scene view over any GameObject that has the script attached.
To assign a custom icon to a prefab, you must open the prefab in prefab mode.
Choose icons from the select icon menu
You assign custom icons from the select icon menu. Top right in the inspector. Can be colors or other.
Icon types.
- Label icons are colored capsules. In the scene view, they display the names of the items they’re assigned to.
Click on a label to assign it - Image only icons are colored divots. They’re useful when you work with objects that may not have a visual representation. For example, you can assign image only icons to navigate way points so you can see and select them in the scene view
Click an image only icon to assign it. - Asset icons are image assets in your scene that you use as custom icons. For example, you could use a skull and crossbones icon to indicate danger areas in a game level.
Click the other button to open an object picker window and select an image asset to assign as an icon.
Toggle Debug Mode
The inspector window is configured as an editor for the selections properties.
You can toggle Debug Mode for each inspector window individually
To turn on Debug mode, click the More items button to open the context menu, and select Debug
To return to normal mode change the context menu from Debug to normal
Different editors for unity
Visual studio code Project Rider by jetbrains Atom Visual studio MonoDevelop
Layout groups in Unity
Grid layout group, grid of objects
Vertical layout group, vertical column of objects of any size
Horizontal layout group, horizontal row of object of any size