Author Topic: [SOLVED] Chat example with scroll (TOUCH)  (Read 7684 times)

PabloAM

  • Jr. Member
  • **
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 58
    • View Profile
[SOLVED] Chat example with scroll (TOUCH)
« 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!
« Last Edit: May 20, 2013, 07:08:41 AM by PabloAM »

galuodo

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 65
    • View Profile
Re: Chat example with scroll (TOUCH)
« Reply #1 on: May 18, 2013, 04:55:52 AM »
u can refer to Example 7 - Scroll View (Panel)

PabloAM

  • Jr. Member
  • **
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 58
    • View Profile
Re: Chat example with scroll (TOUCH)
« Reply #2 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!
« Last Edit: May 20, 2013, 07:13:18 AM by PabloAM »

vip_prizrak_3

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 31
    • View Profile
Re: Chat example with scroll (TOUCH)
« Reply #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

PabloAM

  • Jr. Member
  • **
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 58
    • View Profile
Re: [SOLVED] Chat example with scroll (TOUCH)
« Reply #4 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
« Last Edit: May 20, 2013, 07:22:19 AM by PabloAM »