Hello,
In my project, we only move with the keyboard or the joystick.
Is it possible to change in runtime the textures of all interaction icons in the cursor manager if a keyboard key is pressed and vice versa. When we use the joystick?
So the hotspot icons would change in real time depending on the controller used.
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
Through scripting, you can access an individual interaction icon by referencing its ID number:
(An icon's ID number is listed next to its name in the Cursor Manager)
Using this, it's possible to write a script that updates all icons based on data stored in a custom class. Here's an example:
Place in your scene and fill in the Inspector, and then try the "Set keyboard icons" and "Set controller icons" options that appear in the Inspector's context menu at runtime.
Getting this to work automatically would then be a case of extending the script to call its SetIconsKeyboard / SetIconsController functions based on input.
There's a few schools of thought when it comes to approaching the problem of detecting the source of the last input, but Unity's forums has some good threads on the subject. If you can find a means of reliably detecting which input to switch to, it should be straightforward to plug into the above script.
Thanks Chris for you quick reply!
That's really helpfull, I will do this research
It seems that icons are only assigned once to a hotpsot. But not on trigger.
For example: If I use a controller and activate a hotspot, the first time it does have the desired controller icon. If then I use the keyboard and go to another hotspot that I had not activate yet, this one have the appropriate icon, the one for the keyboard. On the other hand, if I go back to the first hotspot, it keeps the controller icon. Same for the second one, it kept the keyboard icon even if I use the joystick. But the cursor manager updates well every time I change inputs method.
I think it's maybe the hotspot script but I don't feel like I'm going to change anything inside yet. Any clues ?
Try this alternative to the above:
If that doesn't solve it, the way these icons are used will depend on your game's Interface and Hotspot settings in the Settings Manager. Can you share screenshots of both so that I can know your setup?
Thanks again Chris. Now it's working perfectly ! You make my day.
For those who need, here's my settings:
https://imgur.com/hJ9Wdqi
https://imgur.com/zI3wpRQ
For the detection of the controller, as you said, there are a lot of tutorial, forums discussions about this. Especially with the new Input System (in the Package Manager). I haven't used this one, I made a simple OnGUI() detection.
Take care of you and your loved ones in these difficult times.