Expanded uses of Unity UI button functions

Wanting a simple way to work with Unity UI, but limited to the functions of what buttons can do, or work without raycasting to objects attached to the camera?  Unity’s UI for buttons offer useful functionality, although limited.  By default, the UI will be able run such functions as checking, changing the tag and active status of other game objects as well as it’s attached with ease.  It can be simple once the correct navigation is properly setup through the button options and their menus. Unfortunately, more complex functions of the button are more difficult to use, involving some editing or heavy modifications into the script.  Getting the more complex functions working may be easier with focusing entirely on the On-click or mouse down functions within the code.  Multiple issues may arise with the On-click and mouse down function, needing to be applied in a scene with no raycasts to accept the mouse, cursor, or tapping gesture to register the input.  Using a specific area for UI, makes the process easier and better organized, while keeping a clean appearance to the coding syntax.  The UI’s button would then be able to run its functions if need be, as well as work as the catalyst for changes within the code, without inputting any On-click function.  The small changes in a GameObject’s name or tag can be found easily with code.  Detecting the changes can act as Boolean checks in order to run the desired action or function in the code, much preferred to keeping a stable Unity UI and code then creating functions at times.  With these changes we can change elements on the Hololens UI without separating the canvas from the camera, it has allowed us to change units of measure as well as a simple inventory system of items to select.

Posted in: