diff --git a/03_RoyalGallery/Unity-19050-03_RoyalGallery_iPad/19050-03_RoyalGallery_iPad/Assets/RoyalGallery/Script/ZoomInOut.cs b/03_RoyalGallery/Unity-19050-03_RoyalGallery_iPad/19050-03_RoyalGallery_iPad/Assets/RoyalGallery/Script/ZoomInOut.cs new file mode 100644 index 0000000..f7864e1 --- /dev/null +++ b/03_RoyalGallery/Unity-19050-03_RoyalGallery_iPad/19050-03_RoyalGallery_iPad/Assets/RoyalGallery/Script/ZoomInOut.cs @@ -0,0 +1,52 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace UltraCombos.Frozen.RoyalGallery +{ + public class ZoomInOut : MonoBehaviour + { + [SerializeField] + public global::PaintCraft.Controllers.ScreenCameraController Controller; + + public bool multiTouch = true; + public float orthoZoomSpeed = 0.5f; + + // Start is called before the first frame update + void Start() + { + + } + + // Update is called once per frame + void Update() + { + if (Input.touchCount == 2 && multiTouch) + { + Touch touchZero = Input.GetTouch(0); + Touch touchOne = Input.GetTouch(1); + + Vector2 touchZeroPrevPos = touchZero.position - touchZero.deltaPosition; + Vector2 touchOnePrevPos = touchOne.position - touchOne.deltaPosition; + + Vector3 prev_cc = GetWorldPosition((touchZeroPrevPos + touchOnePrevPos) * 0.5f); + Vector3 curr_cc = GetWorldPosition((touchZero.position + touchOne.position) * 0.5f); + Controller.transform.position += prev_cc - curr_cc; + + float prevTouchDeltaMag = (touchZeroPrevPos - touchOnePrevPos).magnitude; + float touchDeltaMag = (touchZero.position - touchOne.position).magnitude; + float deltaMagnitudeDiff = prevTouchDeltaMag - touchDeltaMag; + + Controller.CameraSize.SetCameraNewOrthoSize(Mathf.Max(Controller.Camera.orthographicSize + deltaMagnitudeDiff * orthoZoomSpeed, 0.1f)); + Controller.CameraSize.CheckBounds(); + } + } + + private Vector3 GetWorldPosition(Vector2 screenPosition) + { + Vector3 vector3ScreenPosition = screenPosition; + vector3ScreenPosition.z = transform.position.z; + return Controller.Camera.ScreenToWorldPoint(vector3ScreenPosition); + } + } +} diff --git a/03_RoyalGallery/Unity-19050-03_RoyalGallery_iPad/19050-03_RoyalGallery_iPad/Assets/RoyalGallery/Script/ZoomInOut.cs.meta b/03_RoyalGallery/Unity-19050-03_RoyalGallery_iPad/19050-03_RoyalGallery_iPad/Assets/RoyalGallery/Script/ZoomInOut.cs.meta new file mode 100644 index 0000000..cf8170f --- /dev/null +++ b/03_RoyalGallery/Unity-19050-03_RoyalGallery_iPad/19050-03_RoyalGallery_iPad/Assets/RoyalGallery/Script/ZoomInOut.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 86af4bb2383319a4980ed0078372de50 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/03_RoyalGallery/Unity-19050-03_RoyalGallery_iPad/19050-03_RoyalGallery_iPad/ProjectSettings/XRSettings.asset b/03_RoyalGallery/Unity-19050-03_RoyalGallery_iPad/19050-03_RoyalGallery_iPad/ProjectSettings/XRSettings.asset new file mode 100644 index 0000000..482590c --- /dev/null +++ b/03_RoyalGallery/Unity-19050-03_RoyalGallery_iPad/19050-03_RoyalGallery_iPad/ProjectSettings/XRSettings.asset @@ -0,0 +1,10 @@ +{ + "m_SettingKeys": [ + "VR Device Disabled", + "VR Device User Alert" + ], + "m_SettingValues": [ + "False", + "False" + ] +} \ No newline at end of file