Policy.Icon

From Intrigues Wiki
Revision as of 09:22, 5 January 2024 by Tayfunwiki (talk | contribs) (Created page with "=== Policy Class - <code>Icon</code> Property === ==== Overview ==== The <code>Icon</code> property in the Policy class represents the visual symbol or graphic associated with a specific policy, like "Economy." ==== Syntax ==== <syntaxhighlight lang="c#"> [field: SerializeField] public Sprite Icon { get; private set; } </syntaxhighlight> ==== Description ==== This property holds a <code>Sprite</code> object which serves as the icon for the policy. It can be used in th...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Policy Class - Icon Property

Overview

The Icon property in the Policy class represents the visual symbol or graphic associated with a specific policy, like "Economy."

Syntax

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

Description

This property holds a Sprite object which serves as the icon for the policy. It can be used in the game's user interface to visually represent the policy.

Usage

The Icon property is typically used to display an image or icon in the game's UI, helping players to quickly identify the policy.

Example of Usage

public class PolicyDisplay : MonoBehaviour {
    private Policy currentPolicy;
    public Image policyIconDisplay; // Reference to a UI Image component

    void Start() {
        // Fetching the 'Economy' policy from the game's policy manager
        currentPolicy = IM.GetPolicy("Economy");

        if (currentPolicy != null && policyIconDisplay != null) {
            // Setting the UI Image to the policy's icon
            policyIconDisplay.sprite = currentPolicy.Icon;
        }
    }
}

Remarks

  • The Icon property is accessed from a Policy object, retrieved through the IM.GetPolicy method.
  • This property is essential for visually representing policies in the game's UI, enhancing player understanding and engagement.
  • Ensure that the UI component (like Image) is properly referenced in the script to display the icon correctly.