public TouchInfo(ref UnityEngine.Touch touch, DefaultCameraMover cameraMover) { this.ScreenPos = touch.position; this.fingerIdOffseted = touch.fingerId + 1; this.HitPos = cameraMover.GetIntersectionPoint(touch.position); this.Phase = touch.phase; }
static object PerformMemberwiseClone(ref object o) { var ins = new UnityEngine.Touch(); ins = (UnityEngine.Touch)o; return(ins); }
static void WriteBackInstance(CSHotFix.Runtime.Enviorment.AppDomain __domain, StackObject *ptr_of_this_method, IList <object> __mStack, ref UnityEngine.Touch instance_of_this_method) { ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method); switch (ptr_of_this_method->ObjectType) { case ObjectTypes.Object: { __mStack[ptr_of_this_method->Value] = instance_of_this_method; } break; case ObjectTypes.FieldReference: { var ___obj = __mStack[ptr_of_this_method->Value]; if (___obj is ILTypeInstance) { ((ILTypeInstance)___obj)[ptr_of_this_method->ValueLow] = instance_of_this_method; } else { var t = __domain.GetType(___obj.GetType()) as CLRType; t.SetFieldValue(ptr_of_this_method->ValueLow, ref ___obj, instance_of_this_method); } } break; case ObjectTypes.StaticFieldReference: { var t = __domain.GetType(ptr_of_this_method->Value); if (t is ILType) { ((ILType)t).StaticInstance[ptr_of_this_method->ValueLow] = instance_of_this_method; } else { ((CLRType)t).SetStaticFieldValue(ptr_of_this_method->ValueLow, instance_of_this_method); } } break; case ObjectTypes.ArrayReference: { var instance_of_arrayReference = __mStack[ptr_of_this_method->Value] as UnityEngine.Touch[]; instance_of_arrayReference[ptr_of_this_method->ValueLow] = instance_of_this_method; } break; } }
int UnityEngineInput_m_GetTouch_xlua_st_(RealStatePtr L, int gen_param_count) { ObjectTranslator translator = this; { int _index = LuaAPI.xlua_tointeger(L, 1); UnityEngine.Touch gen_ret = UnityEngine.Input.GetTouch(_index); translator.Push(L, gen_ret); return(1); } }
static StackObject *get_phase_0(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 1); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method); UnityEngine.Touch instance_of_this_method = (UnityEngine.Touch) typeof(UnityEngine.Touch).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); var result_of_this_method = instance_of_this_method.phase; ptr_of_this_method = ILIntepreter.Minus(__esp, 1); WriteBackInstance(__domain, ptr_of_this_method, __mStack, ref instance_of_this_method); __intp.Free(ptr_of_this_method); return(ILIntepreter.PushObject(__ret, __mStack, result_of_this_method)); }
static int _m_GetTouch_xlua_st_(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); { int _index = LuaAPI.xlua_tointeger(L, 1); UnityEngine.Touch gen_ret = UnityEngine.Input.GetTouch(_index); translator.Push(L, gen_ret); return(1); } } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } }
static int _m_GetTouch(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); UnityEngine.EventSystems.BaseInput __cl_gen_to_be_invoked = (UnityEngine.EventSystems.BaseInput)translator.FastGetCSObj(L, 1); try { { int index = LuaAPI.xlua_tointeger(L, 2); UnityEngine.Touch __cl_gen_ret = __cl_gen_to_be_invoked.GetTouch(index); translator.Push(L, __cl_gen_ret); return(1); } } catch (System.Exception __gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e)); } }
public static ITouch ToUniject(this UnityEngine.Touch t) { return(new UnityTouch(t)); }
/** Main */ public static bool Main() { try{ //リスト作成。 if (Fee.Input.Input.GetInstance().touch.device_item_list.Length < UnityEngine.Input.touchCount) { Fee.Input.Input.GetInstance().touch.device_item_list = new Touch.Touch_Device_Item[UnityEngine.Input.touchCount]; } //list Touch.Touch_Device_Item[] t_list = Fee.Input.Input.GetInstance().touch.device_item_list; int t_list_count = 0; for (int ii = 0; ii < UnityEngine.Input.touchCount; ii++) { UnityEngine.Touch t_touch = UnityEngine.Input.GetTouch(ii); switch (t_touch.phase) { case UnityEngine.TouchPhase.Began: case UnityEngine.TouchPhase.Moved: case UnityEngine.TouchPhase.Stationary: { //デバイス。 int t_x; int t_y; { int t_pos_x = (int)t_touch.position.x; int t_pos_y = UnityEngine.Screen.height - (int)t_touch.position.y; //(GUIスクリーン座標)=>(仮想スクリーン座標)。 Fee.Render2D.Render2D.GetInstance().GuiScreenToVirtualScreen(t_pos_x, t_pos_y, out t_x, out t_y); } //位置。 t_list[t_list_count].x = t_x; t_list[t_list_count].y = t_y; //フェーズ。 if (t_touch.phase == UnityEngine.TouchPhase.Began) { t_list[t_list_count].phasetype = Touch_Phase.PhaseType.Began; } else if (t_touch.phase == UnityEngine.TouchPhase.Moved) { t_list[t_list_count].phasetype = Touch_Phase.PhaseType.Moved; } else if (t_touch.phase == UnityEngine.TouchPhase.Stationary) { t_list[t_list_count].phasetype = Touch_Phase.PhaseType.Stationary; } else { t_list[t_list_count].phasetype = Touch_Phase.PhaseType.None; } //フラグ。 t_list[t_list_count].link = false; //追加情報。 t_list[t_list_count].touch_raw_id = Touch.INVALID_TOUCH_RAW_ID; t_list_count++; } break; } } Fee.Input.Input.GetInstance().touch.device_item_list_count = t_list_count; //debugview #if (UNITY_EDITOR) || (DEVELOPMENT_BUILD) || (USE_DEF_FEE_DEBUGTOOL) { Fee.Input.Input.GetInstance().debugview.touch = "Touch_Phase_InputManager_InputTouch"; } #endif return(true); }catch (System.Exception t_exception) { Tool.DebugReThrow(t_exception); } return(false); }
public UnityEngine.EventSystems.PointerEventData ExecuteTouchEvent(UnityEngine.Touch touch, UnityEngine.EventSystems.PointerEventData previousData = null) { if (UnityEngine.EventSystems.EventSystem.current != null) { UnityEngine.EventSystems.RaycastResult raycastResult; System.Collections.Generic.List <UnityEngine.EventSystems.RaycastResult> raycastResults; switch (touch.phase) { case UnityEngine.TouchPhase.Began: UnityEngine.EventSystems.PointerEventData pointerEventData = new UnityEngine.EventSystems.PointerEventData(UnityEngine.EventSystems.EventSystem.current) { position = touch.position, delta = touch.deltaPosition, button = UnityEngine.EventSystems.PointerEventData.InputButton.Left, pointerId = touch.fingerId }; raycastResults = new System.Collections.Generic.List <UnityEngine.EventSystems.RaycastResult>(); UnityEngine.EventSystems.EventSystem.current.RaycastAll(pointerEventData, raycastResults); raycastResult = UnityEngine.EventSystems.BaseInputModule.FindFirstRaycast(raycastResults); pointerEventData.pointerCurrentRaycast = raycastResult; pointerEventData.pointerPressRaycast = pointerEventData.pointerCurrentRaycast; pointerEventData.pointerEnter = UnityEngine.EventSystems.ExecuteEvents.ExecuteHierarchy(pointerEventData.pointerCurrentRaycast.gameObject, pointerEventData, UnityEngine.EventSystems.ExecuteEvents.pointerEnterHandler); pointerEventData.pointerPress = UnityEngine.EventSystems.ExecuteEvents.ExecuteHierarchy(pointerEventData.pointerCurrentRaycast.gameObject, pointerEventData, UnityEngine.EventSystems.ExecuteEvents.pointerDownHandler); UnityEngine.EventSystems.ExecuteEvents.ExecuteHierarchy(pointerEventData.pointerCurrentRaycast.gameObject, pointerEventData, UnityEngine.EventSystems.ExecuteEvents.initializePotentialDrag); UnityEngine.EventSystems.ExecuteEvents.ExecuteHierarchy(pointerEventData.pointerCurrentRaycast.gameObject, pointerEventData, UnityEngine.EventSystems.ExecuteEvents.beginDragHandler); pointerEventData.pointerDrag = UnityEngine.EventSystems.ExecuteEvents.ExecuteHierarchy(pointerEventData.pointerCurrentRaycast.gameObject, pointerEventData, UnityEngine.EventSystems.ExecuteEvents.dragHandler); if (pointerEventData.pointerPress == null) { pointerEventData.pointerPress = UnityEngine.EventSystems.ExecuteEvents.ExecuteHierarchy(pointerEventData.pointerCurrentRaycast.gameObject, pointerEventData, UnityEngine.EventSystems.ExecuteEvents.pointerClickHandler); } return(pointerEventData); case UnityEngine.TouchPhase.Moved: if (previousData != null) { raycastResults = new System.Collections.Generic.List <UnityEngine.EventSystems.RaycastResult>(); UnityEngine.EventSystems.EventSystem.current.RaycastAll(previousData, raycastResults); raycastResult = UnityEngine.EventSystems.BaseInputModule.FindFirstRaycast(raycastResults); previousData.pointerCurrentRaycast = raycastResult; previousData.delta = touch.deltaPosition; previousData.position = touch.position; raycastResults = new System.Collections.Generic.List <UnityEngine.EventSystems.RaycastResult>(); UnityEngine.EventSystems.EventSystem.current.RaycastAll(previousData, raycastResults); raycastResult = UnityEngine.EventSystems.BaseInputModule.FindFirstRaycast(raycastResults); previousData.pointerCurrentRaycast = raycastResult; if (previousData.pointerEnter != previousData.pointerCurrentRaycast.gameObject) { UnityEngine.EventSystems.ExecuteEvents.ExecuteHierarchy(previousData.pointerEnter, previousData, UnityEngine.EventSystems.ExecuteEvents.pointerExitHandler); UnityEngine.EventSystems.ExecuteEvents.ExecuteHierarchy(previousData.pointerCurrentRaycast.gameObject, previousData, UnityEngine.EventSystems.ExecuteEvents.pointerEnterHandler); previousData.pointerEnter = previousData.pointerCurrentRaycast.gameObject; } if (previousData.delta != UnityEngine.Vector2.zero) { UnityEngine.EventSystems.ExecuteEvents.ExecuteHierarchy(previousData.pointerDrag, previousData, UnityEngine.EventSystems.ExecuteEvents.dragHandler); } return(previousData); } break; case UnityEngine.TouchPhase.Ended: if (previousData != null) { raycastResults = new System.Collections.Generic.List <UnityEngine.EventSystems.RaycastResult>(); UnityEngine.EventSystems.EventSystem.current.RaycastAll(previousData, raycastResults); raycastResult = UnityEngine.EventSystems.BaseInputModule.FindFirstRaycast(raycastResults); previousData.pointerCurrentRaycast = raycastResult; UnityEngine.EventSystems.ExecuteEvents.ExecuteHierarchy(previousData.pointerPress, previousData, UnityEngine.EventSystems.ExecuteEvents.pointerUpHandler); UnityEngine.EventSystems.ExecuteEvents.ExecuteHierarchy(previousData.pointerPress, previousData, UnityEngine.EventSystems.ExecuteEvents.pointerClickHandler); UnityEngine.EventSystems.ExecuteEvents.ExecuteHierarchy(previousData.pointerDrag, previousData, UnityEngine.EventSystems.ExecuteEvents.endDragHandler); UnityEngine.EventSystems.ExecuteEvents.ExecuteHierarchy(previousData.pointerCurrentRaycast.gameObject, previousData, UnityEngine.EventSystems.ExecuteEvents.dropHandler); UnityEngine.EventSystems.ExecuteEvents.ExecuteHierarchy(previousData.pointerCurrentRaycast.gameObject, previousData, UnityEngine.EventSystems.ExecuteEvents.pointerExitHandler); return(previousData); } break; } return(previousData); } return(null); }
/** 更新。インプットマネージャ。インプットタッチ。タッチ。 */ public bool Main_InputManager_InputTouch_Touch(Fee.Render2D.Render2D a_render2d) { //devicename this.devicename = "inputtouch"; //device_item_list_count this.device_item_list_count = 0; //リスト作成。 if (this.device_item_list.Length < UnityEngine.Input.touchCount) { this.device_item_list = new Touch_Device_Item[UnityEngine.Input.touchCount]; } for (int ii = 0; ii < UnityEngine.Input.touchCount; ii++) { UnityEngine.Touch t_touch = UnityEngine.Input.GetTouch(ii); switch (t_touch.phase) { case UnityEngine.TouchPhase.Began: case UnityEngine.TouchPhase.Moved: case UnityEngine.TouchPhase.Stationary: { //デバイス。 int t_x; int t_y; { int t_pos_x = (int)t_touch.position.x; int t_pos_y = this.screen_h - (int)t_touch.position.y; /* * { * t_pos_x = t_pos_x * UnityEngine.Screen.width / this.screen_w; * t_pos_y = t_pos_y * UnityEngine.Screen.height / this.screen_h; * } */ //(GUIスクリーン座標)=>(仮想スクリーン座標)。 a_render2d.GuiScreenToVirtualScreen(t_pos_x, t_pos_y, out t_x, out t_y); } //位置。 this.device_item_list[this.device_item_list_count].x = t_x; this.device_item_list[this.device_item_list_count].y = t_y; //フェーズ。 if (t_touch.phase == UnityEngine.TouchPhase.Began) { this.device_item_list[this.device_item_list_count].phasetype = Touch_Phase.PhaseType.Began; } else if (t_touch.phase == UnityEngine.TouchPhase.Moved) { this.device_item_list[this.device_item_list_count].phasetype = Touch_Phase.PhaseType.Moved; } else if (t_touch.phase == UnityEngine.TouchPhase.Stationary) { this.device_item_list[this.device_item_list_count].phasetype = Touch_Phase.PhaseType.Stationary; } else { this.device_item_list[this.device_item_list_count].phasetype = Touch_Phase.PhaseType.None; } //フラグ。 this.device_item_list[this.device_item_list_count].link = false; //追加情報。 this.device_item_list[this.device_item_list_count].touch_raw_id = Touch.INVALID_TOUCH_RAW_ID; this.device_item_list_count++; } break; } } return(true); }
protected void HandleTouch() { int touchCountMax = this.touchInfos.Length; for (int i = 0; i < touchCountMax; ++i) { this.previousTouchInfos[i] = new TouchInfo(); } int touchCount = UnityEngine.Mathf.Min(touchCountMax, UnityEngine.Input.touchCount); for (int i = 0; i < touchCount; ++i) { int sameFinger = -1; UnityEngine.Touch touch = UnityEngine.Input.GetTouch(i); for (int previousInputId = 0; previousInputId < touchCountMax; ++previousInputId) { if (this.touchInfos[previousInputId].SameFingerID(ref touch)) { sameFinger = previousInputId; } } if (sameFinger != -1) { this.previousTouchInfos[i] = this.touchInfos[sameFinger]; } else { this.previousTouchInfos[i] = new TouchInfo(); } } this.previousMouseTouchInfo = this.mouseTouchInfo; for (int i = 0; i < touchCount; ++i) { UnityEngine.Touch touch = UnityEngine.Input.GetTouch(i); this.touchInfos[i] = new TouchInfo(ref touch, this); } UnityEngine.TouchPhase mouseTouchPhase = UnityEngine.Input.GetMouseButton(0) ? (UnityEngine.Input.GetMouseButtonDown(0) ? UnityEngine.TouchPhase.Began : UnityEngine.TouchPhase.Moved) : UnityEngine.TouchPhase.Ended; this.mouseTouchInfo = new TouchInfo() { ScreenPos = UnityEngine.Input.mousePosition, HitPos = GetIntersectionPoint(UnityEngine.Input.mousePosition), Phase = mouseTouchPhase }; for (int i = touchCount; i < touchCountMax; ++i) { this.touchInfos[i] = new TouchInfo(); } if (touchCount == 0 && this.mouseTouchInfo.Phase == UnityEngine.TouchPhase.Moved && this.TouchTranslation) { UnityEngine.Ray ray = this.usedCamera.ScreenPointToRay(this.mouseTouchInfo.ScreenPos); float previousHeight = this.transform.position.y; UnityEngine.Vector3 nextPosition = this.previousMouseTouchInfo.HitPos + ray.direction * (previousHeight / ray.direction.y); nextPosition.y = previousHeight; this.transform.position = nextPosition; } if (touchCount == 1) { if (this.touchInfos[0].Phase == UnityEngine.TouchPhase.Moved && this.previousTouchInfos[0].FingerId != -1 && this.TouchTranslation) { UnityEngine.Ray ray = this.usedCamera.ScreenPointToRay(this.touchInfos[0].ScreenPos); float previousHeight = this.transform.position.y; UnityEngine.Vector3 nextPosition = this.previousTouchInfos[0].HitPos + ray.direction * (previousHeight / ray.direction.y); nextPosition.y = previousHeight; this.transform.position = nextPosition; } } if (touchCount == 2) { if ((this.touchInfos[0].Phase == UnityEngine.TouchPhase.Moved || this.touchInfos[1].Phase == UnityEngine.TouchPhase.Moved) && (this.previousTouchInfos[0].FingerId != -1 && this.previousTouchInfos[1].FingerId != -1)) { UnityEngine.Vector3 previousDifHitPos = this.previousTouchInfos[0].HitPos - this.previousTouchInfos[1].HitPos; float previousDistance01 = UnityEngine.Vector3.Magnitude(previousDifHitPos); UnityEngine.Vector3 difHitPos = this.touchInfos[0].HitPos - this.touchInfos[1].HitPos; float currentDistance01 = UnityEngine.Vector3.Magnitude(difHitPos); UnityEngine.Vector3 nextPosition = this.transform.position; UnityEngine.Vector2 middleScreenPoint = (this.touchInfos[0].ScreenPos + this.touchInfos[1].ScreenPos) * 0.5f; UnityEngine.Ray ray = this.usedCamera.ScreenPointToRay(middleScreenPoint); nextPosition -= ray.direction * (previousDistance01 - currentDistance01); if (this.TouchZoom) { this.transform.position = nextPosition; } float deltaAngleAroundY = 0; { UnityEngine.Vector2 difScreenPos = this.touchInfos[0].ScreenPos - this.touchInfos[1].ScreenPos; UnityEngine.Vector2 previousDifScreenPos = this.previousTouchInfos[0].ScreenPos - this.previousTouchInfos[1].ScreenPos; float currentAngle = UnityEngine.Mathf.Atan2(difScreenPos.y, difScreenPos.x); float previousAngle = UnityEngine.Mathf.Atan2(previousDifScreenPos.y, previousDifScreenPos.x); deltaAngleAroundY += (currentAngle - previousAngle) * 180f / UnityEngine.Mathf.PI; } float deltaAngleX = 0; UnityEngine.Vector2 previousMiddlePoint = (this.previousTouchInfos[0].ScreenPos + this.previousTouchInfos[1].ScreenPos) * 0.5f; { UnityEngine.Vector2 modifiedPreviousMiddlePoint = previousMiddlePoint; modifiedPreviousMiddlePoint.x = middleScreenPoint.x; UnityEngine.Ray previousRay = this.usedCamera.ScreenPointToRay(modifiedPreviousMiddlePoint); float absDeltaAngleX = UnityEngine.Vector3.Angle(previousRay.direction, ray.direction); deltaAngleX += (previousMiddlePoint.y < middleScreenPoint.y) ? absDeltaAngleX : -absDeltaAngleX; } float deltaAngleY = 0; { //UnityEngine.Vector2 modifiedPreviousMiddlePoint = previousMiddlePoint; //UnityEngine.Ray previousRay = this.usedCamera.ScreenPointToRay(modifiedPreviousMiddlePoint); //UnityEngine.Vector3 projectedPreviousRayDirection = previousRay.direction; //projectedPreviousRayDirection.y = 0; //UnityEngine.Vector3 projectedRayDirection = previousRay.direction; //projectedRayDirection.y = 0; //float absDeltaAngleY = UnityEngine.Vector3.Angle(this.transform.forward, previousRay.direction); //deltaAngleY += (previousMiddlePoint.x < middleScreenPoint.x) ? absDeltaAngleY : -absDeltaAngleY; } if (deltaAngleAroundY != 0 || deltaAngleX != 0 || deltaAngleY != 0) { UnityEngine.Vector3 rotateAround = GetIntersectionPoint(middleScreenPoint); UnityEngine.Vector3 nextEulerAngles = this.transform.eulerAngles; nextEulerAngles.y += deltaAngleAroundY; this.transform.eulerAngles = nextEulerAngles; UnityEngine.Ray nextRay = this.usedCamera.ScreenPointToRay(middleScreenPoint); float originalDistance = UnityEngine.Vector3.Magnitude(rotateAround - this.transform.position); this.transform.position = rotateAround - originalDistance * nextRay.direction; nextEulerAngles.x += this.TouchRotationX ? deltaAngleX : 0; nextEulerAngles.y += this.TouchRotationY ? deltaAngleY : 0; this.transform.eulerAngles = nextEulerAngles; } } } for (int i = 0; i < touchCount; ++i) { UnityEngine.Touch touch = UnityEngine.Input.GetTouch(i); this.touchInfos[i] = new TouchInfo(ref touch, this); } this.mouseTouchInfo = new TouchInfo() { ScreenPos = UnityEngine.Input.mousePosition, HitPos = GetIntersectionPoint(UnityEngine.Input.mousePosition), Phase = mouseTouchPhase }; }
public bool SameFingerID(ref UnityEngine.Touch touch) { return((touch.fingerId + 1) == this.fingerIdOffseted); }