0

I already have this script.

using UnityEngine; 
using System.Collections;

public class scrollView: MonoBehaviour {

    Vector2 scrollPosition;
    Touch touch;

    // The string to display inside the scrollview. 2 buttons below add    & clear this string.
    string longString = "This is a long-ish string";

    void OnGUI() {

        scrollPosition = GUI.BeginScrollView(new Rect(110, 50, 130, 150), scrollPosition, new Rect(110, 50, 130, 560), GUIStyle.none, GUIStyle.none);

        for (int i = 0; i < 20; i++) {
            GUI.Box(new Rect(110, 50 + i * 28, 100, 25), "xxxx_" + i);
        }

        GUI.EndScrollView();
    }

    void Update() {
        if (Input.touchCount > 0) {
            touch = Input.touches[0];
            if (touch.phase == TouchPhase.Moved) {
                scrollPosition.y += touch.deltaPosition.y;
            }
        }
    }

}

I use this script for the scroll screen in my project. It works well but it needs some optimizations. I couldn't find how to do it. When i slide my finger fastly, i want it to scroll fastly and when i slide my finger slowly, i want it to scroll slowly. How can i do that? Thank you so much for you answers!

d12frosted
  • 1,280
  • 12
  • 33
  • 1
    Are you looking to optimize or figure out how to make it go faster or slower depending on your finger speed? – Savlon Jan 31 '15 at 00:21
  • Actually, I am trying to figure out how to make it go faster or slower depending on my finger speed and this is going to be like that for instance, when i pull my finger up side(or down side) of the screen quickly by releasing my finger after i drag for a while, i want the screen to slide for a while and slow down slowly. I hope you understand what i am saying because of my English(Its really bad). You can see the example of this in smart phones scrolling style. – bekiryanik Jan 31 '15 at 09:02
  • possible duplicate of [How to develop a scrollview with inertia in Unity?](http://stackoverflow.com/questions/23637598/how-to-develop-a-scrollview-with-inertia-in-unity) – d12frosted Jan 31 '15 at 09:54

0 Answers0