How to use TouchSpeed class of Input package

Best WinAppDriver code snippet using Input.TouchSpeed

CameraMove.cs

Source:CameraMove.cs Github

copy

Full Screen

...11 private float yMoveDistance;12 private int backValue = 0;13 private int updownValue = 0;14 public GameObject my_Cube;15 public float TouchSpeed = 1;1617 float distance = 0;//触控缩放的距离18 private float lastDist = 0;//用于计算触控缩放19 private float curDist = 0;//用于计算触控缩放20 int t;//判断缩放触控2122 public bool IsLock = false;2324 public bool IsTurnAround = false;252627 public bool BigLock = false;28 [SerializeField]29 Transform Min, Max;3031 private void Awake()32 {33 Instance = this;34 }3536 private void Start()37 {38 InvokeRepeating("Timesecond", 0, 0.1f);39 }4041 void Timesecond()42 {43 Lastx = x;44 Lasty = y;45 }4647 void Update()48 {49 //没有触摸 50 if (!IsLock)51 {52#if UNITY_EDITOR53 JudgeFinger();54#elif UNITY_STANDALONE_WIN55 JudgeFinger();56#elif UNITY_IPHONE57 JudgeFinger();58#elif UNITY_ANDROID59 JudgeFinger();60#endif6162 }6364 // if ( (Input.touchCount>1) && (Input.GetTouch(0).phase==TouchPhase.Moved||Input.GetTouch(1).phase==TouchPhase.Moved))65 //{6667 // var touch1 = Input.GetTouch(0); //第一根手指68 // var touch2 = Input.GetTouch(1); //第二根手指6970 // curDist = Vector2.Distance(touch1.position, touch2.position);//两指间距7172 // //当手指移动时,重置起始距离为当前距离73 // if( t==0 )74 // {75 // lastDist = curDist;76 // t=1;77 // }78 // distance=curDist-lastDist;79 // if (distance > 0) 80 // {81 // if (Vector3.Distance (my_Cube.transform.position, transform.position) < 4)82 // IsLock = true;83 // }84 // if (!IsLock)85 // transform.position = Vector3.MoveTowards (transform.position, my_Cube.transform.position, Time.deltaTime * distance * 0.2f);86 // else87 // {88 // if(distance<0)89 // IsLock = false;90 // }91 // lastDist = curDist;92 //}9394 ////没有触控事件95 //if( Input.touchCount==0 )96 // t=0;97 }9899 public void JudgeMouse()100 {101 //没有触摸 102 if (Input.touchCount <= 0 || Input.touchCount > 1)103 {104 return;105 }106107 if (Input.GetMouseButtonDown(0))108 {109 startFingerPos = Input.GetTouch(0).position;110 }111112 nowFingerPos = Input.GetTouch(0).position;113114 if ((Input.GetTouch(0).phase == TouchPhase.Stationary) || (Input.GetTouch(0).phase == TouchPhase.Ended))115 {116117 startFingerPos = nowFingerPos;118 return;119 }120 if (startFingerPos == nowFingerPos)121 {122 return;123 }124 xMoveDistance = Mathf.Abs(nowFingerPos.x - startFingerPos.x);125126 yMoveDistance = Mathf.Abs(nowFingerPos.y - startFingerPos.y);127128 if (nowFingerPos.x - startFingerPos.x > 0)129 {130 backValue = -1; //沿着X轴负方向移动 131 }132 else133 {134 backValue = 1; //沿着X轴正方向移动 135 }136137138 if (nowFingerPos.y - startFingerPos.y > 0)139 {140 updownValue = 2; //沿着Y轴正方向移动 141 }142 else143 {144 updownValue = -2; //沿着Y轴负方向移动 145 }146147 if (backValue == 1)148 {149 //my_Cube.transform.Rotate(Vector3.up * Time.deltaTime * xMoveDistance*0.6f, Space.World);150 this.transform.Translate(Vector3.left * Time.deltaTime * xMoveDistance * 0.1f * TouchSpeed, Space.World);151 }152 else if (backValue == -1)153 {154 //my_Cube.transform.Rotate(Vector3.up* -1 * Time.deltaTime * xMoveDistance*0.6f, Space.World);155 this.transform.Translate(Vector3.left * -1 * Time.deltaTime * xMoveDistance * 0.1f * TouchSpeed, Space.World);156 }157158 if (updownValue == 2)159 {160 //my_Cube.transform.Rotate(Vector3.up * Time.deltaTime * xMoveDistance*0.6f, Space.World);161 this.transform.Translate(Vector3.forward * Time.deltaTime * yMoveDistance * 0.2f * TouchSpeed, Space.World);162 }163 else if (updownValue == -2)164 {165 //my_Cube.transform.Rotate(Vector3.up* -1 * Time.deltaTime * xMoveDistance*0.6f, Space.World);166 this.transform.Translate(Vector3.forward * -1 * Time.deltaTime * yMoveDistance * 0.2f * TouchSpeed, Space.World);167 }168 }169 float xSave = 1;170 float ySave = 1;171 Transform center;172 Vector3 lookedPosition;173 Quaternion q;174 Vector3 direction;175176177178 float x = 0;179 float y = 0;180 float Lastx = 0;181 float Lasty = 0;182183 public void JudgeFinger()184 {185 //没有触摸 186 if (Input.touchCount <= 0 || Input.touchCount > 1)187 {188 return;189 }190191 if ((Input.GetMouseButtonDown(0) || Input.touchCount > 0) && (Input.GetTouch(0).phase == TouchPhase.Began || Input.GetTouch(0).phase == TouchPhase.Moved))192 {193#if IPHONE || ANDROID194 if (EventSystem.current.IsPointerOverGameObject(Input.GetTouch(0).fingerId))195#else196 if (EventSystem.current.IsPointerOverGameObject(Input.GetTouch(0).fingerId))197#endif198 {199 return;200 }201 }202203 if (Input.GetTouch(0).phase == TouchPhase.Began)204 {205 x = Input.GetTouch(0).position.x * 0.01f * TouchSpeed;206 y = Input.GetTouch(0).position.y * 0.01f * TouchSpeed;207 Lastx = x;208 Lasty = y;209 startFingerPos = Input.GetTouch(0).position;210 }211212 if (Input.touchCount == 1 && Input.GetTouch(0).phase == TouchPhase.Moved)213 {214 x = Input.GetTouch(0).position.x * 0.01f * TouchSpeed;215 y = Input.GetTouch(0).position.y * 0.01f * TouchSpeed;216 }217218 nowFingerPos = Input.GetTouch(0).position;219220 if ((Input.GetTouch(0).phase == TouchPhase.Stationary) || (Input.GetTouch(0).phase == TouchPhase.Ended))221 {222223 startFingerPos = nowFingerPos;224 return;225 }226 if (startFingerPos == nowFingerPos)227 {228 return;229 } ...

