I am currently getting a error in this script but I can’t seem to understand it, I’ve done the same in another script the drag handlers etc; and it works great.
Anyway here is the script.
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using UnityEngine.EventSystems;
public class CraftSlot : MonoBehaviour, IDragHandler, IPointerExitHandler, IPointerEnterHandler, IPointerDownHandler{
CraftingSystem craftSystem;
Inventory inventory;
public int slotIndex;
Image image;
// Use this for initialization
void Start () {
image = gameObject.transform.GetChild(0).GetComponent<Image>();
craftSystem = GameObject.FindGameObjectWithTag("CraftSystem").GetComponent<CraftingSystem>();
inventory = GameObject.FindGameObjectWithTag("Inventory").GetComponent<Inventory>();
image.enabled = false;
}
// Update is called once per frame
//shows icon
void Update () {
if (craftSystem.itemsinCraftSystem[slotIndex].itemName != null)
{
image.sprite = craftSystem.itemsinCraftSystem[slotIndex].itemIcon;
image.enabled = true;
}
}
//dragging item in slot
public void OnPointerDown(PointerEventData data)
{
//dragging the item into the slot in aswell
if (inventory.draggingItem)
{
craftSystem.itemsinCraftSystem[slotIndex] = inventory.draggedItem;
inventory.closeDraggedItem();
}
}
public void OnPointerEnter(PointerEventData data)
{
if (inventory.Items[slotIndex].itemName != null && !inventory.draggingItem)
{
inventory.showTooltip(inventory.Slots[slotIndex].GetComponent<RectTransform>().localPosition, inventory.Items[slotIndex]);
}
}
}
The error I am getting.
Assets/Scripts/CraftSlot.cs(6,14): error CS0535: CraftSlot' does not implement interface member
UnityEngine.EventSystems.IDragHandler.OnDrag(UnityEngine.EventSystems.PointerEventData)’
Assets/Scripts/CraftSlot.cs(6,14): error CS0535: CraftSlot' does not implement interface member
UnityEngine.EventSystems.IPointerExitHandler.OnPointerExit(UnityEngine.EventSystems.PointerEventData)’