color_block and texture_block don't show on UI...

Hi, I’m facing a very annoying problem with the UI.

All my color_blocks and texture blocks don’t want to display. Text_blocks work perfectly.

I isolated the problem to run tests but without success, still the same problem.

Is this a bug from the last update, or am I doing something wrong?
If anyone goes through this and knows why it doesn’t work, please let me know.
You can test it, just copy the in an empty projet and tell me if it’s just me lol

Code

 OnBegin<override>()<suspends>:void=
        Sleep(5.0)

        # TEST
        for (Player : GetPlayspace().GetPlayers(), UI := GetPlayerUI[Player]):
            UI.AddWidget(MakeTestUI())
    
    MakeTestUI():canvas=
        Print("TEST")
        LobbyBackground : texture_block = texture_block{DefaultImage := UIElements.BGLobbyUI, DefaultDesiredSize := vector2{X := 1920.0, Y := 1080.0}}
        LobbyBackground2 : color_block = color_block{DefaultColor := NamedColors.Black, DefaultDesiredSize := vector2{X := 1920.0, Y := 1080.0}, DefaultOpacity := 1.0}
        TextBlock : text_block = text_block{DefaultText := StringToMessage("Hello World"), DefaultTextColor := NamedColors.White, DefaultTextOpacity := 1.0}

        Canvas : canvas = canvas:
            Slots := array:
                canvas_slot: # Text Background
                    Widget := LobbyBackground2
                    Anchors := anchors{Minimum := vector2{X := 0.5, Y := 0.5}, Maximum := vector2{X := 0.5, Y := 0.5}}
                    Offsets := margin{Top := 0.0, Left := 0.0, Right := 0.0, Bottom := 0.0}
                    Alignment := vector2{X := 0.5, Y := 0.5}
                    SizeToContent := false
                canvas_slot: # Test Text
                    Widget := TextBlock
                    Anchors := anchors{Minimum := vector2{X := 0.5, Y := 0.5}, Maximum := vector2{X := 0.5, Y := 0.5}}
                    Offsets := margin{Top := 0.0, Left := 0.0, Right := 0.0, Bottom := 0.0}
                    Alignment := vector2{X := 0.5, Y := 0.5}
                    SizeToContent := true  
        return Canvas

The result (Background doesn’t show):

EDIT : i found the solution, just need to remove the SizeToContent line in the color_block widget

hello_world_device := class(creative_device):

    # Runs when the device is started in a running game
    OnBegin<override>()<suspends>:void=
        Sleep(5.0)

        # TEST
        for (Player : GetPlayspace().GetPlayers(), UI := GetPlayerUI[Player]):
            UI.AddWidget(MakeTestUI())
    
    MakeTestUI():canvas=
        Print("TEST")
        #LobbyBackground : texture_block = texture_block{DefaultImage := UIElements.BGLobbyUI, DefaultDesiredSize := vector2{X := 1920.0, Y := 1080.0}}
        LobbyBackground2 : color_block = color_block{DefaultColor := NamedColors.Black, DefaultDesiredSize := vector2{X := 1920.0, Y := 1080.0}, DefaultOpacity := 1.0}
        #TextBlock : text_block = text_block{DefaultText := StringToMessage("Hello World"), DefaultTextColor := NamedColors.White, DefaultTextOpacity := 1.0}

        Canvas : canvas = canvas:
            Slots := array:
                canvas_slot: # Text Background
                    Widget := LobbyBackground2
                    Anchors := anchors{Minimum := vector2{X := 0.0, Y := 0.0}, Maximum := vector2{X := 1.0, Y := 1.0}}
                    Offsets := margin{Top := 0.0, Left := 0.0, Right := 0.0, Bottom := 0.0}
                    Alignment := vector2{X := 0.0, Y := 0.0}
                    SizeToContent := false
                
        return Canvas
Hi, 
Nothing wrong with color_block. It looks like your anchor values are off. See above. Also, this video might help too.
[Full Screen](https://youtu.be/whFR1LRWbJs?si=oPCLEqYKDzzoZIm1)

Hope this helps.

I didn’t see you said you found a solution, but leaving my response just in case someone else wants to see this.

1 Like