Hide/Show GUI Elements by clicking on Meshes

With some help from others on this forum I have put together some behavior in my UI whereby imported STL meshes change color when you click on them.

What I’d now like to add is additional behavior so when you click on those same mesh elements it shows a GUI element associated with it and hides other GUI elements associated with other meshes.

The attached playground shows the imported STL meshes with color changing behavior and also 4 GUI elements associated/linked with four of these meshes. Id like these elements to only be visible when the associated mesh is highlighted.

I’ve had a look through the forum and documentation but can’t really find anything similar so any help would be appreciated.


Hi! You have to somehow link the GUI elements and models. I did one possible solution for your scene and added comments to clarify the code. Now the links are set randomly between to GUI elements and models so you have to fix those.

Hope this helps! :blush:

1 Like

That’s great. One further question, can this method be modified to turn on multiple GUI elements with each click of the mesh.

Line 135 creates a new GUI Element which does not yet have a behaviour linked.

Is there a way this element can be turned on in the same mesh click as that defined in Line 524.

I’ve tried stuff like the below but it doesn’t work as I would expect.

        guiItem: [rvFWProfilesRect, rvFWProfilesTxtRect,],
        models: [rvFWProfiles.meshes[0],],

Thanks for all your help with this to date though it is much appreciated.


If you want to show multiple GUI elements then you have to change the logic a little bit. Here is fixed playground that support show/hide multiple GUI elements when clicking a model.


That’s great - thanks