Hi there. So I am trying to set up a UI widget that displays variable text on the players screen and I was able to do that with the help of a YouTube video however I also want to display the image that is in that widget blueprint. I used verse to display the text so that the text would be variable however the code only allows for the text to appear. I want an image to be behind the text but not sure how to do that. I have tried making another widget blueprint with the image I want to use and using a HUD message device to show that however, the image is appearing on top of the text essentially hiding it. I think this is happening because the text cant be set on a layer because its not done through a HUD message device. I am hoping that there is a way to show the text and image with Verse. I have attached the code I am using below. Hope this makes sense I can explain further if it doesnt.
using { /Fortnite.com/Devices }
using { /Fortnite.com/UI }
using { /Verse.org/Simulation }
using { /Verse.org/Colors/NamedColors }
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /UnrealEngine.com/Temporary/UI }
using { /UnrealEngine.com/Temporary/SpatialMath }
A Verse-authored creative device that can be placed in a level
ResourceUIDevice := class(creative_device):
S2M<localizes>(S:string):message="{S}"
@editable PlayerSpawners : []player_spawner_device = array{}
@editable RefreshRate : float = 0.1
@editable ConditButton : conditional_button_device = conditional_button_device{}
var ResourceTextBlockPerAgent : [agent]?text_block = map{}
# Runs when the device is started in a running game
OnBegin<override>()<suspends>:void=
for(PS:PlayerSpawners):
PS.SpawnedEvent.Subscribe(PlayerSpawned)
PlayerSpawned(Agent:agent):void=
Print("Player Spawned")
if(MyTextBlock:=ResourceTextBlockPerAgent[Agent]?){}
else:
AssignUI(Agent)
AssignUI(Agent:agent):void=
Print("Assigning UI")
MyCanvas:=MakeCanvas(Agent)
if:
PlayerUI:=GetPlayerUI[player[Agent]]
then:
PlayerUI.AddWidget(MyCanvas)
spawn{RefreshUI(Agent)}
RefreshUI(Agent:agent)<suspends>:void=
Print("Starting to Refresh")
if(TextBlock := ResourceTextBlockPerAgent[Agent]?):
loop:
Sleep(RefreshRate)
MyResource := ConditButton.GetItemCount(Agent,0)
TextBlock.SetText(S2M("$ {MyResource}"))
MakeCanvas(Agent:agent):canvas=
Print("Making Canvas")
MyTextBlock:=text_block:
DefaultTextColor:=Green
if(set ResourceTextBlockPerAgent[Agent] = option{MyTextBlock}){}
MyCanvas:=canvas:
Slots:=array:
canvas_slot:
Widget:=MyTextBlock
Anchors:=anchors{Minimum:=vector2{X:=0.0,Y:=0.0},Maximum:=vector2{X:=1.0,Y:=1.0}}
Offsets:=margin{Left:=104.0,Top:=820.0,Right:=1637.0,Bottom:=220.0}
return MyCanvas