Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

AnswerHub Maintenance

Background maintenance is scheduled to occur between 9 - 11am EDT on Tuesday, May 21. Site operation may be slower than normal during this time and a brief interruption in operation may be observed

Does a Widget stay in memory after removing it from Parent

I have created a widget that appears when a keyboard key is pressed and the game pauses. In there I have button that removes the widget and unpauses the game. with a simple "`Remove from Parent :Self`" Node, which lays inside a custom event called Unpause

I decided it would make sense to have the same key could also un pause the game, so I did the following:

 Get All Widget Of Class:PausedUI-->For Each Loop-->Cast to Paused UI-->Unpause

At first, instead of the "`For Each Loop`" I had a "`Get index 0`" and it worked perfectly but only once!

My Question is this: does my PauseUI need something more to get destroyed or is "`Remove From Parent`" enough? If it is enough, why doesn't the "All widget of class" Table empty after it is removed?

Product Version: UE 4.9
more ▼

asked Oct 01 '15 at 10:29 PM in Blueprint Scripting

avatar image

13 1 7 7

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

Hi Ant_V,

the widget stays in memory when you use "Remove From Parent", there is no way to "destroy" it manually as far as I know.

What you could do, which is maybe a more elegant solution then using get-all-widgets-of-class, is to create a variable of the type PauseUI, when you click on the pause button you first check if the variable is valid (if something is stored in there), if not (first time clicking pause, it is empty) then you create a new widget of type PauseUI, assign it to the variable and add it to the viewport. When you want to remove it from the screen just use "remove from parent". Next time you want to pause, you check again if the variable is valid, now it is valid as you had previously stored the widget in there and you just add the content of the variable to the viewport.

I usually do this in blueprint so I don't have any code snippet to share for this functionality.

Let me know if it makes sense.

Regards, Damir

more ▼

answered Oct 14 '15 at 07:11 AM

avatar image

Damir Porobic
211 12 8 20

avatar image Ant_V Oct 14 '15 at 09:46 AM

Thanks for your answer, you have proven my fears to be correct. I was thinking of doing something like that as well... Shouldn't the fact there is no way to clean the widget from memory be considered a bug? I mean if I had not added the unpause call outside the widget itself, I would never have thought of this issue.

avatar image Damir Porobic Oct 14 '15 at 09:55 AM

I was thinking in that direction myself at the beginning and I still think that it would make sense to have a way to clean the widget but it's the way they have designed.

I'm not sure if there is a clean process that destroys unused widgets in the background every 60 seconds or so.

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question