- Home /
can't use EventSystems, Reference is missing
Hi, I have a problem. I have Unity 5.1.1 and when I am trying to have "using UnityEngine.EventSystems" the reference is missing. I am trying to use it to get the object being dropped on ondrop function. I couldn't find a lot of info about this issue. Does anyone know how to fix that? Here is the code:
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using UnityEngine.EventSystems;
public class Slot : MonoBehaviour {
public int slotIndex;
public Image icon;
// Use this for initialization
void Start () {
icon=this.gameObject.GetComponent<Image>();
}
// Update is called once per frame
void Update () {
if(Control.programSlots[slotIndex]==ProgramRunner.forLoop)
{
icon.color=Color.blue;
}
if(Control.programSlots[slotIndex]==ProgramRunner.moveBack)
{
icon.color=Color.red;
}
if(Control.programSlots[slotIndex]==ProgramRunner.moveForward)
{
icon.color=Color.yellow;
}
if(Control.programSlots[slotIndex]==ProgramRunner.moveLeft)
{
icon.color=Color.black;
}
if(Control.programSlots[slotIndex]==ProgramRunner.moveRight)
{
icon.color=Color.green;
}
if(Control.programSlots[slotIndex]==ProgramRunner.blankAction)
{
icon.color=Color.white;
}
}
public void OnDrop(EventSystems.PointerEventData data)
{
Control.programSlots[slotIndex]=Control.selectedCard.action;
Control.requestSlots[slotIndex]=Control.selectedCard.req;
}
}
And here is the error: Assets/Slot.cs(41,28): error CS0246: The type or namespace name `EventSystems' could not be found. Are you missing a using directive or an assembly reference?
Help Please!
Answer by Landern · Jul 13, 2015 at 01:46 PM
You're already using UnityEngine.EventSystems so all the types are exposed from that root level of that namespace, in the parameters/arguments of OnDrop remove the "EventSystems." from the parameter type like this:
public void OnDrop(PointerEventData data)
{
Control.programSlots[slotIndex]=Control.selectedCard.action;
Control.requestSlots[slotIndex]=Control.selectedCard.req;
}