When I try to reference a ?texture type with an editable attribute from Verse, a white image is displayed.

Summary

When I try to reference a ?texture type with an editable attribute from Verse, a white image is displayed.

code: ```using { /Fortnite.com/Devices }
using { /Fortnite.com/UI }
using { /UnrealEngine.com/Temporary/UI }
using { /UnrealEngine.com/Temporary/SpatialMath }
using { /Verse.org/Simulation }
using { /Verse.org/Assets }

ui_button_texture := class(creative_device):

@editable
DisplayButton : button_device = button_device{}

# Define the texture asset exposed to Verse
@editable
TextureToDisplay : ?texture = false

# Position for displaying the texture
@editable
DisplayPosition : vector2 = vector2{X := 0.4, Y := 0.4}

# Desired size for the texture display
@editable
TextureSize : vector2 = vector2{X := 512.0, Y := 512.0}

# Map to store player-specific UI widgets
var PlayerUIMap : [player]?canvas = map{}

# Initialize the device
OnBegin<override>()<suspends>:void=
    DisplayButton.InteractedWithEvent.Subscribe(OnButtonPressed)

# Handle button interaction
OnButtonPressed(Agent : agent):void=
    if (Player := player[Agent], PlayerUI := GetPlayerUI[Player], MaybeTexture := TextureToDisplay?):
        if (ExistingUI := PlayerUIMap[Player]?):
            # Remove existing UI if present
            PlayerUI.RemoveWidget(ExistingUI)
            if (set PlayerUIMap[Player] = false) {}
        else:
            # Create and add new UI with texture
            NewUI := CreateTextureUI(MaybeTexture)
            PlayerUI.AddWidget(NewUI, player_ui_slot{InputMode := ui_input_mode.None})
            if (set PlayerUIMap[Player] = option{NewUI}) {}

# Create UI canvas with the specified texture
CreateTextureUI(Texture : texture):canvas=
    TextureWidget : texture_block = texture_block{
        DefaultImage := Texture
        DefaultDesiredSize := TextureSize
    }

    return canvas:
        Slots := array:
            canvas_slot:
                Anchors := anchors{
                    Minimum := DisplayPosition,
                    Maximum := vector2{X := DisplayPosition.X + (TextureSize.X / 1920.0), Y := DisplayPosition.Y + (TextureSize.Y / 1080.0)}
                }
                Widget := TextureWidget```

Code that works well: ```using { /Fortnite.com/Devices }
using { /Fortnite.com/UI }
using { /UnrealEngine.com/Temporary/UI }
using { /UnrealEngine.com/Temporary/SpatialMath }
using { /Verse.org/Simulation }
using { /Verse.org/Assets }

ui_button_texture := class(creative_device):

@editable
DisplayButton : button_device = button_device{}

# Define the texture asset exposed to Verse
@editable
TextureToDisplay : texture = T_Thumbnail

# Position for displaying the texture
@editable
DisplayPosition : vector2 = vector2{X := 0.4, Y := 0.4}

# Desired size for the texture display
@editable
TextureSize : vector2 = vector2{X := 512.0, Y := 512.0}

# Map to store player-specific UI widgets
var PlayerUIMap : [player]?canvas = map{}

# Initialize the device
OnBegin<override>()<suspends>:void=
    DisplayButton.InteractedWithEvent.Subscribe(OnButtonPressed)

# Handle button interaction
OnButtonPressed(Agent : agent):void=
    if (Player := player[Agent], PlayerUI := GetPlayerUI[Player]):
        if (ExistingUI := PlayerUIMap[Player]?):
            # Remove existing UI if present
            PlayerUI.RemoveWidget(ExistingUI)
            if (set PlayerUIMap[Player] = false) {}
        else:
            # Create and add new UI with texture
            NewUI := CreateTextureUI(TextureToDisplay)
            PlayerUI.AddWidget(NewUI, player_ui_slot{InputMode := ui_input_mode.None})
            if (set PlayerUIMap[Player] = option{NewUI}) {}

# Create UI canvas with the specified texture
CreateTextureUI(Texture : texture):canvas=
    TextureWidget : texture_block = texture_block{
        DefaultImage := Texture
        DefaultDesiredSize := TextureSize
    }

    return canvas:
        Slots := array:
            canvas_slot:
                Anchors := anchors{
                    Minimum := DisplayPosition,
                    Maximum := vector2{X := DisplayPosition.X + (TextureSize.X / 1920.0), Y := DisplayPosition.Y + (TextureSize.Y / 1080.0)}
                }
                Widget := TextureWidget```

Please select what you are reporting on:

Creative

What Type of Bug are you experiencing?

Assets

Steps to Reproduce

As per code

Expected Result

It worked for the texture type, not the ?texture type.

Observed Result

A white image is displayed.

Platform(s)

PC

Upload an image


Im having this exact issue thank you for posting i hope we can get a response and more votes

FORT-852033 has been ‘Closed’ as a duplicate of an existing known issue.

Could anyone please link what this is a duplicate of? Facing the same issue :frowning:

@EGMglokk To reference texture etc you need to use verse asset reflection, not @editables here’s a documentation post about it https://dev.epicgames.com/documentation/en-us/uefn/exposing-assets-with-asset-reflection-to-verse-in-unreal-editor-for-fortnite

1 Like