Jump to content

How to prevent mesh being clicked through GUI element?


lihis
 Share

Recommended Posts

Hello,

I have a mesh that is clickable and i would like to prevent it being clicked if there is a GUI element in front of it.

Playground: http://playground.babylonjs.com/#84Q5FX

In this example i made the GUI clickable as well, but i would like the GUI to stop mesh from being clicked even if there wasn't click function assigned to it.

Is this possible?

I can almost do this with my own input handler, but it only works like 90% of the time. <_<

And it's a bit funky involving global cooldown on clicks. It also requires me assigning an empty click function to the GUI.

 

Link to comment
Share on other sites

This is at application level, but at the point where the GUI is created, could you not just make the ground unpickable?  http://playground.babylonjs.com/#84Q5FX#1

I assume that since you want the mesh still pickable, that the GUI is not always there.  When GUI goes away,  just reset to pickable once more.  Action was never unregistered, so should resume working.

Link to comment
Share on other sites

@JCPalmer Yeah that's a possibility if you don't want the mesh clickable while the GUI is there, but i think i do want it still clickable while the GUI is there, just not where the GUI is.

@Deltakosh Hmm ok that's something i could do i suppose. Feels a bit strange to make a background element from GUI.Button instead of rectangle though. And i'd have to disable the animations from the button. But i guess that's decent hackaroo. -_-

Link to comment
Share on other sites

Ok so i happened to encounter a wild @Wingnut out and about and he actually had a great solution.

No need to use buttons or anything crazy like that, instead there is a isPointerBlocker property that works just fine on GUI.Rectangle.

http://playground.babylonjs.com/#84Q5FX#3

So big ups to our nutman for this tip! :)

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...