What am I doing wrong ?

What am I doing wrong I have a button the opens up a widget I want it so if you click the same button again it removes the widget but its not doing please someone help me I am so confused to what I am doing wrong.

Thanks
Ryan

You did not set the value of the variable after creating the widget:

1 Like

Thanks , I did this but it still does not remove from the viewport

You’re using the wrong variable. No need to create another one. You already have the 2d-3d. See my pic again.

That is just the button but I can not get a set option just a get option when i drag it in

If the top bit is the widget you add, the bottom bit should be the widget you remove. Do not remove the 2d-3d if that’s the button (which I can now see on the event node - my bad).
Remove the same widget you created and referenced. It’d be close to:

And here’s a version of the above that creates the widget only once:

Rather than re-create it from scratch every time we click. You can get of the Validated Get node by right mouse clicking the regular Get node:


So i have done it this way the widget appears but still does not go when i click it again sorry what am i missing

There’s some confusion here.

  • you’re clicking the 2d-3d button
  • you’re creating and referencing another widget
  • add / remove another widget to / from the viewport
  • there’s no need to do anything to the 2d-3d button

Note that my script above does not say 2d-3d button anywhere.


I think it adds to the confusion that you’ve called the SitePlan widget 2d-3d widget. Perhaps that variable should be called 2dSitePlan - just to make things clear.

However, the script looks OK to me. Does it not work?

1 Like


hopefully this helps clear up what i mean and maybe what i am doing wrong.

Currently when i click on the “2d-3d” button in the ui the image comes up but then when i click it again it does not remove it from the ui

Thanks

this helps clear up

All of this looks fine now.

Can you see the button go down when clicking the 2d time? What are the chances the newly added SitePlan is full-screen and covers the button, preventing the 2nd click?


Select this node and hit F9 - it will add a breakbpoint (you can remove it the same way):

Run the project, the script should terminate when it hits that spot - does it?

1 Like

i tried that but the project did not stop when i did this. the way I am making the button appear is adding it to another ui , I am wondering if your right but i do here the click sound i have added when i keep clicking it

I see. I guess you’re creating instances of this widget and things get lost in the process. How do you add the button widget?

Add a Print String at the end:

r

It should fire only once. If you see it fire (print) more times, it means we create more buttons than is needed - and that’s providing I understood what is going on. :melting_face:

1 Like

every time i click the button it prints once , The ui button/bar come in and then the image below

Then we have the issue with the button itself. Most likely with the way it is added and / or removed.


You could test the above script by copy / pasting it into the level blueprint (and adding the vars) and using any keyboard key as input. Once you know this part is working as intended (the widget pop up and hides), you can start looking into why it does not work when invoked by the 2d-3d button.

Sadly, we do know enough about how things are organised.

1 Like

Thanks I will have a try and come back

1 Like

Out of sheer curiosity:

What does it actually Print when you mash it repeatedly?

1 Like

image
this is what comes up

Here’s the flow for the suggested script:

  • 1st click creates the widget if it does not exist
  • consecutive clicks FlipFlop the now existing widget between two Visibility states

Hard to tell what else is going without knowing the rest of the setup. I’d investigate this part:

the way I am making the button appear is adding it to another ui

I believe (a wild guess!) you keep adding new buttons and orphan the widgets created with the script we see. Count them:

See what you get. If you get more than 1, then it’s what I think it is.

1 Like

Every click the number goes up by 1 from 1