Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice

Minor curious bug, ScrollRect, normalizedPosition horizontal not working..?

Discussion in 'UGUI & TextMesh Pro' started by Fattie, Nov 20, 2014.

  1. Fattie

    Fattie

    Joined:
    Jul 5, 2012
    Posts:
    476
    Just a curiosity, you can do this ..

    Code (csharp):
    1.  
    2. public class SliderBounceArrival:MonoBehaviour
    3.     {
    4.     void Start()
    5.         {
    6.         ScrollRect sr = GetComponent<ScrollRect>();
    7.         if ( sr == null) return;
    8.         sr.normalizedPosition = new Vector2(0.0f,1.5f); // note the 1.5
    9.         }
    10.     }
    11.  
    , attach it to a ScrollRect. It will "bounce" on arrival.

    Curiously, if you change to

    Code (csharp):
    1.  
    2.         sr.normalizedPosition = new Vector2(0.7f,1.0f); // note horizontal
    3.  
    it does not work! Does nothing. I tried it in Awake, etc. Even if you just Invoke it later, it exhibts the same problem!

    Code (csharp):
    1.  
    2.     void Start()
    3.         {
    4.         Invoke("_teste",2f);
    5.         }
    6.     void _teste()
    7.         {
    8.         ScrollRect sr = GetComponent<ScrollRect>();
    9.         if ( sr == null) return;
    10.         sr.normalizedPosition = new Vector2(0.0f,1.7f); // only vertical works
    11.         }
    12.  
    tonight's mystery ...

    {Note, you can achieve the same arrival bounce effect by just moving it in the editor, so the content is down (or right).}
     
    Last edited: Nov 20, 2014