/// <summary> /// 每帧执行 /// </summary> /// <param name="inputPoint">输入端世界坐标值</param> public void OnUpdate(Vector3 inputPoint) { if (!isEnable) { return; } currentPoint = inputPoint; if (lastPoint == null) { lastPoint = currentPoint; } //移动坐标 if (HandUI != null) { HandUI.MoveHand(ScreenPoint); } //获取到射线 Ray ray = MUtility.ScreenPointToRay(ScreenPoint); Ray uiRay = MUtility.UIScreenPointToRay(ScreenPoint); //发送射线信息 EventHandRay.SendListener(ray, HandIndex); EventHandUIRay.SendListener(uiRay, HandIndex); EventHandRays.SendListener(ray, uiRay, HandIndex); //算直接坐标的插值 lerpPoint = currentPoint - lastPoint.Value; //记录上一帧 lastPoint = currentPoint; }
void ontest() { gameObject.AddGrabObject(onGrab); gameObject.RemoveGrabObject(onGrab); gameObject.RemoveGrabObjectAll(); gameObject.AddReleaseObject(OnRelease); gameObject.RemoveReleaseObject(OnRelease); gameObject.RemoveReleaseObjectAll(); gameObject.AddRayTargetEnter(OnTargetEnter); gameObject.RemoveRayTargetEnter(OnTargetEnter); gameObject.RemoveRayTargetEnter(); gameObject.AddRayTargetExit(OnTargetExit); gameObject.RemoveRayTargetExit(); gameObject.RemoveRayTargetExit(OnTargetExit); EventHandRay.AddListener(onRay); EventHandRay.RemoveListener(onRay); EventHandRays.AddListener(OnRays); EventHandRays.RemoveListener(OnRays); EventHandStart.AddListener(onstart); EventHandStart.RemoveListener(onstart); EventHandStop.AddListener(onstop); EventHandStop.RemoveListener(onstop); EventHandUIRay.AddListener(onRay); EventHandUIRay.RemoveListener(onRay); EventCameraZoom.AddListener(onzoom); EventCameraZoom.RemoveListener(onzoom); EventCameraRotate.AddListener(onrotate); EventCameraRotate.RemoveListener(onrotate); EventHandGrabObject.AddListener(ongrabobject); EventHandGrabObject.RemoveListener(ongrabobject); EventHandReleaseObject.AddListener(onreleaseobject); EventHandReleaseObject.RemoveListener(onreleaseobject); EventHandGrabObjectKey.AddListener(gameObject, onGrab); EventHandGrabObjectKey.RemoveListener(gameObject, onGrab); EventHandReleaseObjectKey.AddListener(gameObject, OnRelease); EventHandReleaseObjectKey.RemoveListener(gameObject, OnRelease); EventHandRayTarget.AddListener(onraytarget); EventHandRayTarget.RemoveListener(onraytarget); EventHandRayTargetEnter.AddListener(gameObject, OnTargetEnter); EventHandRayTargetEnter.RemoveListener(gameObject, OnTargetEnter); EventHandRayTargetExit.AddListener(gameObject, OnTargetExit); EventHandRayTargetExit.RemoveListener(gameObject, OnTargetExit); EventHandUIRayEnter.AddListener(gameObject, onuienter); EventHandUIRayEnter.RemoveListener(gameObject, onuienter); EventHandUIRayExit.AddListener(gameObject, onuiexit); EventHandUIRayExit.RemoveListener(gameObject, onuiexit); EventHandUIRay.AddListener(onRay); EventHandUIRay.RemoveListener(onRay); }