/// <summary> /// 注册输入 /// </summary> protected virtual void RegisterInput() { if (this.InputRegistered) { return; } #if !UNITY_EDITOR && UNITY_ANDROID CupMotionManager.start(); CupMotionManager.addShakeListener(this._CupShake); //摇晃 CupMotionManager.addPoseChangeListener(this._CupPoseChanged); //姿势 CupMotionManager.addTiltStatusChangeEventListener(this._CupTiltStatusChanged); //倾斜 CupKeyEventHookStaticManager.addPowerKeyPressCallBack(this._PowerClick); if (!this.Registered) { CupKeyEventHookStaticManager.addPowerKeyLongPressCallBack(this._PowerHold); } TouchLeftStaticManager.start(); TouchLeftStaticManager.addTapListener(this._CupTapLeft); TouchLeftStaticManager.addDoubleTapListener(this._CupDoubleTapLeft); TouchLeftStaticManager.addSwipeUpwardListener(this._CupLeftSwipeUp); TouchLeftStaticManager.addSwipeDownwardListener(this._CupLeftSwipeDown); TouchLeftStaticManager.addSwipeUpAndDownListener(this._CupLeftSwipeUpDown); TouchRightStaticManager.start(); TouchRightStaticManager.addTapListener(this._CupTapRight); TouchRightStaticManager.addDoubleTapListener(this._CupDoubleTapRight); TouchRightStaticManager.addSwipeUpwardListener(this._CupRightSwipeUp); TouchRightStaticManager.addSwipeDownwardListener(this._CupRightSwipeDown); TouchRightStaticManager.addSwipeUpAndDownListener(this._CupRightSwipeUpDown); #else dispatcher.UpdateListener(true, MainKeys.PowerClick, this._PowerClick); if (!this.Registered) { dispatcher.UpdateListener(true, MainKeys.PowerHold, this._PowerHold); } dispatcher.UpdateListener(true, MainKeys.CupShake, this._CupShake); dispatcher.UpdateListener(true, MainKeys.CupTiltLeft, this._CupTiltLeft); dispatcher.UpdateListener(true, MainKeys.CupTiltRight, this._CupTiltRight); dispatcher.UpdateListener(true, MainKeys.CupKeepFlat, this._CupKeepFlat); dispatcher.UpdateListener(true, MainKeys.CupTapLeft, this._CupTapLeft); dispatcher.UpdateListener(true, MainKeys.CupTapRight, this._CupTapRight); dispatcher.UpdateListener(true, MainKeys.CupDoubleTapLeft, this._CupDoubleTapLeft); dispatcher.UpdateListener(true, MainKeys.CupDoubleTapRight, this._CupDoubleTapRight); dispatcher.UpdateListener(true, MainKeys.CupLeftSwipeUp, this._CupLeftSwipeUp); dispatcher.UpdateListener(true, MainKeys.CupLeftSwipeDown, this._CupLeftSwipeDown); dispatcher.UpdateListener(true, MainKeys.CupLeftSwipeUpDown, this._CupLeftSwipeUpDown); dispatcher.UpdateListener(true, MainKeys.CupRightSwipeUp, this._CupRightSwipeUp); dispatcher.UpdateListener(true, MainKeys.CupRightSwipeDown, this._CupRightSwipeDown); dispatcher.UpdateListener(true, MainKeys.CupRightSwipeUpDown, this._CupRightSwipeUpDown); #endif this.InputRegistered = true; }
/// <summary> /// 取消注册输入 /// </summary> protected virtual void UnregisterInput() { #if !UNITY_EDITOR && UNITY_ANDROID CupMotionManager.removeShakeListener(this._CupShake); //摇晃 CupMotionManager.removePoseChangeListener(this._CupPoseChanged); //姿势 CupMotionManager.removeTiltStatusChangeEventListener(this._CupTiltStatusChanged); //倾斜 CupKeyEventHookStaticManager.removePowerKeyPressCallBack(this._PowerClick); if (this.View != TopViewHelper.ETopView.eMainView) { CupKeyEventHookStaticManager.removePowerKeyLongPressCallBack(this._PowerHold); } TouchLeftStaticManager.removeTapListener(this._CupTapLeft); TouchLeftStaticManager.removeDoubleTapListener(this._CupDoubleTapLeft); TouchLeftStaticManager.removeSwipeUpwardListener(this._CupLeftSwipeUp); TouchLeftStaticManager.removeSwipeDownwardListener(this._CupLeftSwipeDown); TouchLeftStaticManager.removeSwipeUpAndDownListener(this._CupLeftSwipeUpDown); TouchRightStaticManager.removeTapListener(this._CupTapRight); TouchRightStaticManager.removeDoubleTapListener(this._CupDoubleTapRight); TouchRightStaticManager.removeSwipeUpwardListener(this._CupRightSwipeUp); TouchRightStaticManager.removeSwipeDownwardListener(this._CupRightSwipeDown); TouchRightStaticManager.removeSwipeUpAndDownListener(this._CupRightSwipeUpDown); #else dispatcher.UpdateListener(false, MainKeys.PowerClick, this._PowerClick); if (this.View != TopViewHelper.ETopView.eMainView) { dispatcher.UpdateListener(false, MainKeys.PowerHold, this._PowerHold); } dispatcher.UpdateListener(false, MainKeys.CupShake, this._CupShake); dispatcher.UpdateListener(false, MainKeys.CupTiltLeft, this._CupTiltLeft); dispatcher.UpdateListener(false, MainKeys.CupTiltRight, this._CupTiltRight); dispatcher.UpdateListener(false, MainKeys.CupKeepFlat, this._CupKeepFlat); dispatcher.UpdateListener(false, MainKeys.CupTapLeft, this._CupTapLeft); dispatcher.UpdateListener(false, MainKeys.CupTapRight, this._CupTapRight); dispatcher.UpdateListener(false, MainKeys.CupDoubleTapLeft, this._CupDoubleTapLeft); dispatcher.UpdateListener(false, MainKeys.CupDoubleTapRight, this._CupDoubleTapRight); dispatcher.UpdateListener(false, MainKeys.CupLeftSwipeUp, this._CupLeftSwipeUp); dispatcher.UpdateListener(false, MainKeys.CupLeftSwipeDown, this._CupLeftSwipeDown); dispatcher.UpdateListener(false, MainKeys.CupLeftSwipeUpDown, this._CupLeftSwipeUpDown); dispatcher.UpdateListener(false, MainKeys.CupRightSwipeUp, this._CupRightSwipeUp); dispatcher.UpdateListener(false, MainKeys.CupRightSwipeDown, this._CupRightSwipeDown); dispatcher.UpdateListener(false, MainKeys.CupRightSwipeUpDown, this._CupRightSwipeUpDown); #endif this.InputRegistered = false; }