Role.SetIcon

From Intrigues Wiki
Revision as of 12:06, 5 January 2024 by Tayfunwiki (talk | contribs) (Created page with "=== Role Class - <code>SetIcon</code> Method === ==== Overview ==== The <code>SetIcon</code> method in the Role class allows setting a new graphical icon for a specific role. ==== Syntax ==== <syntaxhighlight lang="c#"> public void SetIcon(Sprite icon) </syntaxhighlight> ==== Description ==== This method updates the visual representation of a role by assigning a new <code>Sprite</code> object as its icon. This is useful for UI elements or any other in-game representat...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Role Class - SetIcon Method

Overview

The SetIcon method in the Role class allows setting a new graphical icon for a specific role.

Syntax

public void SetIcon(Sprite icon)

Description

This method updates the visual representation of a role by assigning a new Sprite object as its icon. This is useful for UI elements or any other in-game representations where roles are visually distinguished.

Usage

This method is commonly used when customizing or updating the visual aspects of roles within the game, making it easier for players to identify different roles at a glance.

Example of Usage

public class RoleIconUpdater : MonoBehaviour {
    public Sprite newGuardIcon; // Assign this in the Unity inspector

    void UpdateGuardIcon() {
        // Retrieve the "Guard" role
        var guardRole = IM.GetRole("Guard");

        // Update the icon for the "Guard" role
        guardRole.SetIcon(newGuardIcon);
    }
}

Remarks

  • It's important to ensure that the icon accurately represents the role's nature and function within the game.
  • Changing a role's icon can be a part of a larger UI update or rebranding within the game.