Announcement

Collapse
No announcement yet.

[Tool] WidgetBox - Recycle your widgets the smart way

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    [Tool] WidgetBox - Recycle your widgets the smart way

    Why?
    Object creation and garbage collection is a time consuming task. Reserving and freeing memory all over the place also causes memory fragmentation, which is something you want to prevent. WidgetBox is a Object Pool specific for widgets which will keep removed widgets in a pool for reuse.

    Solution: WidgetBox!
    WidgetBox is the smart way of handling that issue. The WidgetBox will create widgets for you as needed but will save them for reuse when the widgets got removed from parent. It's useage is very simple (See NoGo section below for what you should NOT do) and keeps the code slick.
    Click image for larger version  Name:	WidgetBox_YES.PNG Views:	1 Size:	278.6 KB ID:	1392664

    NoGo
    As I'm not able to set a hook in the engine when the widget is added to a parent, there is a restriction that you must take into account. NEVER EVER ADD a widget from the WidgetBox TWICE after getting it from the Box.
    Click image for larger version  Name:	WidgetBox_NoGo1.PNG Views:	1 Size:	105.0 KB ID:	1392665

    Go Green - Widget Recycling
    The WidgetBox will only create new widgets if there is no free widget of the specified class. To make a widget available again, remove it from the parent. The widget will go to the Box itself to be marked available again.
    Click image for larger version  Name:	WidgetBox_Remove.PNG Views:	1 Size:	51.0 KB ID:	1392666

    Inheritance
    To use a widget with WidgetBox, it must inherit from [U]WidgetBoxWidget.

    Features
    -Very simple setup and usage
    -New widget only get created when pool is empty
    -Removing a WidgetBoxWidget from parent places it back into the box.
    -Multiple Box instances if needed
    -One Box, All classes you want (inheriting from WidgetBoxWidget)
    -The power of C++

    How to set it up?
    1: Download and place the contents into '.../MyGame/Plugins
    2: Restart Editor
    3: Enable Plugin in Edit->Plugins
    4: Restart Editor

    Download
    UE4.16
    UE4.17
    UE4.18
    UE4.19
    UE4.20
    UE4.21 (Updated 28.12.2018)
    UE4.22
    UE4.23
    UE4.24
    UE4.25

    Feature Request & Bugs
    Let me know.
    Attached Files
    Last edited by Rumbleball; 05-07-2020, 10:20 AM.
    NodePrefabs | PluginBuilder | NotificationBackbone | WidgetBox | DebugWidget

    #2
    The main intention of this plugin was to bypass the issue that widgets do not get garbage collected. With UE4.19 this issue is fixed.

    Does actually anyone made use of this plugin and needs an update of it? If you are only using it because of the now gone garbage collection issue, you should switch back to spawn you widgets as needed.
    NodePrefabs | PluginBuilder | NotificationBackbone | WidgetBox | DebugWidget

    Comment


      #3
      I don't use it because I started using Noesis, but generally pooling is better than delete/new so i'd say it's still worth it.
      George Rolfe.
      Technical Coordinator at Orbit Solutions Pty Ltd.

      Comment


        #4
        Originally posted by duke22 View Post
        I don't use it because I started using Noesis, but generally pooling is better than delete/new so i'd say it's still worth it.
        Im know, but the "NoGo" restriction is to big a bummer. This should be doable as it is engine default behavior. Someone that does not know about that (and it is not obvious at all when grabbig the widget from somewhere), and things go boom.
        NodePrefabs | PluginBuilder | NotificationBackbone | WidgetBox | DebugWidget

        Comment


          #5
          I would like an update of it if possible yes. This could kinda serve as an object pool. Because I'm mass-spawning and destroying widgets.

          Comment


            #6
            Originally posted by Mootjuh View Post
            I would like an update of it if possible yes. This could kinda serve as an object pool. Because I'm mass-spawning and destroying widgets.
            Okay, will see that I do this today.
            NodePrefabs | PluginBuilder | NotificationBackbone | WidgetBox | DebugWidget

            Comment


              #7
              Version for UE4.19 is up. Enjoy.
              NodePrefabs | PluginBuilder | NotificationBackbone | WidgetBox | DebugWidget

              Comment


                #8
                Thank you!

                Comment


                  #9
                  Version for UE4.20 is online.
                  NodePrefabs | PluginBuilder | NotificationBackbone | WidgetBox | DebugWidget

                  Comment


                    #10
                    Version for UE4.21 is up 'n running.
                    NodePrefabs | PluginBuilder | NotificationBackbone | WidgetBox | DebugWidget

                    Comment


                      #11
                      I sometimes get this crash. I have confirmed it only occurs with widgets that make use of the widgetbox. It says I have stuff erroring before pre-construct.

                      Code:
                      [2018.12.08-15.20.20:133][366]LogWindows: Error: === Critical error: ===
                      [2018.12.08-15.20.20:133][366]LogWindows: Error:
                      [2018.12.08-15.20.20:133][366]LogWindows: Error: Assertion failed: !IsUnreachable() [File:D:\Build\++UE4\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\ScriptCore.cpp] [Line: 1319]
                      [2018.12.08-15.20.20:133][366]LogWindows: Error: RadarBlip_C /Engine/Transient.GameEngine_0:BP_MyGameInstance_C_0.RadarBlip_C_2 Function: '/Script/UMG.UserWidget:PreConstruct'
                      Any idea?
                      Last edited by HiIAmMoot; 12-27-2018, 02:18 PM.

                      Comment


                        #12
                        Originally posted by Mootjuh View Post
                        I sometimes get this crash. I have confirmed it only occurs with widgets that make use of the widgetbox. It says I have stuff erroring before pre-construct.

                        Code:
                        [2018.12.08-15.20.20:133][366]LogWindows: Error: === Critical error: ===
                        [2018.12.08-15.20.20:133][366]LogWindows: Error:
                        [2018.12.08-15.20.20:133][366]LogWindows: Error: Assertion failed: !IsUnreachable() [File:D:\Build\++UE4\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\ScriptCore.cpp] [Line: 1319]
                        [2018.12.08-15.20.20:133][366]LogWindows: Error: RadarBlip_C /Engine/Transient.GameEngine_0:BP_MyGameInstance_C_0.RadarBlip_C_2 Function: '/Script/UMG.UserWidget:PreConstruct'
                        Any idea?
                        Hm. Not sure what could cause this. Does this occour everytime you execute a specific section of your code? As the error is script related, do you have issues with unknown types, like problem with a struct after renaming?
                        NodePrefabs | PluginBuilder | NotificationBackbone | WidgetBox | DebugWidget

                        Comment


                          #13
                          I have no problems with unknown times, and this crash doesn't seem to be occuring every time. Seems to be happening at random points.

                          Comment


                            #14
                            Originally posted by Mootjuh View Post
                            I have no problems with unknown times, and this crash doesn't seem to be occuring every time. Seems to be happening at random points.
                            which engine version?
                            NodePrefabs | PluginBuilder | NotificationBackbone | WidgetBox | DebugWidget

                            Comment


                              #15
                              I'm using 4.21. I skipped 4.20 and went from 4.19 to 4.21. My own code did not change.

                              Comment

                              Working...
                              X