Not sure if this is just a bug in Unity or just something i am missing. So i have the following class, it works fine when the script is located in the project but when i try to move it to a dll for use in other projects it starts throwing Missing field exceptions whenever I try to access any variable in PointerEventData.
Currently running version 4.6.1p5, any help would be appreciated.
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.EventSystems;
public class DragThresholdListener : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler
{
public float Threshold = 100f;
public bool Horizontal = true;
public bool Vertical = false;
public UnityEvent PositiveThresholdEvent = null;
public UnityEvent NegitiveThresholdEvent = null;
private Vector2 Delta = Vector2.zero;
public void OnBeginDrag(UnityEngine.EventSystems.PointerEventData eventData)
{
Delta = Vector2.zero;
}
public void OnDrag(UnityEngine.EventSystems.PointerEventData eventData)
{
Delta += eventData.delta;
if (Horizontal)
{
if (Delta.x > Threshold)
{
Delta.x -= Threshold;
if (PositiveThresholdEvent != null)
{
PositiveThresholdEvent.Invoke();
}
}
else if (Delta.x < (Threshold * -1))
{
Delta.x += Threshold;
if (NegitiveThresholdEvent != null)
{
NegitiveThresholdEvent.Invoke();
}
}
}
if (Vertical)
{
if (Delta.y > Threshold)
{
Delta.y -= Threshold;
if (PositiveThresholdEvent != null)
{
PositiveThresholdEvent.Invoke();
}
}
else if (Delta.y < (Threshold * -1))
{
Delta.y += Threshold;
if (NegitiveThresholdEvent != null)
{
NegitiveThresholdEvent.Invoke();
}
}
}
}
}
Full error details:
MissingFieldException: Field 'UnityEngine.EventSystems.PointerEventData.delta' not found.
UnityEngine.EventSystems.ExecuteEvents.Execute (IDragHandler handler, UnityEngine.EventSystems.BaseEventData eventData) (at /Users/builduser/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/EventSystem/ExecuteEvents.cs:73)
UnityEngine.EventSystems.ExecuteEvents.Execute[IDragHandler] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.EventFunction`1 functor) (at /Users/builduser/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/EventSystem/ExecuteEvents.cs:269)
UnityEngine.EventSystems.EventSystem:Update()
↧