Full Screen

Full Screen

InfiniteScrollingList.cs

Source:InfiniteScrollingList.cs Github

copy

Full Screen

1//https://github.com/rnjsxorwns12/unity-infinite-scrolling-list2using System;3using System.Collections.Generic;4using UnityEngine;5[ExecuteInEditMode]6public class InfiniteScrollingList : MonoBehaviour7{8 [Serializable]9 class Position10 {11 [Range(0, 1)]12 public float left;13 [Range(0, 1)]14 public float right;15 [Range(0, 1)]16 public float top;17 [Range(0, 1)]18 public float bottom;19 public Position(float left, float right, float top, float bottom)20 {21 this.left = left;22 this.right = right;23 this.top = top;24 this.bottom = bottom;25 }26 public Position() : this(0, 0, 0, 0) { }27 }28 [Serializable]29 class Item30 {31 [Range(0.01f, 1)]32 public float height = 0.1f;33 [Range(0, 1)]34 public float interval = 0.01f;35 public Texture backgroundNormal;36 public Texture backgroundSelected;37 public Position padding = new Position();38 public TextAnchor textAnchor = TextAnchor.MiddleCenter;39 public Font font;40 public FontStyle fontStyle = FontStyle.Normal;41 public Color fontColorNormal = Color.gray;42 public Color fontColorSelected = Color.white;43 }44 public static InfiniteScrollingList Instance;45 public delegate void SelectedIndexChangedEvent(int index);46 private SelectedIndexChangedEvent selectedIndexChangedEvent;47 [SerializeField, Range(0,1)]48 private float pivot = 0.5f;49 [SerializeField]50 private Position margin = new Position();51 [SerializeField]52 private Position padding = new Position();53 [SerializeField]54 private Texture background;55 [SerializeField]56 private Item item = new Item();57 private GUIStyle labelStyle = new GUIStyle();58 private float drawPosition;59 private float marqueeEnd;60 private float marqueePos;61 private float touchPos;62 private float touchTime;63 private float touchSpeed;64 private int selectedIndex = -1;65 [HideInInspector]66 public List<string> List;6768 public SelectedIndexChangedEvent SelectedIndexChanged69 {70 set{ selectedIndexChangedEvent = value; }71 }72 public int SelectedIndex73 {74 get { return GetIndex(drawPosition); }75 set76 {77 if (List == null || value < 0 || value >= List.Count) return;78 DrawPosition = Screen.height * Mathf.Max(0, 1 - margin.bottom - margin.top) * (item.height + item.interval) * value;79 CheckIfSelectedIndexChanged();80 }81 }8283 private float DrawPosition84 {85 set86 {87 int drawSize = 1;88 if (List != null) drawSize = Mathf.Max(drawSize, List.Count);89 float limit = Screen.height * Mathf.Max(0, 1 - margin.bottom - margin.top) * (item.height + item.interval) * drawSize;90 value %= limit;91 if (value < 0) value += limit;92 drawPosition = value;93 }94 }9596 private void Awake()97 {98 Instance = this;99 }100101 void OnGUI()102 {103 Rect bg = new Rect(104 Screen.width * margin.left,105 Screen.height * margin.top,106 Screen.width * Mathf.Max(0, 1 - margin.right - margin.left),107 Screen.height * Mathf.Max(0, 1 - margin.bottom - margin.top)108 );109 if (bg.width == 0 || bg.height == 0) return;110 if (background != null) GUI.DrawTexture(bg, background);111 Rect rect = new Rect(112 bg.width * padding.left,113 bg.height * padding.top,114 bg.width * Mathf.Max(0, 1 - padding.right - padding.left),115 bg.height * Mathf.Max(0, 1 - padding.bottom - padding.top)116 );117 if (rect.width == 0 || rect.height == 0) return;118 GUI.BeginGroup(bg);119 GUI.BeginGroup(rect);120 float itemHeight = bg.height * item.height;121 float itemTotalHeight = itemHeight + bg.height * item.interval;122 float currY = drawPosition + itemTotalHeight / 2 - bg.height * pivot + rect.y;123 int currIndex = (int)((drawPosition + itemTotalHeight / 2) / itemTotalHeight);124 labelStyle.font = item.font;125 labelStyle.fontStyle = item.fontStyle;126 labelStyle.alignment = item.textAnchor;127 labelStyle.fontSize = (int)(itemHeight * Mathf.Max(0, 1 - item.padding.bottom - item.padding.top));128 for (int i = -Mathf.CeilToInt((currIndex * itemTotalHeight - currY) / itemTotalHeight); i <= Mathf.CeilToInt((currY + rect.height - (currIndex + 1) * itemTotalHeight) / itemTotalHeight) ; i++)129 {130 float y = (currIndex + i) * itemTotalHeight;131 Texture itemBg = i == 0 ? item.backgroundSelected : item.backgroundNormal;132 if (itemBg != null) GUI.DrawTexture(new Rect(0, y - currY + (itemTotalHeight - itemHeight) / 2, rect.width, itemHeight), itemBg);133 if (List != null && List.Count > 0)134 {135 Rect itemContentRect = new Rect(136 rect.width * item.padding.left,137 y - currY + (itemTotalHeight - itemHeight) / 2 + itemHeight * item.padding.top,138 rect.width * Mathf.Max(0, 1 - item.padding.right - item.padding.left),139 labelStyle.fontSize140 );141 GUI.BeginGroup(itemContentRect);142 labelStyle.normal.textColor = i == 0 ? item.fontColorSelected : item.fontColorNormal;143 string content = List[GetIndexInRange(currIndex + i)];144 bool marquee = false;145 if (i == 0)146 {147 float contentWidth = labelStyle.CalcSize(new GUIContent(content)).x;148 if (itemContentRect.width < contentWidth)149 {150 marqueeEnd = contentWidth;151 marquee = true;152 }153 else marqueeEnd = 0;154 }155 GUI.Label(new Rect(marquee ? -marqueePos : 0, 0, marquee ? marqueeEnd : itemContentRect.width, itemContentRect.height), content, labelStyle);156 GUI.EndGroup();157 }158 }159 GUI.EndGroup();160 GUI.EndGroup();161 }162163 private int GetIndexInRange(int indexOutOfRange)164 {165 int index = indexOutOfRange % List.Count;166 if (index < 0) index += List.Count;167 return index;168 }169170 private int GetIndex(float drawPosition)171 {172 if (List != null && List.Count > 0)173 {174 float itemTotalHeight = Screen.height * Mathf.Max(0, 1 - margin.bottom - margin.top) * (item.height + item.interval);175 return GetIndexInRange((int)((drawPosition + itemTotalHeight / 2) / itemTotalHeight));176 }177 return -1;178 }179 private void CheckIfSelectedIndexChanged()180 {181 if (selectedIndex != SelectedIndex) SelectedIndexChange(SelectedIndex);182 }183 private void SelectedIndexChange(int index)184 {185 selectedIndex = index;186 if (index < 0) return;187 marqueePos = 0;188 selectedIndexChangedEvent?.Invoke(index);189 }190 private int touchId = -1;191 private bool Touch(Vector3 pos)192 {193 float x = Screen.width * margin.left;194 float width = Screen.width * Mathf.Max(0, 1 - margin.right - margin.left);195 float y = Screen.height * margin.bottom;196 float height = Screen.height * Mathf.Max(0, 1 - margin.bottom - margin.top);197 return x < pos.x && pos.x < x + width && y < pos.y && pos.y < y + height;198 }199 private void Update()200 {201#if UNITY_EDITOR || !(UNITY_ANDROID || UNITY_IOS)202 if (Input.GetMouseButtonDown(0) && Touch(Input.mousePosition))203 {204 touchTime = Time.deltaTime;205 touchSpeed = 0;206 touchPos = Input.mousePosition.y;207 touchId = 0;208 }209 else if (touchId == 0)210 {211 if (Input.GetMouseButton(0))212 {213 float mouseDeltaPos = Input.mousePosition.y - touchPos;214 touchPos = Input.mousePosition.y;215 DrawPosition = drawPosition + mouseDeltaPos;216 if (touchSpeed == 0 || (touchSpeed > 0 && mouseDeltaPos > 0) || (touchSpeed < 0 && mouseDeltaPos < 0))217 {218 touchSpeed += mouseDeltaPos;219 touchTime += Time.deltaTime;220 }221 else222 {223 touchSpeed = mouseDeltaPos;224 touchTime = Time.deltaTime;225 }226 }227 else if (Input.GetMouseButtonUp(0))228 {229 touchSpeed /= touchTime;230 touchPos = touchSpeed;231 touchTime = 0;232 touchId = -1;233 }234 }235#else236 foreach (Touch t in Input.touches)237 {238 if (t.phase == TouchPhase.Began && Touch(t.position))239 {240 touchTime = Time.deltaTime;241 touchSpeed = 0;242 touchPos = Input.mousePosition.y;243 touchId = t.fingerId;244 }245 else if (touchId == t.fingerId)246 {247 if (t.phase == TouchPhase.Ended || t.phase == TouchPhase.Canceled)248 {249 touchSpeed /= touchTime;250 touchPos = touchSpeed;251 touchTime = 0;252 touchId = -1;253 }254 else255 {256 float mouseDeltaPos = Input.mousePosition.y - touchPos;257 touchPos = Input.mousePosition.y;258 DrawPosition = drawPosition + mouseDeltaPos;259 if (touchSpeed == 0 || (touchSpeed > 0 && mouseDeltaPos > 0) || (touchSpeed < 0 && mouseDeltaPos < 0))260 {261 touchSpeed += mouseDeltaPos;262 touchTime += Time.deltaTime;263 }264 else265 {266 touchSpeed = mouseDeltaPos;267 touchTime = Time.deltaTime;268 }269 }270 }271 }272#endif273 if (touchTime == 0)274 {275 DrawPosition = drawPosition + touchSpeed * Time.deltaTime;276 float mouseSpeedTemp = touchSpeed - touchPos * Time.deltaTime;277 if (touchSpeed < 0) touchSpeed = Mathf.Min(0, mouseSpeedTemp);278 else if (touchSpeed > 0) touchSpeed = Mathf.Max(0, mouseSpeedTemp);279 }280 CheckIfSelectedIndexChanged();281 marqueePos += labelStyle.fontSize * 2 * Time.deltaTime;282 if (marqueePos > marqueeEnd) marqueePos = 0;283 }284} ...

Full Screen

Full Screen

BlindController.cs

Source:BlindController.cs Github

copy

Full Screen

1using UnityEngine;2using System;3using UnityEngine.UI;4using System.Collections;5public class BlindController : MonoBehaviour6{7 //Vector2 touchPos;8 public float maxLocalY;9 public float minLocalY;10 //Touch speed but also direction with + and -11 public float touchSpeed;12 public float touchSpeedReq;13 Vector2 setPos;14 Vector2 refVector;15 public float smoothAmount;16 public bool dragging;17 public bool blindOpen;18 public float yPosTop;19 public float yPosBot;20 public float ypsps;21 void Start()22 {23 }24 void Update()25 {26 if (transform.localPosition.y > (yPosTop + yPosBot) / 2f)27 blindOpen = false;28 else29 blindOpen = true;30 }31 void LateUpdate()32 {33 if (!dragging)34 {35 transform.localPosition = Vector2.SmoothDamp(transform.localPosition, setPos, ref refVector, smoothAmount, Mathf.Infinity, Mathf.Abs(touchSpeed) / 100f * Time.fixedDeltaTime);36 }37 else38 {39 touchSpeed = Input.touches[0].deltaPosition.y / Input.touches[0].deltaTime;40 transform.localPosition = new Vector2(transform.localPosition.x, transform.localPosition.y + (Input.touches[0].deltaPosition.y/1.525f));41 if (transform.localPosition.y <= maxLocalY - 25f)42 {43 transform.localPosition = new Vector2(transform.localPosition.x, yPosBot - 25f);44 blindOpen = false;45 }46 if (transform.localPosition.y >= minLocalY + 25f)47 {48 transform.localPosition = new Vector2(transform.localPosition.x, yPosTop + 25f);49 blindOpen = true;50 }51 ypsps = Input.touches[0].deltaPosition.y;52 }53 }54 public void OnDrag()55 {56 dragging = true;57 }58 public void OnRelease()59 {60 if (Mathf.Abs(touchSpeed) > touchSpeedReq)61 {62 if (touchSpeed > 0)63 setPos = new Vector2(transform.localPosition.x, yPosTop);64 else65 setPos = new Vector2(transform.localPosition.x, yPosBot);66 }67 else68 {69 if(transform.position.y >= (yPosTop + yPosBot) / 2)70 setPos = new Vector2(transform.localPosition.x, yPosTop);71 else72 setPos = new Vector2(transform.localPosition.x, yPosBot);73 touchSpeed = 1000f;74 }75 dragging = false;76 }77}...

Full Screen

Full Screen

TouchSpeed

Using AI Code Generation

copy

Full Screen

1using UnityEngine;2using System.Collections;3using UnityEngine.UI;4using UnityEngine.EventSystems;5using UnityEngine.Events;6using UnityEngine.InputSystem;7{8 public float speed;9 public Text speedText;10 public float speedTime;11 public float speedTimeStart;12 public bool speedStart;13 public bool speedEnd;14 public bool speedStart2;15 public bool speedEnd2;16 public bool speedStart3;17 public bool speedEnd3;18 public bool speedStart4;19 public bool speedEnd4;20 public bool speedStart5;21 public bool speedEnd5;22 public bool speedStart6;23 public bool speedEnd6;24 public bool speedStart7;25 public bool speedEnd7;26 public bool speedStart8;27 public bool speedEnd8;28 public bool speedStart9;29 public bool speedEnd9;30 public bool speedStart10;31 public bool speedEnd10;32 public bool speedStart11;33 public bool speedEnd11;34 public bool speedStart12;35 public bool speedEnd12;36 public bool speedStart13;37 public bool speedEnd13;38 public bool speedStart14;39 public bool speedEnd14;40 public bool speedStart15;41 public bool speedEnd15;42 public bool speedStart16;43 public bool speedEnd16;44 public bool speedStart17;45 public bool speedEnd17;46 public bool speedStart18;47 public bool speedEnd18;48 public bool speedStart19;49 public bool speedEnd19;50 public bool speedStart20;51 public bool speedEnd20;52 public bool speedStart21;53 public bool speedEnd21;54 public bool speedStart22;55 public bool speedEnd22;56 public bool speedStart23;57 public bool speedEnd23;58 public bool speedStart24;59 public bool speedEnd24;60 public bool speedStart25;61 public bool speedEnd25;62 public bool speedStart26;63 public bool speedEnd26;64 public bool speedStart27;65 public bool speedEnd27;66 public bool speedStart28;67 public bool speedEnd28;68 public bool speedStart29;69 public bool speedEnd29;70 public bool speedStart30;71 public bool speedEnd30;72 public bool speedStart31;73 public bool speedEnd31;

Full Screen

Full Screen

TouchSpeed

Using AI Code Generation

copy

Full Screen

1using UnityEngine;2using System.Collections;3{4 public float speed = 1.0f;5 public float acceleration = 1.0f;6 public float deceleration = 1.0f;7 private float currentSpeed = 0.0f;8 private float targetSpeed = 0.0f;9 void Update()10 {11 float oldSpeed = currentSpeed;12 if (Input.touchCount > 0)13 {14 targetSpeed = speed;15 }16 {17 targetSpeed = 0;18 }19 if (currentSpeed < targetSpeed)20 {21 currentSpeed += acceleration * Time.deltaTime;22 }23 {24 currentSpeed -= deceleration * Time.deltaTime;25 }26 if (currentSpeed < 0)27 {28 currentSpeed = 0;29 }30 transform.Rotate(Vector3.up, currentSpeed * Time.deltaTime);31 }32}33using UnityEngine;34using System.Collections;35{36 public float speed = 1.0f;37 public float acceleration = 1.0f;38 public float deceleration = 1.0f;39 private float currentSpeed = 0.0f;40 private float targetSpeed = 0.0f;41 void Update()42 {43 float oldSpeed = currentSpeed;44 if (Input.touchCount > 0)45 {46 targetSpeed = speed;47 }48 {49 targetSpeed = 0;50 }51 if (currentSpeed < targetSpeed)52 {53 currentSpeed += acceleration * Time.deltaTime;54 }55 {56 currentSpeed -= deceleration * Time.deltaTime;57 }58 if (currentSpeed < 0)59 {60 currentSpeed = 0;61 }62 transform.Rotate(Vector3.up, currentSpeed * Time.deltaTime);63 }64}65using UnityEngine;66using System.Collections;67{68 public float speed = 1.0f;69 public float acceleration = 1.0f;70 public float deceleration = 1.0f;71 private float currentSpeed = 0.0f;

Full Screen

Full Screen

TouchSpeed

Using AI Code Generation

copy

Full Screen

1using UnityEngine;2using System.Collections;3using UnityEngine.UI;4using UnityEngine.EventSystems;5using UnityEngine.Events;6using UnityEngine.InputSystem;7using UnityEngine.InputSystem.Controls;8using UnityEngine.InputSystem.Interactions;9{10 public float speed = 0;11 public float speed2 = 0;12 public float speed3 = 0;13 public float speed4 = 0;14 public float speed5 = 0;15 public float speed6 = 0;16 public float speed7 = 0;17 public float speed8 = 0;18 public float speed9 = 0;19 public float speed10 = 0;20 public float speed11 = 0;21 public float speed12 = 0;22 public float speed13 = 0;23 public float speed14 = 0;24 public float speed15 = 0;25 public float speed16 = 0;26 public float speed17 = 0;27 public float speed18 = 0;28 public float speed19 = 0;29 public float speed20 = 0;30 public float speed21 = 0;31 public float speed22 = 0;32 public float speed23 = 0;33 public float speed24 = 0;34 public float speed25 = 0;35 public float speed26 = 0;36 public float speed27 = 0;37 public float speed28 = 0;38 public float speed29 = 0;39 public float speed30 = 0;40 public float speed31 = 0;41 public float speed32 = 0;42 public float speed33 = 0;43 public float speed34 = 0;44 public float speed35 = 0;45 public float speed36 = 0;46 public float speed37 = 0;47 public float speed38 = 0;48 public float speed39 = 0;49 public float speed40 = 0;50 public float speed41 = 0;51 public float speed42 = 0;52 public float speed43 = 0;53 public float speed44 = 0;54 public float speed45 = 0;55 public float speed46 = 0;56 public float speed47 = 0;57 public float speed48 = 0;58 public float speed49 = 0;59 public float speed50 = 0;

Full Screen

Full Screen

TouchSpeed

Using AI Code Generation

copy

Full Screen

1using UnityEngine;2using UnityEngine.UI;3using UnityEngine.InputSystem;4using UnityEngine.InputSystem.EnhancedTouch;5using UnityEngine.InputSystem.Users;6using UnityEngine.InputSystem.Controls;7{8 public Text speedText;9 public Text speedText2;10 public Text speedText3;11 public Text speedText4;12 public Text speedText5;13 public Text speedText6;14 public Text speedText7;15 public Text speedText8;16 public Text speedText9;17 public Text speedText10;18 public Text speedText11;19 public Text speedText12;20 public Text speedText13;21 public Text speedText14;22 public Text speedText15;23 public Text speedText16;24 public Text speedText17;25 public Text speedText18;26 public Text speedText19;27 public Text speedText20;28 public Text speedText21;29 public Text speedText22;30 public Text speedText23;31 public Text speedText24;32 public Text speedText25;33 public Text speedText26;34 public Text speedText27;35 public Text speedText28;36 public Text speedText29;37 public Text speedText30;38 public Text speedText31;39 public Text speedText32;40 public Text speedText33;41 public Text speedText34;42 public Text speedText35;43 public Text speedText36;44 public Text speedText37;45 public Text speedText38;46 public Text speedText39;47 public Text speedText40;48 public Text speedText41;49 public Text speedText42;50 public Text speedText43;51 public Text speedText44;52 public Text speedText45;53 public Text speedText46;54 public Text speedText47;55 public Text speedText48;56 public Text speedText49;57 public Text speedText50;58 public Text speedText51;59 public Text speedText52;60 public Text speedText53;61 public Text speedText54;62 public Text speedText55;63 public Text speedText56;64 public Text speedText57;65 public Text speedText58;66 public Text speedText59;67 public Text speedText60;68 public Text speedText61;69 public Text speedText62;70 public Text speedText63;71 public Text speedText64;72 public Text speedText65;

Full Screen

Full Screen

TouchSpeed

Using AI Code Generation

copy

Full Screen

1using System.Collections;2using System.Collections.Generic;3using UnityEngine;4using UnityEngine.InputSystem;5{6 public Vector2 touchPosition;7 public Vector2 touchSpeed;8 public void OnTouch(InputAction.CallbackContext context)9 {10 touchPosition = context.ReadValue<Vector2>();11 }12 public void OnTouchSpeed(InputAction.CallbackContext context)13 {14 touchSpeed = context.ReadValue<Vector2>();15 }16}17using System.Collections;18using System.Collections.Generic;19using UnityEngine;20using UnityEngine.InputSystem;21{22 public Vector2 touchPosition;23 public Vector2 touchSpeed;24 public void OnTouch(InputAction.CallbackContext context)25 {26 touchPosition = context.ReadValue<Vector2>();27 }28 public void OnTouchSpeed(InputAction.CallbackContext context)29 {30 touchSpeed = context.ReadValue<Vector2>();31 }32}33using System.Collections;34using System.Collections.Generic;35using UnityEngine;36using UnityEngine.InputSystem;37{38 public Vector2 touchPosition;39 public Vector2 touchSpeed;40 public void OnTouch(InputAction.CallbackContext context)41 {42 touchPosition = context.ReadValue<Vector2>();43 }44 public void OnTouchSpeed(InputAction.CallbackContext context)45 {46 touchSpeed = context.ReadValue<Vector2>();47 }48}49using System.Collections;50using System.Collections.Generic;51using UnityEngine;52using UnityEngine.InputSystem;53{54 public Vector2 touchPosition;55 public Vector2 touchSpeed;56 public void OnTouch(InputAction.CallbackContext context)57 {58 touchPosition = context.ReadValue<Vector2>();59 }60 public void OnTouchSpeed(InputAction.CallbackContext context)61 {62 touchSpeed = context.ReadValue<Vector2>();63 }64}65using System.Collections;66using System.Collections.Generic;67using UnityEngine;68using UnityEngine.InputSystem;69{70 public Vector2 touchPosition;71 public Vector2 touchSpeed;72 public void OnTouch(InputAction.CallbackContext context)73 {74 touchPosition = context.ReadValue<Vector2>();

Full Screen

Full Screen

TouchSpeed

Using AI Code Generation

copy

Full Screen

1using UnityEngine;2using System.Collections;3public class TouchSpeed : MonoBehaviour {4private Vector2 touchDeltaPosition;5void Update () {6touchDeltaPosition = Input.GetTouch(0).deltaPosition;7}8}9using UnityEngine;10using System.Collections;11public class TouchSpeed : MonoBehaviour {12private Vector2 touchDeltaPosition;13void Update () {14touchDeltaPosition = Input.GetTouch(0).deltaPosition;15}16}17using UnityEngine;18using System.Collections;19public class TouchSpeed : MonoBehaviour {20private Vector2 touchDeltaPosition;21void Update () {22touchDeltaPosition = Input.GetTouch(0).deltaPosition;23}24}25using UnityEngine;26using System.Collections;27public class TouchSpeed : MonoBehaviour {28private Vector2 touchDeltaPosition;29void Update () {30touchDeltaPosition = Input.GetTouch(0).deltaPosition;31}32}33using UnityEngine;34using System.Collections;35public class TouchSpeed : MonoBehaviour {36private Vector2 touchDeltaPosition;37void Update () {38touchDeltaPosition = Input.GetTouch(0).deltaPosition;39}40}41using UnityEngine;42using System.Collections;43public class TouchSpeed : MonoBehaviour {44private Vector2 touchDeltaPosition;45void Update () {46touchDeltaPosition = Input.GetTouch(0).deltaPosition;47}48}49using UnityEngine;50using System.Collections;51public class TouchSpeed : MonoBehaviour {52private Vector2 touchDeltaPosition;53void Update () {54touchDeltaPosition = Input.GetTouch(0).deltaPosition;55}56}57using UnityEngine;58using System.Collections;59public class TouchSpeed : MonoBehaviour {60private Vector2 touchDeltaPosition;61void Update () {62touchDeltaPosition = Input.GetTouch(0).deltaPosition;63}64}65using UnityEngine;66using System.Collections;67public class TouchSpeed : MonoBehaviour {68private Vector2 touchDeltaPosition;69void Update () {70touchDeltaPosition = Input.GetTouch(0

Full Screen

Full Screen

TouchSpeed

Using AI Code Generation

copy

Full Screen

1using UnityEngine;2using System.Collections;3{4 private Vector2 touchStart;5 private Vector2 touchEnd;6 private float swipeTime;7 private float swipeDistance;8 private float swipeSpeed;9 private float swipeSpeedX;10 private float swipeSpeedY;11 private void Update()12 {13 if (Input.touchCount > 0)14 {15 Touch touch = Input.GetTouch(0);16 if (touch.phase == TouchPhase.Began)17 {18 touchStart = touch.position;19 touchEnd = touch.position;20 }21 else if (touch.phase == TouchPhase.Moved)22 {23 touchEnd = touch.position;24 }25 else if (touch.phase == TouchPhase.Ended)26 {27 touchEnd = touch.position;28 swipeTime = touch.deltaTime;29 swipeDistance = Vector2.Distance(touchStart, touchEnd);30 swipeSpeed = swipeDistance / swipeTime;31 swipeSpeedX = Mathf.Abs(touchEnd.x - touchStart.x) / swipeTime;32 swipeSpeedY = Mathf.Abs(touchEnd.y - touchStart.y) / swipeTime;33 Debug.Log("Swipe Speed: " + swipeSpeed);34 Debug.Log("Swipe Speed X: " + swipeSpeedX);35 Debug.Log("Swipe Speed Y: " + swipeSpeedY);36 }37 }38 }39}40using UnityEngine;41using System.Collections;42{43 private Vector2 touchStart;44 private Vector2 touchEnd;45 private float swipeTime;46 private float swipeDistance;47 private float swipeSpeed;48 private float swipeSpeedX;49 private float swipeSpeedY;50 private void Update()51 {52 if (Input.touchCount > 0)53 {54 Touch touch = Input.GetTouch(0);55 if (touch.phase == TouchPhase.Began)56 {57 touchStart = touch.position;58 touchEnd = touch.position;59 }60 else if (touch.phase == TouchPhase.Moved)61 {62 touchEnd = touch.position;63 }64 else if (touch.phase == TouchPhase.Ended)65 {66 touchEnd = touch.position;67 swipeTime = touch.deltaTime;68 swipeDistance = Vector2.Distance(touchStart, touchEnd);69 swipeSpeed = swipeDistance / swipeTime;70 swipeSpeedX = Mathf.Abs(touchEnd

Full Screen

Full Screen

TouchSpeed

Using AI Code Generation

copy

Full Screen

1using UnityEngine;2using System.Collections;3using TouchSpeed;4public class 1 : MonoBehaviour {5 public float speed;6 void Start () {7 speed = 0.1f;8 }9 void Update () {10 if (Input.touchCount > 0) {11 Touch touch = Input.GetTouch (0);12 Vector2 touchDeltaPosition = touch.deltaPosition;13 transform.Translate (-touchDeltaPosition.x * speed, -touchDeltaPosition.y * speed, 0);14 }15 }16}17using UnityEngine;18using System.Collections;19using TouchSpeed;20public class 2 : MonoBehaviour {21 public float speed;22 void Start () {23 speed = 0.1f;24 }25 void Update () {26 if (Input.touchCount > 0) {27 Touch touch = Input.GetTouch (0);28 Vector2 touchDeltaPosition = touch.deltaPosition;29 transform.Translate (-touchDeltaPosition.x * speed, -touchDeltaPosition.y * speed, 0);30 }31 }32}33using UnityEngine;34using System.Collections;35using TouchSpeed;36public class 3 : MonoBehaviour {37 public float speed;38 void Start () {39 speed = 0.1f;40 }41 void Update () {42 if (Input.touchCount > 0) {43 Touch touch = Input.GetTouch (0);44 Vector2 touchDeltaPosition = touch.deltaPosition;45 transform.Translate (-touchDeltaPosition.x * speed, -touchDeltaPosition.y * speed, 0);46 }47 }48}49using UnityEngine;50using System.Collections;51using TouchSpeed;52public class 4 : MonoBehaviour {53 public float speed;54 void Start () {55 speed = 0.1f;56 }57 void Update () {58 if (Input.touchCount > 0) {59 Touch touch = Input.GetTouch (0);60 Vector2 touchDeltaPosition = touch.deltaPosition;61 transform.Translate (-touchDeltaPosition.x * speed, -touchDeltaPosition.y * speed, 0);62 }63 }64}

Full Screen

Full Screen

TouchSpeed

Using AI Code Generation

copy

Full Screen

1using UnityEngine;2using UnityEngine.UI;3using UnityEngine.EventSystems;4using UnityEngine.Events;5using UnityEngine.InputSystem;6{7 float speed = 0;8 float distance = 0;9 float time = 0;10 void Update()11 {12 if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Moved)13 {14 distance = Input.GetTouch(0).deltaPosition.magnitude;15 time = Input.GetTouch(0).deltaTime;16 speed = distance / time;17 Debug.Log("Speed: " + speed);18 }19 }20}21using UnityEngine;22using UnityEngine.UI;23using UnityEngine.EventSystems;24using UnityEngine.Events;25using UnityEngine.InputSystem;26{27 float speed = 0;28 float distance = 0;29 float time = 0;30 void Update()31 {32 if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Moved)33 {34 distance = Input.GetTouch(0).deltaPosition.magnitude;35 time = Input.GetTouch(0).deltaTime;36 speed = distance / time;37 Debug.Log("Speed: " + speed);38 }39 }40}41using UnityEngine;42using UnityEngine.UI;43using UnityEngine.EventSystems;44using UnityEngine.Events;45using UnityEngine.InputSystem;46{47 float speed = 0;48 float distance = 0;49 float time = 0;50 void Update()51 {52 if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Moved)53 {54 distance = Input.GetTouch(0).deltaPosition.magnitude;55 time = Input.GetTouch(0).deltaTime;56 speed = distance / time;57 Debug.Log("Speed: " + speed);58 }59 }60}61using UnityEngine;62using UnityEngine.UI;63using UnityEngine.EventSystems;64using UnityEngine.Events;65using UnityEngine.InputSystem;66{67 float speed = 0;68 float distance = 0;69 float time = 0;70 void Update()71 {72 if (Input.touchCount >

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run WinAppDriver automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful