using { /Fortnite.com/Devices }
using { /UnrealEngine.com/Temporary/Synthetics }
using { /UnrealEngine.com/Engine/Classes/Engine/World }
using { /UnrealEngine.com/Engine/Classes/GameFramework/PlayerController }
# Define our team state.
# Think of this as your "Elimination Count" or "Score."
var IsTeamA_Winning: bool = true
# This function is like the "Storm Timer" ticking.
# It checks who is winning and updates the UI color.
Update_Team_UI := func():
# We need to find the widget in the scene.
# In a real build, you'd reference this via a Device or Event.
# For this demo, we assume we have a reference to the Widget.
widget := World.Get_Player_Controller(0).Get_Widget("W_TeamScore")
if (widget != None):
# Get the specific shape component inside the widget.
# This is like finding the "body" of the player.
shape := widget.Get_Component("RectangleShape")
if (shape != None):
# Get the Material Instance we created.
# This is like equipping the skin.
material := shape.Get_Material(0)
if (material != None):
# HERE IS THE MAGIC.
# We are changing the "Base Color" parameter on the Instance.
Verse Library
verse
01 Fragment
Dynamically updates UI widget colors based on game state by modifying material instances.
verse-library/creating-and-using-material-instances/01-fragment.verse
Sign in free to read the full source 🌴
This Verse Library file is members-only. Create a free account to view the complete source and download the .verse file.