Policy.Icon

From Intrigues Wiki

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.