Search Unity

[Unity] 4.6 Beta Error

Discussion in 'Unity UI (uGUI) & TextMesh Pro' started by Subzero619, Aug 30, 2014.

  1. Subzero619

    Subzero619

    Joined:
    Oct 14, 2012
    Posts:
    6
    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.

    Code (CSharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4. using UnityEngine.UI;
    5. using UnityEngine.EventSystems;
    6.  
    7. public class CraftSlot : MonoBehaviour, IDragHandler, IPointerExitHandler, IPointerEnterHandler, IPointerDownHandler{
    8.  
    9.     CraftingSystem craftSystem;
    10.     Inventory inventory;
    11.     public int slotIndex;
    12.     Image image;
    13.     // Use this for initialization
    14.     void Start () {
    15.         image = gameObject.transform.GetChild(0).GetComponent<Image>();
    16.         craftSystem = GameObject.FindGameObjectWithTag("CraftSystem").GetComponent<CraftingSystem>();
    17.         inventory = GameObject.FindGameObjectWithTag("Inventory").GetComponent<Inventory>();
    18.         image.enabled = false;
    19.     }
    20.    
    21.     // Update is called once per frame
    22.  
    23.     //shows icon
    24.     void Update () {
    25.  
    26.         if (craftSystem.itemsinCraftSystem[slotIndex].itemName != null)
    27.         {
    28.             image.sprite = craftSystem.itemsinCraftSystem[slotIndex].itemIcon;
    29.             image.enabled = true;
    30.         }
    31.     }
    32.  
    33.  
    34.     //dragging item in slot
    35.     public void OnPointerDown(PointerEventData data)
    36.     {
    37.        
    38.         //dragging the item into the slot in aswell
    39.         if (inventory.draggingItem)
    40.         {
    41.             craftSystem.itemsinCraftSystem[slotIndex] = inventory.draggedItem;
    42.             inventory.closeDraggedItem();
    43.         }
    44.     }
    45.  
    46.     public void OnPointerEnter(PointerEventData data)
    47.     {
    48.         if (inventory.Items[slotIndex].itemName != null && !inventory.draggingItem)
    49.         {
    50.             inventory.showTooltip(inventory.Slots[slotIndex].GetComponent<RectTransform>().localPosition, inventory.Items[slotIndex]);
    51.         }
    52.     }
    53. }
    54.  
    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)'
     
  2. Ostwind

    Ostwind

    Joined:
    Mar 22, 2011
    Posts:
    2,772
    You are missing OnDrag and OnPointerExit. If you don't need them then remove them from interface list
     
  3. Subzero619

    Subzero619

    Joined:
    Oct 14, 2012
    Posts:
    6
    Thanks man. I assumed it was a bug.
     
  4. Tnagele

    Tnagele

    Joined:
    Jan 3, 2015
    Posts:
    17
    Not really a bug, I had the same issue. Just don't implement the interfaces if you aren't going to use them.