/// <summary> /// Occurs upon a valid <see cref="PanGesture"/> when the end (or beginning) of the sequence is reached and navigation to next/previous item may not be completed. /// </summary> /// <param name="panGesture"></param> protected override void OnPanStretch(PanGesture panGesture) { base.OnPanStretch(panGesture); double scaleFactor = 0.2; double offset = this.View.Orientation == Orientation.Horizontal ? panGesture.CumulativeTranslation.X : panGesture.CumulativeTranslation.Y; if (offset > 0) { offset = Math.Min(this.Panel.ItemLength * scaleFactor, offset); } else { offset = Math.Max(-this.Panel.ItemLength * scaleFactor, offset); } double absOffset = Math.Abs(offset); double scale = 1 - (absOffset / (this.Panel.ItemLength + (absOffset / scaleFactor))); if (this.View.Orientation == Orientation.Horizontal) { this.transform.CenterX = offset > 0 ? this.Panel.ItemLength : 0; this.transform.TranslateX = offset; this.transform.ScaleX = scale; } else { this.transform.CenterY = offset > 0 ? this.Panel.ItemLength : 0; this.transform.TranslateY = offset; this.transform.ScaleY = scale; } }
private void OnEnable() { rectTransform = GetComponent <RectTransform>(); rectTransform.pivot = new Vector2(0.5f, 0.5f); PanGesture.ThresholdUnits = 0.0f; PanGesture.AllowSimultaneousExecutionWithAllGestures(); PanGesture.StateUpdated += PanGestureUpdated; #if UNITY_EDITOR if (JoystickImage != null && JoystickImage.canvas.renderMode != RenderMode.ScreenSpaceOverlay) { Debug.LogError("Fingers joystick script requires that if JoystickImage is set, the Canvas is in ScreenSpaceOverlay mode."); } #endif if (!string.IsNullOrEmpty(CrossPlatformInputHorizontalAxisName) && !string.IsNullOrEmpty(CrossPlatformInputVerticalAxisName)) { crossPlatformInputHorizontalAxisObject = FingersCrossPlatformInputReflectionScript.RegisterVirtualAxis(CrossPlatformInputHorizontalAxisName, out crossPlatformInputNewlyRegistered); crossPlatformInputVerticalAxisObject = FingersCrossPlatformInputReflectionScript.RegisterVirtualAxis(CrossPlatformInputVerticalAxisName, out crossPlatformInputNewlyRegistered); } FingersScript.Instance.AddGesture(PanGesture); SetIdleState(); homePosition = rectTransform.position; }
protected override void onPanRunning(PanGesture gesture) { /*if (gesture.ActiveTouches.Count > 0) * if (EventSystem.current.IsPointerOverGameObject ()) * return;*/ if (gesture.ActiveTouches.Count > 0) { PointerEventData ped = new PointerEventData(EventSystem.current); ped.position = gesture.ScreenPosition; List <RaycastResult> hit = new List <RaycastResult>(); EventSystem.current.RaycastAll(ped, hit); foreach (RaycastResult rr in hit) { if (rr.gameObject.name.Equals("MessageBox")) { continue; } else { return; } } } rotatedDirty = true; focusedObject.Rotate(0, -(gesture.ScreenPosition.x - gesture.PreviousScreenPosition.x) * .5f, 0, Space.World); GameObject.Find("MessageBox").GetComponent <Text>().text = focusedObject.eulerAngles.y.ToString("0") + "\u00B0"; }
protected override void onPanRunning(PanGesture gesture) { /*if (gesture.ActiveTouches.Count > 0) * if (EventSystem.current.IsPointerOverGameObject ()) * return;*/ if (gesture.ActiveTouches.Count > 0) { PointerEventData ped = new PointerEventData(EventSystem.current); ped.position = gesture.ScreenPosition; List <RaycastResult> hit = new List <RaycastResult>(); EventSystem.current.RaycastAll(ped, hit); foreach (RaycastResult rr in hit) { if (rr.gameObject.name.Equals("MessageBox")) { continue; } else { return; } } } turnTableCamera.setDelta((gesture.ScreenPosition - gesture.PreviousScreenPosition) / 10.0f); }
// Use this for initialization protected virtual void Start() { PressGesture press = gameObject.AddComponent <PressGesture> (); press.Pressed += TouchEvent; PanGesture pan = gameObject.AddComponent <PanGesture> (); pan.Panned += TouchEvent; TapGesture tap = gameObject.AddComponent <TapGesture>(); tap.Tapped += TouchEvent; tap.NumberOfTapsRequired = 2; tap.TimeLimit = 0.5f; ScaleGesture scale = gameObject.AddComponent <ScaleGesture> (); scale.Scaled += TouchEvent; gameObject.AddComponent <PressGesture>().Pressed += TouchEvent; LongPressGesture longPress = gameObject.AddComponent <LongPressGesture>(); longPress.LongPressed += TouchEvent; longPress.TimeToPress = 0.2f; longPress.AddFriendlyGesture(pan); gameObject.AddComponent <ReleaseGesture>().Released += TouchEvent; }
public void ScrollableBaseOnAccessibilityPan() { tlog.Debug(tag, $"ScrollableBaseOnAccessibilityPan START"); var testingTarget = new ScrollableBase() { Size = new Size(100, 2), BackgroundColor = Color.Cyan, ScrollingDirection = ScrollableBase.Direction.Vertical, }; Assert.IsNotNull(testingTarget, "null handle"); Assert.IsInstanceOf <ScrollableBase>(testingTarget, "Should return ScrollableBase instance."); using (PanGesture gesture = new PanGesture()) { try { testingTarget.OnAccessibilityPan(gesture); } catch (Exception e) { tlog.Debug(tag, e.Message.ToString()); Assert.Fail("Caught Exception : Failed!"); } } testingTarget.Dispose(); tlog.Debug(tag, $"ScrollableBaseOnAccessibilityPan END (OK)"); }
public void HandlePanning(object sender, GameObject room) { PanGesture pg = (PanGesture)sender; if (aWallIsSelected) { Ray ray = Camera.main.ScreenPointToRay(new Vector3(pg.ScreenPosition.x, pg.ScreenPosition.y, 0)); float t = (hitY - ray.origin.y) / ray.direction.y; float factor = 1.0F; if (selectedWall == 1) { float z = ray.origin.z + ray.direction.z * t; z = (int)(Math.Round(z / 0.025F)) * 0.025F; float oldZ = room.gameObject.transform.Find(toS[0]).transform.position.z; room.gameObject.transform.Find(toS[0]).transform.Translate(new Vector3(0, 0, factor * (z - oldZ))); room.gameObject.transform.Find(toS[2]).transform.Translate(new Vector3(0, 0, factor * (z - oldZ))); } else if (selectedWall == 4) { float x = ray.origin.x + ray.direction.x * t; x = (int)(Math.Round(x / 0.025F)) * 0.025F; float oldX = room.gameObject.transform.Find(toS[3]).transform.position.x; room.gameObject.transform.Find(toS[1]).transform.Translate(new Vector3(0, 0, factor * (oldX - x))); room.gameObject.transform.Find(toS[3]).transform.Translate(new Vector3(0, 0, factor * (oldX - x))); } } }
IEnumerator _Initialize(AssociationPiece piece) { var rb = GetComponent <Rigidbody>(); rb.useGravity = false; rb.WakeUp(); rb.isKinematic = true; yield return(null); var tranf = GetComponent <Transformer2D>(); tranf.Speed = 25; _pg = GetComponent <PanGesture>(); if (!string.IsNullOrEmpty(piece.sprite)) { var image = GetComponent <Image>(); if (!image) { image = gameObject.AddComponent <Image>(); } image.sprite = Resources.Load <Sprite>(piece.sprite); } Id = piece.id; IsStatic = piece.isStatic; _controllerType = ControllerTypes.Association; Initialize(); }
internal static PanGesture GetPanGestureFromPtr(global::System.IntPtr cPtr) { PanGesture ret = new PanGesture(cPtr, false); if (NDalicPINVOKE.SWIGPendingException.Pending) { throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public void PanGestureGetPanGestureFromPtr() { tlog.Debug(tag, $"PanGestureGetPanGestureFromPtr START"); PanGesture a1 = new PanGesture(); PanGesture a2 = PanGesture.GetPanGestureFromPtr(PanGesture.getCPtr(a1).Handle); a1.Dispose(); tlog.Debug(tag, $"PanGestureGetPanGestureFromPtr END (OK)"); Assert.Pass("PanGestureGetPanGestureFromPtr"); }
protected override void OnStart() { base.OnStart(); _pg = GetComponent <PanGesture>(); var input = _controller as InputController; input.AddPanGesture(_pg); }
public void PanGestureDetectorSetPanGestureProperties() { tlog.Debug(tag, $"PanGestureDetectorSetPanGestureProperties START"); PanGesture pan = new PanGesture(); PanGestureDetector.SetPanGestureProperties(pan); tlog.Debug(tag, $"PanGestureDetectorSetPanGestureProperties END (OK)"); Assert.Pass("PanGestureDetectorClearAngles"); }
private void OnDetected(object obj, PanGestureDetector.DetectedEventArgs e) { View v1 = e.View; e.View = v1; PanGesture p1 = e.PanGesture; e.PanGesture = p1; }
/// <summary> /// Occurs upon a valid <see cref="PanGesture"/>. /// </summary> /// <param name="gesture"></param> protected override void OnPan(PanGesture gesture) { base.OnPan(gesture); this.PreparePan(this.OffsetLength); if (this.snapshotState == SnapshotState.Ready) { this.UpdateProjections(); } }
public void PanGestureNumberOfTouches() { tlog.Debug(tag, $"PanGestureNumberOfTouches START"); PanGesture a1 = new PanGesture(); uint b1 = a1.NumberOfTouches; a1.Dispose(); tlog.Debug(tag, $"PanGestureNumberOfTouches END (OK)"); Assert.Pass("PanGestureNumberOfTouches"); }
public void PanGesturePosition() { tlog.Debug(tag, $"PanGesturePosition START"); PanGesture a1 = new PanGesture(); Vector2 v1 = a1.Position; a1.Dispose(); tlog.Debug(tag, $"PanGesturePosition END (OK)"); Assert.Pass("PanGesturePosition"); }
/// <summary> /// Occurs upon a valid <see cref="PanGesture"/> when the end (or beginning) of the sequence is reached and navigation to next/previous item may not be completed. /// </summary> /// <param name="panGesture"></param> protected override void OnPanStretch(PanGesture panGesture) { base.OnPanStretch(panGesture); double length = this.View.Orientation == Orientation.Horizontal ? panGesture.CumulativeTranslation.X : panGesture.CumulativeTranslation.Y; this.PreparePan(length); this.rotation = Math.Min(this.rotation, 60); this.UpdateProjections(); }
public void PanGestureVelocity() { tlog.Debug(tag, $"PanGestureVelocity START"); PanGesture a1 = new PanGesture(); Vector2 v1 = a1.Velocity; a1.Dispose(); tlog.Debug(tag, $"PanGestureVelocity END (OK)"); Assert.Pass("PanGestureVelocity"); }
public void PanGestureGetScreenDistance() { tlog.Debug(tag, $"PanGestureGetScreenDistance START"); PanGesture a1 = new PanGesture(); float f1 = a1.GetScreenDistance(); a1.Dispose(); tlog.Debug(tag, $"PanGestureGetScreenDistance END (OK)"); Assert.Pass("PanGestureGetScreenDistance"); }
public void PanGestureGetSpeed() { tlog.Debug(tag, $"PanGestureGetSpeed START"); PanGesture a1 = new PanGesture(); float f1 = a1.GetSpeed(); a1.Dispose(); tlog.Debug(tag, $"PanGestureGetSpeed END (OK)"); Assert.Pass("PanGestureGetSpeed"); }
public void PanGestureDisplacement() { tlog.Debug(tag, $"PanGestureDisplacement START"); PanGesture a1 = new PanGesture(); Vector2 v1 = a1.Displacement; a1.Dispose(); tlog.Debug(tag, $"PanGestureDisplacement END (OK)"); Assert.Pass("PanGestureDisplacement"); }
protected override void OnStart() { base.OnStart(); _panGesture = GetComponent <PanGesture>(); _boxCollider = GetComponent <BoxCollider>(); inputController = _controller as InputController; inputController.AddPanGesture(_panGesture); }
/// <summary> /// Occurs upon a valid <see cref="PanGesture"/>. /// </summary> /// <param name="gesture"></param> protected override void OnPan(PanGesture gesture) { if (this.View.Orientation == Orientation.Horizontal) { this.transform.TranslateX = this.Offset.X; } else { this.transform.TranslateY = this.Offset.Y; } }
public void PanGesturegetCPtr() { tlog.Debug(tag, $"PanGesturegetCPtr START"); PanGesture a1 = new PanGesture(); global::System.Runtime.InteropServices.HandleRef ptr = PanGesture.getCPtr(a1); a1.Dispose(); tlog.Debug(tag, $"PanGesturegetCPtr END (OK)"); Assert.Pass("PanGestureCPtr"); }
private void OnDetected(object obj, PanGestureDetector.DetectedEventArgs e) { View view = e.View; e.View = view; PanGesture gesture = e.PanGesture; e.PanGesture = gesture; tlog.Debug(tag, "Handled : " + e.Handled); }
public void PanGestureConstructorWithState() { tlog.Debug(tag, $"PanGestureConstructorWithState START"); var testingTarget = new PanGesture(Gesture.StateType.Finished); Assert.IsNotNull(testingTarget, "Can't create success object Hover"); Assert.IsInstanceOf <PanGesture>(testingTarget, "Should be an instance of PanGesture type."); testingTarget.Dispose(); tlog.Debug(tag, $"PanGestureConstructorWithState END (OK)"); Assert.Pass("PanGestureConstructor"); }
public void PanGestureConstructor() { tlog.Debug(tag, $"PanGestureConstructor START"); PanGesture a1 = new PanGesture(); Gesture.StateType state = Gesture.StateType.Finished; PanGesture a2 = new PanGesture(state); a2.Dispose(); a1.Dispose(); tlog.Debug(tag, $"PanGestureConstructor END (OK)"); Assert.Pass("PanGestureConstructor"); }
protected override void OnStart() { base.OnStart(); _inputController = _controller as InputController; _inputController.AddFloatController(); _pg = GetComponent <PanGesture>(); _pg.Panned += Pan; _pg.PanCompleted += EndPan; _iniPos = transform.position; bx = GetComponent <BoxCollider>(); bx.size = new Vector3(GetComponent <RectTransform>().rect.width, GetComponent <RectTransform>().rect.height, 1); }
// Handle pan start events private void panStartedHandler(object sender, EventArgs e) { // get the gesture that was sent to us, which will tell us which object was pressed PanGesture gesture = sender as PanGesture; // get info about where the hit object was located when the gesture was recognized ITouchHit hit; if (gesture.GetTargetHitResult(out hit)) { // want the info as a 2D point ITouchHit2D hit2d = (ITouchHit2D)hit; Debug.Log("PAN STARTED on " + gesture.gameObject.name + " at " + hit2d.Point); } }
public void PanGestureGetScreenSpeed() { tlog.Debug(tag, $"PanGestureGetScreenSpeed START"); var testingTarget = new PanGesture(Gesture.StateType.Finished); Assert.IsNotNull(testingTarget, "Can't create success object Hover"); Assert.IsInstanceOf <PanGesture>(testingTarget, "Should be an instance of PanGesture type."); tlog.Debug(tag, "GetScreenSpeed : " + testingTarget.GetScreenSpeed()); testingTarget.Dispose(); tlog.Debug(tag, $"PanGestureGetScreenSpeed END (OK)"); Assert.Pass("PanGestureGetScreenSpeed"); }