Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: PabloAM on May 17, 2013, 11:16:46 AM

Title: [SOLVED] Chat example with scroll (TOUCH)
Post by: PabloAM on May 17, 2013, 11:16:46 AM
Hello, I find out about that chat example has scroll but only with Scroll whell of the mouse.

Any idea how to do the scroll but with touch?


Cheers!
Title: Re: Chat example with scroll (TOUCH)
Post by: galuodo on May 18, 2013, 04:55:52 AM
u can refer to Example 7 - Scroll View (Panel)
Title: Re: Chat example with scroll (TOUCH)
Post by: PabloAM on May 20, 2013, 06:53:01 AM
u can refer to Example 7 - Scroll View (Panel)

I tried to do it from that example. But that doesn´t work, I cant move the Text List.
The thing is that I can clip it and the ScrollBar makes more little, but I can´t get it and scroll it :(

Any idea why?

Thanks!
Title: Re: Chat example with scroll (TOUCH)
Post by: vip_prizrak_3 on May 20, 2013, 07:07:30 AM
private bool isTouch = false;
public UITextList _chatList;
   
void Update()
    {             
#if (UNITY_ANDROID || UNITY_IPHONE)
        foreach (Touch touch in Input.touches)
      {
            if ((touch.phase == TouchPhase.Began))              
           {               
            isTouch = true;            
         }
         if (touch.phase == TouchPhase.Ended)   
            {
            isTouch = false;
         }
        }
#endif
    }

    void LateUpdate()
    {
        if (isTouch)
        {
            _chatList.OnScroll((float)System.Math.Round(-Input.GetAxis("Mouse Y") / 5, 1));
        }
    }

Make function OnScroll public in script UITextList.cs
Title: Re: [SOLVED] Chat example with scroll (TOUCH)
Post by: PabloAM on May 20, 2013, 07:11:26 AM
Thanks you very much vip_prizrak_3.
I didn´t try because I have find out why that didn´t works with the example 7.
That was because Text list didn´t have "UIDrag Panel Contents" script and a Box collider on it.

Now works, but your script looks better in order to avoid all that work and just get the touch if is from a mobile device.

Good job! :)

Thanks