Icon

From Intrigues Wiki
Revision as of 19:05, 4 January 2024 by Tayfunwiki (talk | contribs) (Created page with "== <code>Icon</code> Property in Scheme Class == === Overview === The <code>Icon</code> property in the Scheme class holds a visual icon associated with the scheme, providing a graphical representation that reflects its theme or action. === Property Definition === <syntaxhighlight lang="c#"> [field: SerializeField] public Sprite Icon { get; private set; } </syntaxhighlight> === Description === * Type: <code>Sprite</code> - Used in Unity for 2D images. * Accessibility...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Icon Property in Scheme Class

Overview

The Icon property in the Scheme class holds a visual icon associated with the scheme, providing a graphical representation that reflects its theme or action.

Property Definition

[field: SerializeField]
public Sprite Icon { get; private set; }

Description

  • Type: Sprite - Used in Unity for 2D images.
  • Accessibility: Publicly readable, but can only be set within the class.

Functionality

  • The Icon serves as a visual identifier, making it easier for players to recognize and understand the scheme's purpose.
  • It enhances user interfaces by visually representing schemes in menus, dialogues, or other interactive elements.

Usage

The Icon property is used in game UIs to display an icon for a scheme. The Scheme objects themselves are not directly editable in the Unity Inspector, but their properties, including Icon, can be accessed and manipulated programmatically.

Example of Usage

public class SchemeUIManager : MonoBehaviour {
    public Image schemeIconImage;

    void Start() {
        // Retrieve a specific scheme by its name
        Scheme currentScheme = IM.Player.GetScheme("Assassination");

        if (currentScheme != null && schemeIconImage != null) {
            // Set the icon of the retrieved scheme in an Image component
            schemeIconImage.sprite = currentScheme.Icon;
            schemeIconImage.gameObject.SetActive(true);
        }
    }
}

Description

  • The Start method in the SchemeUIManager class demonstrates retrieving a specific scheme by name using IM.Player.GetScheme and then using its Icon property to display the scheme's icon in a UI element.

Remarks

  • The Icon property is key to providing intuitive visual cues in game interfaces, especially in games where schemes are a major gameplay element.
  • This approach is beneficial in strategy or role-playing games where visual storytelling and player interaction with various schemes are crucial.