public override void TouchEnded(Touch touch) { if (currentTouch != touch) { return; } currentTouch = null; currentVector = Vector2.zero; var touchPosition = TouchManager.ScreenToWorldPoint(touch.position); var delta = beganPosition - touchPosition; if (delta.magnitude < sensitivity) { fireButtonTarget = true; nextButtonTarget = tapTarget; lastButtonTarget = ButtonTarget.None; return; } fireButtonTarget = false; nextButtonTarget = ButtonTarget.None; lastButtonTarget = ButtonTarget.None; }
public override void TouchMoved(Touch touch) { if (currentTouch != touch) { return; } var movedPosition = TouchManager.ScreenToWorldPoint(touch.position); var delta = movedPosition - lastPosition; if (delta.magnitude >= sensitivity) { lastPosition = movedPosition; currentVector = delta.normalized; if (fireButtonTarget) { var thisButtonTarget = GetButtonTargetForVector(currentVector); if (thisButtonTarget != lastButtonTarget) { nextButtonTarget = thisButtonTarget; } } } }
public override void TouchBegan(Touch touch) { if (!IsActive) { beganPosition = TouchManager.ScreenToWorldPoint(touch.position); bool flag = worldActiveArea.Contains(beganPosition); bool flag2 = ring.Contains(beganPosition); if (snapToInitialTouch && (flag || flag2)) { RingPosition = beganPosition; KnobPosition = beganPosition; currentTouch = touch; } else if (flag2) { KnobPosition = beganPosition; beganPosition = RingPosition; currentTouch = touch; } if (IsActive) { TouchMoved(touch); ring.State = true; knob.State = true; } } }
public override void TouchMoved(Touch touch) { if (currentTouch != touch) { return; } Vector3 a = TouchManager.ScreenToWorldPoint(touch.position); Vector3 vector = a - lastPosition; if (!(vector.magnitude >= sensitivity)) { return; } lastPosition = a; if (!oneSwipePerTouch || !currentVectorIsSet) { currentVector = vector.normalized; currentVectorIsSet = true; } if (fireButtonTarget) { ButtonTarget buttonTargetForVector = GetButtonTargetForVector(currentVector); if (buttonTargetForVector != lastButtonTarget) { nextButtonTarget = buttonTargetForVector; } } }
public override void TouchBegan(Touch touch) { if (IsActive) { return; } beganPosition = TouchManager.ScreenToWorldPoint(touch.position); var insideActiveArea = worldActiveArea.Contains(beganPosition); var insideControl = ring.Contains(beganPosition); if (snapToInitialTouch && (insideActiveArea || insideControl)) { RingPosition = beganPosition; KnobPosition = beganPosition; currentTouch = touch; } else if (insideControl) { KnobPosition = beganPosition; beganPosition = RingPosition; currentTouch = touch; } if (IsActive) { TouchMoved(touch); ring.State = true; knob.State = true; } }
public override void TouchMoved(Touch touch) { if (currentTouch == touch) { thisPosition = TouchManager.ScreenToViewPoint(touch.position * 100f); } }
public override void TouchMoved(Touch touch) { if (currentTouch != touch) { return; } movedPosition = TouchManager.ScreenToWorldPoint(touch.position); var vector = movedPosition - beganPosition; var normal = vector.normalized; var length = vector.magnitude; if (allowDragging) { var excess = length - worldKnobRange; if (excess < 0.0f) { excess = 0.0f; } beganPosition = beganPosition + (excess * normal); RingPosition = beganPosition; } movedPosition = beganPosition + (Mathf.Clamp(length, 0.0f, worldKnobRange) * normal); value = (movedPosition - beganPosition) / worldKnobRange; value.x = inputCurve.Evaluate(Utility.Abs(value.x)) * Mathf.Sign(value.x); value.y = inputCurve.Evaluate(Utility.Abs(value.y)) * Mathf.Sign(value.y); KnobPosition = movedPosition; RingPosition = beganPosition; }
void OnEnable() { touchManager = target as TouchManager; var path = AssetDatabase.GetAssetPath(MonoScript.FromScriptableObject(this)); headerTexture = Resources.LoadAssetAtPath <Texture>(Path.GetDirectoryName(path) + "/Images/TouchManagerHeader.png"); }
public override void TouchMoved(Touch touch) { if (currentTouch != touch) { return; } movedPosition = TouchManager.ScreenToWorldPoint(touch.position); var vector = movedPosition - beganPosition; var normal = vector.normalized; var length = vector.magnitude; if (allowDragging) { var excess = length - worldKnobRange; if (excess < 0.0f) { excess = 0.0f; } beganPosition = beganPosition + (excess * normal); RingPosition = beganPosition; } movedPosition = beganPosition + (Mathf.Clamp(length, 0.0f, worldKnobRange) * normal); value = (movedPosition - beganPosition) / worldKnobRange; value.x = inputCurve.Evaluate(Utility.Abs(value.x)) * Mathf.Sign(value.x); value.y = inputCurve.Evaluate(Utility.Abs(value.y)) * Mathf.Sign(value.y); if (snapAngles == SnapAngles.None) { snappedValue = value; if (lockToAxis == LockAxis.Horizontal) { snappedValue.y = 0.0f; KnobPosition = beganPosition + (snappedValue * worldKnobRange); } else if (lockToAxis == LockAxis.Vertical) { snappedValue.x = 0.0f; KnobPosition = beganPosition + (snappedValue * worldKnobRange); } else { KnobPosition = movedPosition; } } else { snappedValue = SnapTo(value, snapAngles); KnobPosition = beganPosition + (snappedValue * worldKnobRange); } RingPosition = beganPosition; }
public override void TouchMoved(Touch touch) { if (currentTouch != touch) { return; } thisPosition = TouchManager.ScreenToWorldPoint(touch.position); }
public override void TouchMoved(Touch touch) { if (currentTouch != touch) { return; } movedPosition = TouchManager.ScreenToWorldPoint(touch.position); if (lockToAxis == LockAxis.Horizontal && allowDraggingAxis == DragAxis.Horizontal) { movedPosition.y = beganPosition.y; } else if (lockToAxis == LockAxis.Vertical && allowDraggingAxis == DragAxis.Vertical) { movedPosition.x = beganPosition.x; } Vector3 vector = movedPosition - beganPosition; Vector3 normalized = vector.normalized; float magnitude = vector.magnitude; if (allowDragging) { float num = magnitude - worldKnobRange; if (num < 0f) { num = 0f; } Vector3 vector2 = num * normalized; if (allowDraggingAxis == DragAxis.Horizontal) { vector2.y = 0f; } else if (allowDraggingAxis == DragAxis.Vertical) { vector2.x = 0f; } beganPosition += vector2; RingPosition = beganPosition; } movedPosition = beganPosition + Mathf.Clamp(magnitude, 0f, worldKnobRange) * normalized; if (lockToAxis == LockAxis.Horizontal) { movedPosition.y = beganPosition.y; } else if (lockToAxis == LockAxis.Vertical) { movedPosition.x = beganPosition.x; } if (snapAngles != 0) { movedPosition = TouchControl.SnapTo(movedPosition - beganPosition, snapAngles) + beganPosition; } RingPosition = beganPosition; KnobPosition = movedPosition; value = (movedPosition - beganPosition) / worldKnobRange; value.x = inputCurve.Evaluate(Utility.Abs(value.x)) * Mathf.Sign(value.x); value.y = inputCurve.Evaluate(Utility.Abs(value.y)) * Mathf.Sign(value.y); }
public override void ConfigureControl() { resetPosition = OffsetToWorldPosition(anchor, offset, offsetUnitType, lockAspectRatio: true); base.transform.position = resetPosition; ring.Update(forceUpdate: true); knob.Update(forceUpdate: true); worldActiveArea = TouchManager.ConvertToWorld(activeArea, areaUnitType); worldKnobRange = TouchManager.ConvertToWorld(knobRange, knob.SizeUnitType); }
public override void ConfigureControl() { var worldOffset = (Vector3)offset * TouchManager.UnitToWorld; transform.position = TouchManager.ViewToWorldPoint(TouchUtility.AnchorToViewPoint(anchor)) + worldOffset; ScaleSprite(buttonGameObject, buttonRenderer, buttonSize); worldButtonSize = buttonSize * TouchManager.HalfUnitToWorld; }
public override void TouchBegan(Touch touch) { if (currentTouch != null) { return; } if (Contains(TouchManager.ScreenToWorldPoint(touch.position))) { state = true; currentTouch = touch; } }
public override void SubmitControlState(ulong updateTick, float deltaTime) { if (currentTouch == null && allowSlideToggle) { ButtonState = false; var touchCount = TouchManager.TouchCount; for (var i = 0; i < touchCount; i++) { ButtonState = ButtonState || button.Contains(TouchManager.GetTouch(i)); } } SubmitButtonState(target, ButtonState, updateTick, deltaTime); }
static void UpdateScreenSize() { knownScreenSize = ScreenSize; ViewSize = TouchManager.ViewToWorldPoint(Vector2.one) * 2.0f; UnitToWorld = Mathf.Min(ViewSize.x, ViewSize.y); HalfUnitToWorld = UnitToWorld * 0.5f; var touchControlCount = touchControls.Count; for (int i = 0; i < touchControlCount; i++) { touchControls[i].ConfigureControl(); } }
protected Vector3 OffsetToWorldPosition(TouchControlAnchor anchor, Vector2 offset, TouchUnitType offsetUnitType) { Vector3 worldOffset; if (offsetUnitType == TouchUnitType.Pixels) { worldOffset = TouchUtility.RoundVector(offset) * TouchManager.PixelToWorld; } else { worldOffset = (Vector3)offset * TouchManager.PercentToWorld; } return(TouchManager.ViewToWorldPoint(TouchUtility.AnchorToViewPoint(anchor)) + worldOffset); }
public override void TouchBegan(Touch touch) { if (currentTouch == null) { beganPosition = TouchManager.ScreenToWorldPoint(touch.position); if (worldActiveArea.Contains(beganPosition)) { thisPosition = TouchManager.ScreenToViewPoint(touch.position * 100f); lastPosition = thisPosition; currentTouch = touch; beganTime = Time.realtimeSinceStartup; } } }
public override void SubmitControlState(ulong updateTick) { if (currentTouch == null && allowSlideToggle) { state = false; var touchCount = TouchManager.TouchCount; for (int i = 0; i < touchCount; i++) { state = state || Contains(TouchManager.ScreenToWorldPoint(TouchManager.GetTouch(i).position)); } } SubmitButtonState(target, state, updateTick); }
public override void ConfigureControl() { var worldOffset = (Vector3)offset * TouchManager.UnitToWorld; resetPosition = TouchManager.ViewToWorldPoint(TouchUtility.AnchorToViewPoint(anchor)) + worldOffset; transform.position = resetPosition; ScaleSprite(ringGameObject, ringRenderer, ringSize); ScaleSprite(knobGameObject, knobRenderer, knobSize); worldActiveArea = TouchManager.ViewToWorldRect(activeArea); worldRingSize = ringSize * TouchManager.HalfUnitToWorld; worldKnobSize = knobSize * TouchManager.HalfUnitToWorld; worldKnobRange = knobRange * TouchManager.HalfUnitToWorld; }
public override void TouchEnded(Touch touch) { if (currentTouch == touch) { Vector3 a = TouchManager.ScreenToWorldPoint(touch.position); Vector3 vector = a - beganPosition; float num = Time.realtimeSinceStartup - beganTime; if (vector.magnitude <= maxTapMovement && num <= maxTapDuration && tapTarget != 0) { fireButtonTarget = true; } thisPosition = Vector3.zero; lastPosition = Vector3.zero; currentTouch = null; } }
public override void TouchBegan(Touch touch) { if (currentTouch != null) { return; } var beganPosition = TouchManager.ScreenToWorldPoint(touch.position); if (worldActiveArea.Contains(beganPosition)) { thisPosition = beganPosition; lastPosition = beganPosition; currentTouch = touch; } }
public override void TouchBegan(Touch touch) { if (currentTouch == null) { beganPosition = TouchManager.ScreenToWorldPoint(touch.position); if (worldActiveArea.Contains(beganPosition)) { lastPosition = beganPosition; currentTouch = touch; currentVector = Vector2.zero; currentVectorIsSet = false; fireButtonTarget = true; nextButtonTarget = ButtonTarget.None; lastButtonTarget = ButtonTarget.None; } } }
public override void SubmitControlState(ulong updateTick, float deltaTime) { #if !(UNITY_4_3 || UNITY_4_5 || UNITY_4_6 || UNITY_4_7 || UNITY_5_0 || UNITY_5_1 || UNITY_5_2) if (pressureSensitive) { var buttonValue = 0.0f; if (currentTouch == null) { if (allowSlideToggle) { var touchCount = TouchManager.TouchCount; for (var i = 0; i < touchCount; i++) { var touch = TouchManager.GetTouch(i); if (button.Contains(touch)) { buttonValue = Utility.Max(buttonValue, touch.NormalizedPressure); } } } } else { buttonValue = currentTouch.NormalizedPressure; } ButtonState = buttonValue > 0.0f; SubmitButtonValue(target, buttonValue, updateTick, deltaTime); return; } #endif if (currentTouch == null && allowSlideToggle) { ButtonState = false; var touchCount = TouchManager.TouchCount; for (var i = 0; i < touchCount; i++) { ButtonState = ButtonState || button.Contains(TouchManager.GetTouch(i)); } } SubmitButtonState(target, ButtonState, updateTick, deltaTime); }
public override void SubmitControlState(ulong updateTick, float deltaTime) { if (pressureSensitive) { float num = 0f; if (currentTouch == null) { if (allowSlideToggle) { int touchCount = TouchManager.TouchCount; for (int i = 0; i < touchCount; i++) { Touch touch = TouchManager.GetTouch(i); if (button.Contains(touch)) { num = Utility.Max(num, touch.normalizedPressure); } } } } else { num = currentTouch.normalizedPressure; } ButtonState = (num > 0f); SubmitButtonValue(target, num, updateTick, deltaTime); return; } if (currentTouch == null && allowSlideToggle) { ButtonState = false; int touchCount2 = TouchManager.TouchCount; for (int j = 0; j < touchCount2; j++) { ButtonState = (ButtonState || button.Contains(TouchManager.GetTouch(j))); } } SubmitButtonState(target, ButtonState, updateTick, deltaTime); }
public override void TouchEnded(Touch touch) { if (currentTouch == touch) { currentTouch = null; currentVector = Vector2.zero; currentVectorIsSet = false; Vector3 b = TouchManager.ScreenToWorldPoint(touch.position); if ((beganPosition - b).magnitude < sensitivity) { fireButtonTarget = true; nextButtonTarget = tapTarget; lastButtonTarget = ButtonTarget.None; } else { fireButtonTarget = false; nextButtonTarget = ButtonTarget.None; lastButtonTarget = ButtonTarget.None; } } }
public override void TouchEnded(Touch touch) { if (currentTouch != touch) { return; } var endedPosition = TouchManager.ScreenToWorldPoint(touch.position); var deltaPosition = endedPosition - beganPosition; var deltaTime = Time.realtimeSinceStartup - beganTime; if (deltaPosition.magnitude <= maxTapMovement && deltaTime <= maxTapDuration) { if (tapTarget != ButtonTarget.None) { fireButtonTarget = true; } } thisPosition = Vector3.zero; lastPosition = Vector3.zero; currentTouch = null; }
void OnEnable() { touchManager = target as TouchManager; headerTexture = Internal.EditorTextures.TouchManagerHeader; }
public override void ConfigureControl() { worldActiveArea = TouchManager.ConvertToWorld(activeArea, areaUnitType); }
public bool Contains(Touch touch) { return(Contains(TouchManager.ScreenToWorldPoint(touch.position))); }