public static void PushIn(GameObject obj, float duration, TransitionDirection direction, Action completion = null) { var sign = direction == TransitionDirection.Backward ? 1 : -1; var screenLocation = Camera.main.WorldToScreenPoint(obj.transform.position); var x = Screen.width / 2 + (sign * Screen.width); Debug.Log("X = " + x); var sourceScreen = new Vector3(x, screenLocation.y * 0.8f, screenLocation.z * 0.8f); var sourceWorld = Camera.main.ScreenToWorldPoint(sourceScreen); var destinationWorld = obj.transform.position; obj.transform.position = sourceWorld; var moveAnimation = ABAnimation.MoveTo(destinationWorld, duration); moveAnimation.Timing = ABAnimationTiming.EaseOut; var destinationAngles = obj.transform.eulerAngles; var rotateAnimation = ABAnimation.RotateTo(destinationAngles, duration); rotateAnimation.Timing = ABAnimationTiming.EaseInEaseOut; obj.transform.eulerAngles = new Vector3(destinationAngles.x, destinationAngles.y + (sign * 90), destinationAngles.z); var list = new List <ABAnimation> (2); list.Add(moveAnimation); list.Add(rotateAnimation); var group = ABAnimation.Group(list); ABAnimationSystem.RunAnimation(group, obj, completion); }
public static void PushOut(GameObject obj, float duration, TransitionDirection direction, Action completion = null) { var sign = direction == TransitionDirection.Backward ? -1 : 1; var screenLocation = Camera.main.WorldToScreenPoint(obj.transform.position); var x = Screen.width / 2 + (sign * Screen.width * 1.25f); // Debug.Log ("X = " + x); var destinationScreen = new Vector3(x, screenLocation.y * 0.8f, screenLocation.z * 0.8f); var destinationWorld = Camera.main.ScreenToWorldPoint(destinationScreen); var moveAnimation = ABAnimation.MoveTo(destinationWorld, duration); moveAnimation.Timing = ABAnimationTiming.EaseIn; var deltaAngle = sign * 90; var rotateAnimation = ABAnimation.RotateBy(new Vector3(0, deltaAngle, 0), duration); rotateAnimation.Timing = ABAnimationTiming.EaseInEaseOut; var list = new List <ABAnimation> (2); list.Add(moveAnimation); list.Add(rotateAnimation); var group = ABAnimation.Group(list); ABAnimationSystem.RunAnimation(group, obj, completion); }