Commit 4b1cbb7c authored by Sergey Portnoy's avatar Sergey Portnoy
Browse files

AV-347

Настоил позицию нажатия на слайдер
Настроил передачу позиции нажатия слайдеру
parent 23f9711c
Showing with 92 additions and 74 deletions
+92 -74
......@@ -4823,6 +4823,39 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 893728448}
m_CullTransparentMesh: 0
--- !u!21 &936824548
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: UI/Procedural UI Image
m_Shader: {fileID: 4800000, guid: 27d83044d20c5de4e9d57d35e4fda368, type: 3}
m_ShaderKeywords:
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _ColorMask: 15
- _Stencil: 0
- _StencilComp: 8
- _StencilOp: 0
- _StencilReadMask: 255
- _StencilWriteMask: 255
- _UseUIAlphaClip: 0
m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 1}
--- !u!1 &940314996
GameObject:
m_ObjectHideFlags: 0
......@@ -5933,7 +5966,7 @@ Animator:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1100271215}
m_Enabled: 1
m_Enabled: 0
m_Avatar: {fileID: 0}
m_Controller: {fileID: 9100000, guid: 4f2876752a0954d9bb7b36020aa17ab5, type: 2}
m_CullingMode: 0
......@@ -7431,39 +7464,6 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1300563974}
m_CullTransparentMesh: 0
--- !u!21 &1308685478
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: UI/Procedural UI Image
m_Shader: {fileID: 4800000, guid: 27d83044d20c5de4e9d57d35e4fda368, type: 3}
m_ShaderKeywords:
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _ColorMask: 15
- _Stencil: 0
- _StencilComp: 8
- _StencilOp: 0
- _StencilReadMask: 255
- _StencilWriteMask: 255
- _UseUIAlphaClip: 0
m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 1}
--- !u!1 &1311851906
GameObject:
m_ObjectHideFlags: 0
......@@ -8870,7 +8870,7 @@ GameObject:
- component: {fileID: 1661120573}
- component: {fileID: 1661120575}
- component: {fileID: 1661120574}
- component: {fileID: 1661120577}
- component: {fileID: 1661120576}
m_Layer: 5
m_Name: PanelOpenButton
m_TagString: Untagged
......@@ -8937,7 +8937,7 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1661120572}
m_CullTransparentMesh: 0
--- !u!114 &1661120577
--- !u!114 &1661120576
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
......@@ -8946,25 +8946,16 @@ MonoBehaviour:
m_GameObject: {fileID: 1661120572}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a8229c0d1da684d64afd3b526b13c657, type: 3}
m_Script: {fileID: 11500000, guid: 56a31420433f44ea49c2d5481fce1bbe, type: 3}
m_Name:
m_EditorClassIdentifier:
onMouseDown:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 1100271220}
m_MethodName: SwitchOnOff
m_Mode: 1
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
m_TypeName: UnityEngine.Events.UnityEvent, UnityEngine.CoreModule, Version=0.0.0.0,
Culture=neutral, PublicKeyToken=null
target: {fileID: 962231320}
useStartPosFromDefault: 1
startPos: 0
minPos: 0
minCapturePos: 0
maxCapturePos: 0
maxPos: 0
--- !u!1 &1661397901
GameObject:
m_ObjectHideFlags: 0
......@@ -10351,7 +10342,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 41f1c5417c9d7ab4b84e531f83f60a4b, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 1308685478}
m_Material: {fileID: 936824548}
m_Color: {r: 0, g: 0.47843137, b: 1, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
......@@ -11498,7 +11489,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 41f1c5417c9d7ab4b84e531f83f60a4b, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 1308685478}
m_Material: {fileID: 936824548}
m_Color: {r: 0, g: 0.47843137, b: 1, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
......
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace AvvyLand.UI
{
[RequireComponent(typeof(RectTransform))]
......@@ -20,30 +21,43 @@ namespace AvvyLand.UI
private float targetToSliderOffset;
private RectTransform SliderTransform => GetComponent<RectTransform>();
private RectTransform _sliderTransform;
private CanvasScaler _scaler;
private RectTransform SliderTransform => _sliderTransform != null ? _sliderTransform : GetComponent<RectTransform>();
private CanvasScaler Scaler => _scaler != null ? _scaler : GetComponentInParent<CanvasScaler>();
private TKDragRecognizer dragger;
private bool gestureEnabled;
private bool gestureInitialized;
private bool isDragging;
private bool isUp;
[SerializeField]
void Start()
private void Init()
{
if (useStartPosFromDefault)
startPos = target.anchoredPosition.y;
var sliderRect = SliderTransform.rect;
var tkRect = new TKRect(sliderRect.width, sliderRect.height, sliderRect.center);
var tkRect = new TKRect()
{
x = SliderTransform.position.x - SliderTransform.rect.width / 2 * Scaler.scaleFactor,
y = SliderTransform.position.y - SliderTransform.rect.height / 2 * Scaler.scaleFactor,
width = SliderTransform.rect.width * Scaler.scaleFactor,
height = SliderTransform.rect.height * Scaler.scaleFactor
};
dragger = new TKDragRecognizer();
dragger.boundaryFrame = tkRect;
targetToSliderOffset = target.position.y - SliderTransform.position.y;
}
private void OnEnable()
{
if (!gestureInitialized)
Init();
dragger.gestureRecognizedEvent += Selected;
dragger.gestureDraggedEvent += Dragged;
dragger.gestureDroppedEvent += Dropped;
......@@ -55,6 +69,8 @@ namespace AvvyLand.UI
{
if (!isDragging) return;
Debug.Log("Swiping target");
var swiperY = SliderTransform.position.y;
var targetPosition = target.position;
......@@ -75,28 +91,26 @@ namespace AvvyLand.UI
private void Selected(TKDragRecognizer recognizer)
{
Debug.Log("Sliding");
isDragging = true;
}
private void Dragged(TKDragRecognizer recognizer)
{
Debug.Log("Dragging");
Slide(recognizer.currentPosition.y);
}
private void Slide(float value)
{
var sliderTransform = SliderTransform;
var currPosition = sliderTransform.position;
Debug.Log("Sliding at value: " + value);
var currPosition = SliderTransform.position;
currPosition.y = value;
sliderTransform.position = currPosition;
SliderTransform.position = currPosition;
}
private void Dropped(TKDragRecognizer recognizer)
{
Debug.Log("Droped");
Debug.Log("Dropped");
var value = recognizer.currentPosition.y;
HandleDroppedValue(ref value);
Update();
......@@ -117,7 +131,7 @@ namespace AvvyLand.UI
private void SlideSmooth(float value)
{
var sliderTransform = SliderTransform;
}
}
......
......@@ -9,7 +9,7 @@ namespace AvvyLand.UI
public event Action<TKDragRecognizer> gestureRecognizedEvent;
public event Action<TKDragRecognizer> gestureDraggedEvent;
public event Action<TKDragRecognizer> gestureDroppedEvent;
public Vector2 currentPosition;
private bool isDragging;
......@@ -19,6 +19,7 @@ namespace AvvyLand.UI
gestureRecognizedEvent?.Invoke(this);
}
internal override bool touchesBegan(List<TKTouch> touches)
{
if (isDragging || state != TKGestureRecognizerState.Possible || touches.Count < 1)
......@@ -26,13 +27,20 @@ namespace AvvyLand.UI
isDragging = true;
currentPosition = touches[0].startPosition;
_trackingTouches.Add(touches[0]);
state = TKGestureRecognizerState.Began;
return true;
}
internal override void touchesMoved(List<TKTouch> touches)
{
if (state != TKGestureRecognizerState.RecognizedAndStillRecognizing) return;
Debug.Log("Moving");
Debug.Log("State: " + state);
//if (state != TKGestureRecognizerState.Began || state != TKGestureRecognizerState.RecognizedAndStillRecognizing)
// return;
state = TKGestureRecognizerState.RecognizedAndStillRecognizing;
Debug.Log("Moved");
currentPosition = touches[0].position;
gestureDraggedEvent?.Invoke(this);
......@@ -40,9 +48,12 @@ namespace AvvyLand.UI
internal override void touchesEnded(List<TKTouch> touches)
{
Debug.Log("Ending");
currentPosition = touches[0].position;
state = TKGestureRecognizerState.FailedOrEnded;
gestureDroppedEvent?.Invoke(this);
isDragging = false;
}
}
}
......@@ -15,7 +15,7 @@
"com.unity.physics": "0.2.0-preview",
"com.unity.purchasing": "2.0.6",
"com.unity.rendering.hybrid": "0.1.1-preview",
"com.unity.test-framework": "1.0.13",
"com.unity.test-framework": "1.0.18",
"com.unity.textmeshpro": "2.0.1",
"com.unity.timeline": "1.1.0",
"com.unity.ugui": "1.0.0",
......
......@@ -153,6 +153,8 @@ PlayerSettings:
sharedDepthBuffer: 1
dashSupport: 1
lowOverheadMode: 0
protectedContext: 0
v2Signing: 0
enable360StereoCapture: 0
isWsaHolographicRemotingEnabled: 0
protectGraphicsMemory: 0
......
m_EditorVersion: 2019.2.1f1
m_EditorVersionWithRevision: 2019.2.1f1 (ca4d5af0be6f)
m_EditorVersion: 2019.2.4f1
m_EditorVersionWithRevision: 2019.2.4f1 (c63b2af89a85)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment