The icon_component is a Scene Graph component used to assign an icon to an entity. Refer to Working with Entities and Components for how to add a component to your entity.
Class Description
The icon_component uses a Texture asset as a visual reference for the entity in-game.
It could be an item icon inside a backpack, a character portrait or an ability icon for a hotbar. The component holds a single field, Icon, which can be set in the Prefab Editor or through Verse script.
Example
In the example below, the icon_component is added to an item prefab (for example an entity with an item_component) and a Texture icon representing the entity.
Now when the item is picked up by a player, the Icon is used in the hotbar and Backpack UI elements.
Once the Custom Items and Inventory system is enabled the icon_component is listed in the component dropdown list. For more information check out the icon_component API reference from the Verse API.
Verse: Icon
With Verse, the Icon field can be set on demand. Below is a script of an icon_component subclass that swaps the texture in the Icon field on a loop:
# 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.
Below is a function you can call on an entity. Targeting an entity that has an icon_component displays the icon on the screen, providing the entity has a player for an ancestor:
# Copyright Epic Games, Inc. All Rights Reserved.
using { /UnrealEngine.com/Temporary/UI }
using { /Verse.org/SceneGraph }
using { /Verse.org/Simulation }
# Calling this function will display a texture block widget to the player screen.
# It sources the texture from the icon_component from the provided entity.
The cycling_icon_component is added to an entity prefab definition.
The
cycling_icon_componentis added to an entity prefab definition.The Verse device, and an instance of the prefab, are placed in the scene.
Starting a session illustrates how the icon displays on all players screens and is updated when the icon changes.
cycling_icon_component in the HUD
To learn more about using Verse to create user interfaces (UI), see Creating UI with Verse.