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


C# IUIObject.OnInput方法代码示例

本文整理汇总了C#中IUIObject.OnInput方法的典型用法代码示例。如果您正苦于以下问题:C# IUIObject.OnInput方法的具体用法?C# IUIObject.OnInput怎么用?C# IUIObject.OnInput使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IUIObject的用法示例。


在下文中一共展示了IUIObject.OnInput方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DispatchHelper

	protected void DispatchHelper(ref POINTER_INFO curPtr)
	{
		switch (curPtr.evt)
		{
			case POINTER_INFO.INPUT_EVENT.DRAG:
			case POINTER_INFO.INPUT_EVENT.RELEASE:
			case POINTER_INFO.INPUT_EVENT.TAP:
				// See if a tap or release took place outside of
				// the targetObj:
				if (curPtr.evt == POINTER_INFO.INPUT_EVENT.RELEASE ||
					curPtr.evt == POINTER_INFO.INPUT_EVENT.TAP)
				{
					tempObj = null;

					if (Physics.Raycast(curPtr.ray, out hit, curPtr.rayDepth, curPtr.layerMask))
					{
#if INTOLERANT_GET_COMPONENT
						tempObj = (IUIObject)hit.collider.gameObject.GetComponent(typeof(IUIObject));
#else
						// Else, get the component in a tolerant way:
						tempObj = (IUIObject)hit.collider.gameObject.GetComponent("IUIObject");
#endif
						curPtr.hitInfo = hit;
					}
					else
						curPtr.hitInfo = default(RaycastHit);

					// If the hit object (or lack thereof) is not
					// the same as the current target:
					if (tempObj != curPtr.targetObj)
					{
						// If we have someone to notify of a release-off:
						if (curPtr.targetObj != null && !blockInput) // Don't change the targetObj if input is blocked
						{
							// Notify the targetObj of the event:
							tempPtr.Copy(curPtr);
							// Pass on a RELEASE_OFF if it was a RELEASE event,
							// else, pass on the TAP:
							if (curPtr.evt == POINTER_INFO.INPUT_EVENT.RELEASE)
								tempPtr.evt = POINTER_INFO.INPUT_EVENT.RELEASE_OFF;
							else
								tempPtr.evt = POINTER_INFO.INPUT_EVENT.TAP;

							curPtr.targetObj.OnInput(tempPtr);

							curPtr.targetObj = tempObj;
						}

						// See if we need to notify our new target:
						if (tempObj != null)
						{
							// Only pass on a non-tap event
							// to a different target from the
							// one the pointer already had:
							if (curPtr.evt != POINTER_INFO.INPUT_EVENT.TAP && !blockInput)
								tempObj.OnInput(curPtr);
						}
					}
					else if (curPtr.targetObj != null)
					{
						// Tell our target about the event:
						if (!blockInput)
							curPtr.targetObj.OnInput(curPtr);
					}

					// See if we hit a non-UI object:
					if (tempObj == null)
					{
						if (informNonUIHit != null)
							informNonUIHit(curPtr);
					}

				}// Notify focus object:
				else
				{
					if (Physics.Raycast(curPtr.ray, out hit, curPtr.rayDepth, curPtr.layerMask))
						curPtr.hitInfo = hit;

					if (curPtr.targetObj == null)
					{
						if (informNonUIHit != null)
							informNonUIHit(curPtr);
					}
					else if (!blockInput)
					{
						curPtr.targetObj.OnInput(curPtr);
					}
				}
				break;
			case POINTER_INFO.INPUT_EVENT.NO_CHANGE:
			case POINTER_INFO.INPUT_EVENT.MOVE:
				tempObj = null;
				// See if we need to notify anyone:
				if (Physics.Raycast(curPtr.ray, out hit, curPtr.rayDepth, curPtr.layerMask))
				{
#if INTOLERANT_GET_COMPONENT
					tempObj = (IUIObject)hit.collider.gameObject.GetComponent(typeof(IUIObject));
#else
					// Else, get the component in a tolerant way:
					tempObj = (IUIObject)hit.collider.gameObject.GetComponent("IUIObject");
//.........这里部分代码省略.........
开发者ID:robert-irribarren,项目名称:TraumaOR,代码行数:101,代码来源:UIManager.cs


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