【Verse】モンスターの撃破数を表示する ”撃破カウンターUI” をVerseで実装してみる!【UEFN】
動画内Verseコード
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /UnrealEngine.com/Temporary/UI }
using { /Fortnite.com/UI }
using { /UnrealEngine.com/Temporary/SpatialMath}
Counter := class(creative_device):
@editable
var Elimination : elimination_manager_device = elimination_manager_device{}
var Count : int = 0
var Players :[]player = array{}
var UIButton : button_loud = button_loud{}
TextForUI<localizes>(Kills : int) : message = "撃破: {Kills}"
OnBegin<override>()<suspends>:void=
Elimination.EliminationEvent.Subscribe(OnEliminationEvent)
set Players = GetPlayspace().GetPlayers()
if (Player := Players[0]):
CreateUI(Player)
OnEliminationEvent(Agent:?agent):void=
set Count += 1
UIButton.SetText(TextForUI(Count))
CreateUI(Player : player) : void=
if(PlayerUI := GetPlayerUI[Player]):
UIButton.SetText(TextForUI(0))
MyCanvas : canvas = canvas:
Slots := array:
canvas_slot:
Anchors := anchors{Minimum := vector2{X := 0.5, Y := 0.0}, Maximum := vector2{X := 0.5, Y := 0.0}}
Offsets := margin{Top := 100.0, Left := 50.0, Right := 50.0, Bottom := 50.0}
Alignment := vector2{X := 0.5, Y := 0.5}
SizeToContent := true
Widget := UIButton
PlayerUI.AddWidget(MyCanvas)
ご質問やご感想はお気軽にコメント欄まで!