/// <summary> /// Change orientation of bubble surface or tube /// </summary> /// <param name="e">Event arguments</param> private void ChangeLevelOrientation(DeviceOrientationChangedEventArgs e) { _bubbleSpeed = new Simple3DVector(); if (DeviceOrientationHelper.IsFlat(e.CurrentOrientation)) { SurfaceShown = true; DeviceOrientationInfo priorDoi = DeviceOrientationHelper.GetDeviceOrientationInfo(e.PreviousOrientation); _bubblePosition = new Simple3DVector(priorDoi.NormalGravityVector.X, priorDoi.NormalGravityVector.Y, 0); } else { DeviceOrientationInfo doi = DeviceOrientationHelper.GetDeviceOrientationInfo(e.CurrentOrientation); if (DeviceOrientationHelper.IsFlat(e.PreviousOrientation) || (e.PreviousOrientation == DeviceOrientation.Unknown)) { MoveLevel.Angle = doi.AngleOnXYPlan; _bubblePosition = new Simple3DVector(); SurfaceShown = false; } double accumulatedLoops = MoveLevel.Angle / 360; accumulatedLoops = Math.Floor(accumulatedLoops + 0.5); _tubeRotationAnimation.To = 360 * accumulatedLoops + doi.AngleOnXYPlan; if ((_tubeRotationAnimation.To - MoveLevel.Angle) > 180) { _tubeRotationAnimation.To -= 360; } if ((_tubeRotationAnimation.To - MoveLevel.Angle) < -180) { _tubeRotationAnimation.To += 360; } _tubeRotationStoryboard.Begin(); _bubbleDirection = doi.HorizontalAxisPolarity; } _levelOrientation = e.CurrentOrientation; }
void Awake() { _instance = this; //text = GetComponent<Text>(); //text.enabled = false; //DontDestroyOnLoad(gameObject); #if UNITY_EDITOR if (Screen.width > Screen.height) { _isLandscape = true; } else { _isLandscape = false; } #else if (Screen.orientation == ScreenOrientation.LandscapeLeft || Screen.orientation == ScreenOrientation.LandscapeRight) { _isLandscape = true; } else { _isLandscape = false; } #endif orientationChanged.AddListener(OrientationChangedCallBack); }
protected override async Task <bool> ExecuteImpl(DeviceOrientation value) { var result = await DeviceOrientationInfo.Set(value); return(result == value); }