本文整理汇总了C#中POINTER_INFO.Reset方法的典型用法代码示例。如果您正苦于以下问题:C# POINTER_INFO.Reset方法的具体用法?C# POINTER_INFO.Reset怎么用?C# POINTER_INFO.Reset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类POINTER_INFO
的用法示例。
在下文中一共展示了POINTER_INFO.Reset方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PollMouse
// Polls the mouse pointing device
protected void PollMouse(ref POINTER_INFO curPtr)
{
down = Input.GetMouseButton(0);
// If the device is pressed and it
// was already pressed, it's a drag
// or a repeat, depending on if there
// was movement:
if (down && curPtr.active)
{
// Drag:
if (Input.mousePosition != curPtr.devicePos)
{
curPtr.evt = POINTER_INFO.INPUT_EVENT.DRAG;
curPtr.inputDelta = Input.mousePosition - curPtr.devicePos;
curPtr.devicePos = Input.mousePosition;
// See if we have exceeded the drag threshold:
if (curPtr.isTap)
{
tempVec = curPtr.origPos - curPtr.devicePos;
if (Mathf.Abs(tempVec.x) > dragThreshold || Mathf.Abs(tempVec.y) > dragThreshold)
curPtr.isTap = false;
}
}
else
{
// Nothing to see here:
curPtr.evt = POINTER_INFO.INPUT_EVENT.NO_CHANGE;
curPtr.inputDelta = Vector3.zero;
}
}
else if (down && !curPtr.active) // Else if it's a new press, it's a press
{
curPtr.Reset(curActionID++);
curPtr.evt = POINTER_INFO.INPUT_EVENT.PRESS;
curPtr.active = true;
curPtr.inputDelta = Input.mousePosition - curPtr.devicePos;
curPtr.origPos = Input.mousePosition;
curPtr.isTap = true; // True for now, until it moves too much
}
else if (!down && curPtr.active) // A release
{
curPtr.inputDelta = Input.mousePosition - curPtr.devicePos;
curPtr.devicePos = Input.mousePosition;
// See if we have exceeded the drag threshold:
if (curPtr.isTap)
{
tempVec = curPtr.origPos - curPtr.devicePos;
if (Mathf.Abs(tempVec.x) > dragThreshold || Mathf.Abs(tempVec.y) > dragThreshold)
curPtr.isTap = false;
}
if (curPtr.isTap)
curPtr.evt = POINTER_INFO.INPUT_EVENT.TAP;
else
curPtr.evt = POINTER_INFO.INPUT_EVENT.RELEASE;
curPtr.active = false;
}
else if (!down && Input.mousePosition != curPtr.devicePos) // Mouse was moved
{
curPtr.evt = POINTER_INFO.INPUT_EVENT.MOVE;
curPtr.inputDelta = Input.mousePosition - curPtr.devicePos;
curPtr.devicePos = Input.mousePosition;
}
else
{
curPtr.evt = POINTER_INFO.INPUT_EVENT.NO_CHANGE;
curPtr.inputDelta = Vector3.zero;
}
curPtr.devicePos = Input.mousePosition;
curPtr.prevRay = curPtr.ray;
curPtr.ray = uiCameras[0].camera.ScreenPointToRay(curPtr.devicePos);
}
示例2: PollMouse
// Polls the mouse pointing device
protected void PollMouse(ref POINTER_INFO curPtr)
{
down = Input.GetMouseButton(0);
// Check for scroll wheel:
float scrollDelta = Input.GetAxis("Mouse ScrollWheel");
#if SCROLL_IS_TIME_COHERENT
scrollDelta *= Time.deltaTime;
#endif
bool scrolled = (scrollDelta != 0);
// If the device is pressed and it
// was already pressed, it's a drag
// or a repeat, depending on if there
// was movement:
if (down && curPtr.active)
{
// Drag:
if (Input.mousePosition != curPtr.devicePos)
{
curPtr.evt = POINTER_INFO.INPUT_EVENT.DRAG;
curPtr.inputDelta = Input.mousePosition - curPtr.devicePos;
curPtr.devicePos = Input.mousePosition;
// See if we have exceeded the drag threshold:
if (curPtr.isTap)
{
tempVec = curPtr.origPos - curPtr.devicePos;
if (Mathf.Abs(tempVec.x) > dragThreshold || Mathf.Abs(tempVec.y) > dragThreshold)
curPtr.isTap = false;
}
}
else
{
// Nothing to see here:
curPtr.evt = POINTER_INFO.INPUT_EVENT.NO_CHANGE;
curPtr.inputDelta = Vector3.zero;
}
}
else if (down && !curPtr.active) // Else if it's a new press, it's a press
{
curPtr.Reset(curActionID++);
curPtr.evt = POINTER_INFO.INPUT_EVENT.PRESS;
curPtr.active = true;
curPtr.inputDelta = Input.mousePosition - curPtr.devicePos;
curPtr.origPos = Input.mousePosition;
curPtr.isTap = true; // True for now, until it moves too much
curPtr.activeTime = Time.time;
}
else if (!down && curPtr.active) // A release
{
curPtr.inputDelta = Input.mousePosition - curPtr.devicePos;
curPtr.devicePos = Input.mousePosition;
// See if we have exceeded the drag threshold:
if (curPtr.isTap)
{
tempVec = curPtr.origPos - curPtr.devicePos;
if (Mathf.Abs(tempVec.x) > dragThreshold || Mathf.Abs(tempVec.y) > dragThreshold)
curPtr.isTap = false;
}
if (curPtr.isTap)
curPtr.evt = POINTER_INFO.INPUT_EVENT.TAP;
else
curPtr.evt = POINTER_INFO.INPUT_EVENT.RELEASE;
curPtr.active = false;
curPtr.activeTime = 0;
}
else if (!down && Input.mousePosition != curPtr.devicePos) // Mouse was moved
{
curPtr.evt = POINTER_INFO.INPUT_EVENT.MOVE;
curPtr.inputDelta = Input.mousePosition - curPtr.devicePos;
curPtr.devicePos = Input.mousePosition;
}
else
{
curPtr.evt = POINTER_INFO.INPUT_EVENT.NO_CHANGE;
curPtr.inputDelta = Vector3.zero;
}
// Add any scroll delta in to the Z coordinate:
if (scrolled)
{
curPtr.inputDelta.z = scrollDelta;
}
curPtr.devicePos = Input.mousePosition;
curPtr.prevRay = curPtr.ray;
curPtr.ray = uiCameras[0].camera.ScreenPointToRay(curPtr.devicePos);
}