void Update()
{
if (!active) return;
var hoverHit = raycastModel.cardCanvasHit;
//check to see if a card in a hand has been hovered
//also check to see if the hit object has been destroyed in the meantime
if (hoverHit.HasValue
&& hoverHit.Value.collider != null
&& hoverHit.Value.collider.gameObject.transform.parent.name == "cardCanvas"
)
{
hoverSignal.Dispatch(hoverHit.Value.collider.gameObject);
}
else
{
hoverSignal.Dispatch(null);
}
if (draggedObject != null)
{
dragTimer += Time.deltaTime;
}
if (CrossPlatformInputManager.GetButtonUp("Fire1")) {
if (draggedObject != null && dragTimer > dragMin)
{
TestActivate();
}
}
if (CrossPlatformInputManager.GetButtonDown("Fire1"))
{
//if we're already dragging, test the activate, otherwise start dragging
if (draggedObject != null && dragTimer > dragMin)
{
TestActivate();
}
else
{
if (hoverHit.HasValue)
{
clickSignal.Dispatch(hoverHit.Value.collider.gameObject, hoverHit.Value.point);
}
else
{
clickSignal.Dispatch(null, Vector3.zero);
}
}
}
//right click et al deselects
if (CrossPlatformInputManager.GetButtonDown("Fire2"))
{
clickSignal.Dispatch(null, Vector3.zero);
dragTimer = 0f;
}
//if (camRay.origin != null)
//{
// Debug.DrawLine(camRay.origin, Quaternion.Euler(camRay.direction) * camRay.origin * Constants.cameraRaycastDist, Color.red, 10f);
//}
}