public void Awake() { if (Instance == null) { Instance = this; } lastFingerDownTimeReal = 0; lastClickTimeReal = 0; lastFinger0DownPos = Vector3.zero; dragStartPos = Vector3.zero; isDragging = false; wasFingerDownLastFrame = false; DragFinalMomentumVector = new List <Vector3>(); pinchStartPositions = new List <Vector3>() { Vector3.zero, Vector3.zero }; touchPositionLastFrame = new List <Vector3>() { Vector3.zero, Vector3.zero }; pinchStartDistance = 1; isPinching = false; isClickPrevented = false; }
public void Awake() { if (touchInputController == null) { touchInputController = FindObjectOfType <TouchInputController>(); if (touchInputController == null) { Debug.LogError("Failed to find TouchInputController. Make sure the reference is assigned via inspector or by ensuring the Find method works."); this.enabled = false; } } }
public void Awake() { mobileTouchCam = FindObjectOfType <MobileTouchCamera>(); if (mobileTouchCam == null) { Debug.LogError("No MobileTouchCamera found in scene. This script will not work without this."); } touchInputController = mobileTouchCam.GetComponent <TouchInputController>(); if (touchInputController == null) { Debug.LogError("No TouchInputController found in scene. Make sure this component exists and is attached to the MobileTouchCamera gameObject."); } }
// BorderScript borderScript; public void Awake() { cam = MobileTouchCamera.Instance.main; mobileTouchCamera = cam.GetComponent <MobileTouchCamera> (); touchInputController = cam.GetComponent <TouchInputController> (); mobilePickingController = cam.GetComponent <MobilePickingController> (); #region detail callbacks touchInputController.OnInputClick += OnInputClick; touchInputController.OnDragStart += OnDragStart; touchInputController.OnDragStop += OnDragStop; touchInputController.OnDragUpdate += OnDragUpdate; touchInputController.OnFingerDown += OnFingerDown; touchInputController.OnPinchStart += OnPinchStart; touchInputController.OnPinchStop += OnPinchStop; touchInputController.OnPinchUpdateExtended += new TouchInputController.PinchUpdateExtendedDelegate(OnPinchUpdate); #endregion }
public void Awake() { cam = FindObjectOfType <Camera>(); mobileTouchCamera = cam.GetComponent <MobileTouchCamera>(); touchInputController = cam.GetComponent <TouchInputController>(); mobilePickingController = cam.GetComponent <MobilePickingController>(); #region detail callbacks touchInputController.OnInputClick += new TouchInputController.InputClickDelegate(OnInputClick); touchInputController.OnDragStart += new TouchInputController.Input1PositionDelegate(OnDragStart); touchInputController.OnDragStop += new TouchInputController.DragStopDelegate(OnDragStop); touchInputController.OnDragUpdate += new TouchInputController.DragUpdateDelegate(OnDragUpdate); touchInputController.OnFingerDown += new TouchInputController.Input1PositionDelegate(OnFingerDown); touchInputController.OnPinchStart += new TouchInputController.PinchStartDelegate(OnPinchStart); touchInputController.OnPinchStop += new System.Action(OnPinchStop); touchInputController.OnPinchUpdate += new TouchInputController.PinchUpdateDelegate(OnPinchUpdate); #endregion ShowInfoText("Mobile Touch Camera Demo\nSwipe: Scroll\nPinch: Zoom\nTap: Pick Item", 5); }
public void Awake() { Application.targetFrameRate = 60; cam = FindObjectOfType <Camera>(); mobileTouchCamera = cam.GetComponent <MobileTouchCamera>(); touchInputController = cam.GetComponent <TouchInputController>(); mobilePickingController = cam.GetComponent <MobilePickingController>(); #region detail callbacks touchInputController.OnInputClick += OnInputClick; touchInputController.OnDragStart += OnDragStart; touchInputController.OnDragStop += OnDragStop; touchInputController.OnDragUpdate += OnDragUpdate; touchInputController.OnFingerDown += OnFingerDown; touchInputController.OnPinchStart += OnPinchStart; touchInputController.OnPinchStop += OnPinchStop; touchInputController.OnPinchUpdateExtended += new TouchInputController.PinchUpdateExtendedDelegate(OnPinchUpdate); #endregion ShowInfoText("Mobile Touch Camera Demo\nSwipe: Scroll\nPinch: Zoom\nTap: Pick Item", introTextOnScreenTime); }
public void Awake() { Cam = GetComponent <Camera>(); IsSmoothingEnabled = true; touchInputController = GetComponent <TouchInputController>(); dragStartCamPos = Vector3.zero; cameraScrollVelocity = Vector3.zero; timeRealDragStop = 0; pinchStartCamZoomSize = 0; IsPinching = false; IsDragging = false; DragCameraMoveVector = new List <Vector3>(); refPlaneXY = new Plane(new Vector3(0, 0, -1), groundLevelOffset); refPlaneXZ = new Plane(new Vector3(0, 1, 0), -groundLevelOffset); ScreenRatio = GetScreenRatio(); ComputeCamBoundaries(); if (CamZoomMax < CamZoomMin) { Debug.LogWarning("The defined max camera zoom (" + CamZoomMax + ") is smaller than the defined min (" + CamZoomMin + "). Automatically switching the values."); float camZoomMinBackup = CamZoomMin; CamZoomMin = CamZoomMax; CamZoomMax = camZoomMinBackup; } //Errors for certain incorrect settings. if (transform.forward == Vector3.down && cameraAxes != CameraPlaneAxes.XZ_TOP_DOWN) { Debug.LogError("Camera is pointing down but the cameraAxes is not set to TOP_DOWN. Make sure to set the cameraAxes variable properly."); } if (transform.forward == Vector3.forward && cameraAxes != CameraPlaneAxes.XY_2D_SIDESCROLL) { Debug.LogError("Camera is pointing sidewards but the cameraAxes is not set to 2D_SIDESCROLL. Make sure to set the cameraAxes variable properly."); } }
/////////////////////////////////////////////////////////////////////////// // Methods /////////////////////////////////////////////////////////////////////////// public void Reset() { touchInputController = FindObjectOfType <TouchInputController>(); }