当前位置: 首页>>代码示例>>C#>>正文


C# POINTER_INFO.Reset方法代码示例

本文整理汇总了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);
	}
开发者ID:exdev,项目名称:urban-survivors,代码行数:78,代码来源:UIManager.cs

示例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);
	}
开发者ID:stevesolomon,项目名称:MicroDungeonPrototype,代码行数:93,代码来源:UIManager.cs


注:本文中的POINTER_INFO.Reset方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。