Verse Library verse

01 Verse Icon

Automatically cycles through a list of textures on a component when added to the scene.

extracted-snippets/documentation/en-us/fortnite/item-icon-component-in-fortnite/01-verse-icon.verse

# Source URL: https://dev.epicgames.com/documentation/en-us/fortnite/item-icon-component-in-fortnite
# Local doc:  epic-docs/documentation/en-us/fortnite/item-icon-component-in-fortnite.md
# Section:    Verse: Icon
# Copyright Epic Games, Inc. All Rights Reserved.
using { /Verse.org/Assets }
using { /Verse.org/SceneGraph }
using { /Verse.org/Simulation }
# This is a subclass of the icon_component.
# You can add this component to an entity and it will cycle between icons from an editable list.
# The component will set each Icon sequentially from the IconList, before looping back to the start.
cycling_icon_component := class(icon_component) :
# List of Icons to set in order.
@editable
IconList:[]texture = array{}
# Index of the currently set Icon.
var CurrentIconIndex<private>:int = 0
# When the component is added to the scene it will immediately begin cycling the icons.
OnAddedToScene<override>():void =
spawn{CycleIconTexture()}
# This function will loop continuously, updating the texture inside the Icon field.
CycleIconTexture()<suspends>:void =
loop:
if(NextIcon := GetNextIcon[]):
set Icon = NextIcon
Sleep(2.0)
else:
break
# Here we get the next texture from the IconList array, else it loops back to the starting index.
GetNextIcon()<decides><transacts>:texture =
NextIndex := Mod[CurrentIconIndex + 1, IconList.Length]

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.

Sign in with Discord

Comments

    Sign in to vote, comment, or suggest an edit. Sign in