Search Unity

Rect transform

Discussion in 'UGUI & TextMesh Pro' started by Koesys, Aug 13, 2015.

  1. Koesys

    Koesys

    Joined:
    Jul 20, 2015
    Posts:
    18
    Hello.
    I have created a .png composed by 97 images which were 60x60.
    So, it's resolution is 5820x60, the size is 365Ko.

    I would like to create an animated button based on that picture.
    I have created a button with an image and a mask 60x60, and I created a child to it, where I put my png in the sprite component.

    Now, I want to move it with a script, and it is where I have a problem. Here my script :

    Code (CSharp):
    1.  
    2.  
    3.     Vector2 move;
    4.  
    5.     void Start()
    6.     {
    7.         move.x = 0.0f;
    8.         move.y = 0.0f;
    9.     }
    10.  
    11.     void FixedUpdate ()
    12.     {
    13.             move.x -= 60.0f;
    14.             GetComponent<RectTransform>().anchoredPosition = move;
    15.  
    16.           (if move.x <= 5820)
    17.         {   move.x -= 0.0f;    }
    18.     }
    19.     }
    So :
    It work for the "Left" attribute of the Rect Transform, as it should, BUT it also modify the "right" attribute, so it doesn't work properly. I try a lot of things, but I cannot find a way to move ONLY the Left attribute.
    Could you help me with that ?
    Maybe, do you know a better solution to do that sort of animations which is not too heavy ?

    Thanks.
     
  2. Koesys

    Koesys

    Joined:
    Jul 20, 2015
    Posts:
    18