public void EnableGridMode(Vector3 position) { if (state == State.Grid) { return; } if (state != State.Zoomed) { var lookDirection = Camera.main.transform.position - transform.parent.position; currentRotationToCamera = Quaternion.LookRotation(lookDirection, Vector3.up).eulerAngles.y % 360; gridKeyFrame.LocalRotation = new Vector3(0, currentRotationToCamera, 0); gridKeyFrame.LocalScale = TransformsHelper.WorldToLocalScale(transform, gridWorldScale); gridKeyFrame.LocalPosition = position; } else { gridKeyFrame.LocalRotation = new Vector3(0, currentRotationToCamera, 0); } presenterGridKeyFrame.LocalPosition = Vector3.zero; presenterGridKeyFrame.LocalRotation = Constants.PlaneRotationCorrection; animationExecutor.StartAnimation(gridKeyFrame, Constants.TransitionDuration); presenterAnimationExecutor.StartAnimation(presenterGridKeyFrame, Constants.TransitionDuration, animateRotation: false, animateScale: false); state = State.Grid; }
private void UpdateGrid() { var yOffset = GetGameObjectHeight(Souvenir.gameObject); var numberOfDisplayedSlots = Math.Min(carouselSlots.Count, photoCoordinates.Count); for (int i = 0; i < numberOfDisplayedSlots; ++i) { var carouselSlot = carouselSlots[i]; // We transform the world position of the grid slot to local coordinates, then we remove the height of the souvenir // to remove the offset. The height must be transformed to local coordinates too, because of the scaling factor. var position = transform.InverseTransformPoint(photoCoordinates[i].transform.position) - TransformsHelper.WorldToLocalScale(carouselSlot.transform, new Vector3(0, yOffset, 0)); carouselSlot.EnableGridMode(position); } }