+1
Fixed

Cursor lock on Inventory UI exit button

Brian 3 months ago in Inventory updated by Marti (Lead Developer) 3 months ago 4

How would I lock & hide the cursor during runtime after closing the Inventory UI using the "X" button at the top right?

I've created a variable bool for when the inventory is Open / Closed according to the action options in Game Creator.

So I can press "I" to open the inventory and again to close it, which works peachy using the "change cursor parameters" actions.

It doesn't work when I use the mouse on the UI "X" button to close it. 

I believe I will need to either: 


A. find a way to set my global bool variable inside the InventoryRPG prefab by referencing it within the InventoryUIManager script (i wouldn't know where to begin with this)

B. write a few lines of code inside the InventoryUIManager script alongside the "is.Open" or "changeState" functions (I don't know how to code that well yet)

Maybe there's an easier way I'm missing? I suppose the easiest way would be to get rid of any clickable close buttons in all UI, but I feel like I'll have to figure it out at some point. 

Unity version:
2019.3.6f1
Game Creator version:
1.1.6

Answer

+1
Answer
Planned

Hi. This is a good question. There's currently no "easy way" of doing this. However, I'm opening a ticket to add a new Trigger called "On Inventory UI" that will detect when the inventory UI changes its state. You'll be able to to choose between when the inventory UI is opened or closed.

This should solve the problem, since you can simply call the Action "Cursor" when the inventory closes and lock the cursor on screen.

The same will be done with the Merchant.

GOOD, I'M SATISFIED

Awesome thanks guys!

Satisfaction mark by Brian 3 months ago

I have also been trying to figure this out, but for the merchant UI also.

I have tried using conditions that check if the InventoryUI/merchantUI are open or closed but have yet to get it working.

What would be great is if the inventoryUI or merchantUI open/closed state could be used as a trigger.

If anyone can share a solution that would be great.

The best I have done is far from perfect.

I hope someone can do better and share.

I have a bool variable.

Then an on mouse down trigger that triggers a condition.

IF InventoryUI, MerchantUI are closed it toggles the bool.

Another trigger looks for the variable change on the bool, which triggers another condition to check if the bool is enabled.

Which I then hooked up to an action to lock the cursor.

So, if I click the X in either the MerchantUI or Inventory UI to close the UI, the cursor is still enabled, but clicking again gets rid of it.

Not perfect.

+1
Answer
Planned

Hi. This is a good question. There's currently no "easy way" of doing this. However, I'm opening a ticket to add a new Trigger called "On Inventory UI" that will detect when the inventory UI changes its state. You'll be able to to choose between when the inventory UI is opened or closed.

This should solve the problem, since you can simply call the Action "Cursor" when the inventory closes and lock the cursor on screen.

The same will be done with the Merchant.

Fixed

Hi; I'm closing this ticket since I've just addressed this issue. You'll now find a new Trigger called "On Merchant UI" that will be triggered when a merchant's store UI opens (or closes, you can choose that). There's also the On Inventory UI and On Container UI, which are homologous to their respective system.

The update will be live between tomorrow (hopefully) and Monday. Happy game making!