Author Topic: Right click with UI Actions  (Read 784 times)


  • Full Member
  • ***
  • Posts: 163
Right click with UI Actions
« on: April 11, 2021, 07:25:09 AM »
Hey guys

I'm hoping I can get a bit of guidance here.  I have an inventory system that players can drag one stack of items from one inventory slot to another slot.  I can make this happen fairly easy but I also want to add a feature while holding left click down, you can right click to add 1 item into the slot.  My problem is my right click doesn't seem to get tracked by anything.  All my UI Actions I've tried doesn't seem to register clicking or what inventory slot (GO) the pointer is on when I right click. When I left click, it finds the slot just fine.  Is there a way to have the right click function the same as left with these actions?


Weak Interactive

  • Beta Group
  • Playmaker Newbie
  • *
  • Posts: 33
Re: Right click with UI Actions
« Reply #1 on: April 11, 2021, 01:10:24 PM »

So I never really had a super good solution for this, but I'll share what I wound up doing when I ran into this issue.

As far as I know, there's no component that can differentiate between mouse clicks by default, but the "Get Mouse Button Down" or "Get Mouse Button" actions can.

So my solution was to make a state with "Get Mouse Button Down" (Right Click), and enter that state when needed. If you can only right click while holding left click down, you can add a prior state with "Get Mouse Button" (Left Click) to control when to enter the right click state.

Hopefully that makes sense, and good luck.


  • Full Member
  • ***
  • Posts: 163
Re: Right click with UI Actions
« Reply #2 on: April 12, 2021, 06:09:51 PM »
Hey there,

I can sort the different clicks easy enough with how you suggested but the problem is still there.  As soon as I right click, nothing on the UI gets registered that it was clicked.  I can tell the player right clicked but not what they clicked on.  This breaks my inventory system as I need to know what slot the player is clicking on to be able to add items or move them around.

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3974
  • Official Playmaker Support
    • LinkedIn
Re: Right click with UI Actions
« Reply #3 on: April 12, 2021, 06:39:51 PM »
What actions/events are you using to select the inventory slots? Are the inventory slots UI GameObjects under a Canvas or regular scene GameObjects?

If you're using a 3d UI made of GameObjects, you can use UI Events and Actions by adding a Physics Raycaster component to the camera and making sure you have a default Event System in the scene.

You can then use system events like UI POINTER DOWN or actions like UI On Pointer Down Event on the GameObjects. UI System Events and Actions respond to left or right click. You can use UI Get Last Pointer Event Data if you need to know more about the event (e.g., which button was pressed).

I believe this is the recommended way to interact with 3d world space UIs, but I'm sure there are other ways to set it up.

There's probably a way to do it with your current setup, but I need to know a bit more about the setup, e.g., the actions and events used.


  • Full Member
  • ***
  • Posts: 163
Re: Right click with UI Actions
« Reply #4 on: April 14, 2021, 07:03:20 AM »
Hey Alex.

Currently using the UI GameObjects under the Canvas for my system. 

I've re-design my system a bit though as my inventory slots are quite dynamic.  What I have is unlimited inventory slots (A new one opens up as soon as you fill in all the slots).  I've made the inventory slots a prefab with an FSM on them that listens for Pointer Up (Player selects the item) and also Pointer Drags (Player drags the item around).  Once they get any of these events, it fires off the event to the parent inventory manager that listens for these events at the same time listening for left/right clicks every frame.  From here I can do whatever logic I need depending on what event is fired off while seeing what mouse click is happening during it.

Not sure if this system is the best way to work with this but it seems to work for me for now.