using UnityEngine; using System.Collections; using UnityEngine.UI; // ** Can potentially merge with the money script. // script to change the top left player portrait based on the player appearance and toggle the inventory panel. public class Portrait : MonoBehaviour { private setAppearance appearance; private PlayerStats stats; // to access name public Text playerName; public Image face; public Image head; private Color color; private CanvasGroup inventory; // to toggle the panel on and off // Use this for initialization void Start () { stats = GameObject.Find("Player").GetComponent<PlayerStats>(); appearance = GameObject.Find("Player").GetComponent<setAppearance>(); inventory = GameObject.Find("inventoryPanel").GetComponent<CanvasGroup>(); color = appearance.getColor(); playerName.text = stats.getName(); face.sprite = appearance.getFace(); head.sprite = appearance.getHead(); face.color = color; head.color = color; // inventory initially invisible inventory.alpha = 0; inventory.interactable = false; inventory.blocksRaycasts = false; } public void OnClick() { if (inventory.alpha == 1) { // if the inventory screen is up inventory.alpha = 0; // hide inventory.interactable = false; inventory.blocksRaycasts = false; } else if (inventory.alpha == 0) { // if the inventory screen is hidden inventory.alpha = 1; // show inventory.interactable = true; inventory.blocksRaycasts = true; } } }