Newer
Older
Dreamsturbia-Project-IADE-Unity3D / Assets / Scripts / Colectible Inventory / SlotController.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;

public class SlotController : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
{
    /*  [HideInInspector]
      public string memoryName;
      [HideInInspector]
      public string description;*/
    public Item item;
    [HideInInspector]
    public Image imageComponent;
    private Image informationPanel;
    private Text infoText;

    void Start()
    {
        imageComponent = GetComponent<Image>();
        informationPanel = GameObject.Find("Information Panel").GetComponent<Image>();
        infoText = GameObject.Find("InfoText").GetComponent<Text>();
    }

    public void OnPointerEnter(PointerEventData pointerEventData)
    {
        //Output to console the GameObject's name and the following message
        informationPanel.color = new Color(1, 1, 1, 1);
        infoText.text = "You recall this memory by " + item.name + " where " + item.description;
    }

    //Detect when Cursor leaves the GameObject
    public void OnPointerExit(PointerEventData pointerEventData)
    {
        //Output the following message with the GameObject's name
        informationPanel.color = new Color(1, 1, 1, 0);
        infoText.text = "";
    }

}