
This is useful for a number of reasons, but mainly provides a centralized place to manage all input and to coordinate clicks according to game state.


This works fine but it requires a script on the GameObject itself, and may require synchronization within the game when there are many clickable objects.Īnother method, and the one we’ll be going over in this post, is to use a single script to manage all clicks throughout the game. Pimp my Debug.Log: an interesting set of method extensions for the string class, perfect for Posts Animating Rotations through Code in Unity Synchronizing Idle, Walk and Run animations with a NavMeshAgent in Unity Siren Song, Devlog #3: But With More Dogs Unity: Working with Custom HLSL Functions in Shader Graph Unity: Accessing Private and Protected Fields from the Inspectorįrequently in Unity you’ll see OnMouseDown used to detect clicks on GameObjects.WWDebugWindow: a simple, yet powerful script to write to the console.mminer Console: another script for in-game console.DebugConsole: a scrolling, interactive debug console that you can use directly in your games.By creating a GUIStyle object with the richText parameters set to true, we can draw some formatted text: While DrawDefaultInspector draws the inspector for the current object, GUILayout.Label adds a text to it. GUILayout.Label("This is a CUSTOM text", style) Public static string Log (params object data)įor (int i = 0 i This is a CUSTOM text", style) Let’s see what we can do about these things. Something which bothers me deeply is the way the Debug.Log function has to be fed. There are two main problems here: (1) Debug.Log takes a single string and (2) its console output is quite chunky and doesn’t really allow for multi-lines. We will see later how to improve Debug even further.įor a full list of the supported colours, you can check this page. Unity supports for italic, for bold and to change the pixel size. So, for instance:Īdding the tag does the trick. As reported in its documentation, it supports rich text tags. The standard logging function provided by Unity is Debug.Log.
