odd behavior with button group in instanced scenes.

dotteddotted Posts: 347Member

I create a UI scene that uses button groups. I wire it up and add the resources as an exported variable.

Works as expected.

But when I instance this scene as a child scene in another, this export is empty in the owning scene.

Why?


Tags :

Best Answer

  • dotteddotted Posts: 347
    edited January 15 Accepted Answer

    The buttons and groups are all assigned statically in each scene. Again this only happens for the (instanced) scenes which are invisible in a tab container. The first tab and the visible one is fine.

    I've resolved the issue by adding a null ptr check on the value returned by get_selected_button() since refreshing the scene for other reasons is called when its visible changes in the container.

        var button  = grid_type.get_pressed_button()
        if button:
    

    I will note that my mind is bent a little because the editor keeps resetting the instance scene settings to a default button group with the option to revert to the ones set by that scene without me touching the properties from the (tab container) instancing scene.

Answers

  • dotteddotted Posts: 347Member

    On top of this the editor often resets button group resources to a default entry with a 'revert' that goes back to the resource I set

  • dotteddotted Posts: 347Member

    Best I can figure, util the buttons which are children nodes in the instanced scene must be instanced first before the button group returns a selected button.

    but this doesn't happen when the scene itself is made the project target

  • TwistedTwiglegTwistedTwigleg Posts: 5,251Admin

    Does the issue only occur in the editor? In other words, it's not a script that is trying to set the button group? If it's all done through the editor, it sounds like it could potentially be a bug in the loading/timing of buttons when loading scenes.

    Does the buttons get added to the group after _ready? Maybe if you add something like yield(get_tree(), "idle_frame") before getting the button group it would (for testing at least) work?

  • dotteddotted Posts: 347Member
    edited January 15 Accepted Answer

    The buttons and groups are all assigned statically in each scene. Again this only happens for the (instanced) scenes which are invisible in a tab container. The first tab and the visible one is fine.

    I've resolved the issue by adding a null ptr check on the value returned by get_selected_button() since refreshing the scene for other reasons is called when its visible changes in the container.

        var button  = grid_type.get_pressed_button()
        if button:
    

    I will note that my mind is bent a little because the editor keeps resetting the instance scene settings to a default button group with the option to revert to the ones set by that scene without me touching the properties from the (tab container) instancing scene.

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file