void Start() { // 設定ファイルより入力タイプを取得 if (!ApplicationSetting.Instance.GetBool("UseMouse")) { winTouch = true; } inputLock = false; // カメラコンポーネントの取得 flyThroughCamera = this.gameObject.GetComponent <FlyThroughCamera>(); pinchZoomCamera = this.gameObject.GetComponent <PinchZoomCamera>(); orbitCamera = this.gameObject.GetComponent <OrbitCamera>(); // 初期値を保存 defaultPos = this.gameObject.transform.position; ResetInput(); }
IEnumerator Start() { // 設定ファイルより入力タイプを取得 if (!ApplicationSetting.Instance.GetBool("UseMouse")) { winTouch = true; } Vector3 temp_pos = this.gameObject.transform.position; Quaternion temp_rot = this.gameObject.transform.rotation; Vector3 temp_scale = this.gameObject.transform.localScale; yield return(new WaitForEndOfFrame()); // カメラコンポーネントの取得 flyThroughCamera = this.gameObject.GetComponent <FlyThroughCamera>(); orbitCamera = this.gameObject.GetComponent <OrbitCamera>(); // ズーム位置のルートを設定する pinchZoomRoot = new GameObject(this.gameObject.name + " PinchZoom Root"); pinchZoomRoot.transform.SetParent(this.gameObject.transform.parent, true); pinchZoomRoot.transform.position = temp_pos; pinchZoomRoot.transform.rotation = temp_rot; pinchZoomRoot.transform.localScale = temp_scale; this.gameObject.transform.SetParent(pinchZoomRoot.transform, true); this.gameObject.transform.localPosition = Vector3.zero; this.gameObject.transform.localRotation = Quaternion.identity; this.gameObject.transform.localScale = Vector3.one; // 初期値を保存 switch (zoomType) { case PINCH_ZOOM_TYPE.POSITION_Z: defaultZoom = this.gameObject.transform.localPosition.z; break; case PINCH_ZOOM_TYPE.FOV: defaultZoom = this.gameObject.GetComponent <Camera>().fieldOfView; break; case PINCH_ZOOM_TYPE.ORTHOSIZE: defaultZoom = this.gameObject.GetComponent <Camera>().orthographicSize; break; default: break; } // ピンチセンターへのズーム設定 if (zoomToPinchCenterFor2D) { if (zoomType != PINCH_ZOOM_TYPE.POSITION_Z) { Debug.LogWarning("PinchZoomCamera :: [zoomToPinchCenter] only works for [PINCH_ZOOM_TYPE.POSITION_Z]"); } Camera[] cameras = this.gameObject.GetComponent <Camera>().GetComponentsInChildren <Camera>(); foreach (Camera cam in cameras) { CameraShifter cameraShifter = cam.gameObject.GetComponent <CameraShifter>(); if (cameraShifter == null) { cameraShifter = cam.gameObject.AddComponent <CameraShifter>(); } cameraShifter.calcAlways = true; cameraShifterListForZtoPC.Add(cameraShifter); } } ResetInput(); }