Hotbar appears when a certain gameobject is selected?
I have a gameobject that the player can select and would like a hotbar with several buttons to appear, but only when the gameobject is selected. I have an image in the canvas with all of the buttons on, so the image is probably the thing that should appear and disappear.
What is your exact question? You don't know how to detect the click or touch on the GameObject? Or does the image not appear on the canvas?
Answer by Grumphh · Oct 06, 2020 at 07:42 AM
Hi,
Should be as straightforward as creating your gameobject from a button object (adding a button script component to an existing gameobject should also work). Then defining in the button component a onclick function (click "+" at the bottom of the component) Finally this function should either enable / disable the hotbar, or you can keep it enabled and just move it off canvas when you don't need it and moving it on canvas when you need it.
Your answer
Follow this Question
Related Questions
Scaling an image sent to UI Image 0 Answers
Use a canvas prefab multiple times at the same time 0 Answers
How to make an object the root of a prefab, or remove the canvas that is set as the root of a prefab 0 Answers
C# - Error " does not implement interface member" 2 Answers
Loading an 'UI skin pack' 1 Answer