Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

UI Tween animation

Discussion in 'UGUI & TextMesh Pro' started by Redeemer86, Nov 6, 2015.

  1. Redeemer86

    Redeemer86

    Joined:
    Jul 16, 2013
    Posts:
    35
    I want to transform canvas raw images at certain positions inside the canvas. All raw images are starting in one position. But they also translate to a set default position. I want the images to move to a selected layout(selected points on the canvas) which will work in devices having different resolutions and give the same layout impression. How should i fix this problem?
    Code (CSharp):
    1. public class WidgetMove : MonoBehaviour
    2. {
    3.     public Vector3 sx = new Vector3 (0f, 0f, 0f);
    4.     public Vector3[] ranVecs = new Vector3[11];
    5.     public GameObject[] widgets = new GameObject[11];
    6.     public float divx, divy, srec;
    7.  
    8.     // Use this for initialization
    9.     void Start()
    10.     {
    11.         divx = Screen.width;
    12.         divy = Screen.height;
    13.         srec = divx / divy;
    14.         setvalue ();
    15.     }
    16.  
    17.     IEnumerator TracePaths()
    18.     {
    19.     //    widgets = GameObject.FindGameObjectsWithTag("movableWidgets");
    20.         int x = 0;
    21.         yield return new WaitForSeconds(2.9f);
    22.        
    23.         float duration = 2f;
    24.         foreach(GameObject gos in widgets)
    25.         {
    26.             iTween.MoveTo(gos, ranVecs[x], 3.0f);
    27.             x++;
    28.         }
    29.         yield return null;
    30.     }
    31.  
    32.     public void setvalue()
    33.     {
    34.         float setx, sety = 0f;
    35.         setx = srec / 2;
    36.         int y= 0, i, j;
    37.         for (i=0; i<3; i++) {
    38.             for(j=0;j<3;j++){
    39.                 sx= new Vector3(setx,sety,0f);
    40.                 ranVecs[y]=sx;
    41.                 StartCoroutine(TracePaths());
    42.                 setx+=1.5f;
    43.                 y++;
    44.             }
    45.             setx=srec/2;
    46.             sety+=1.0f;
    47.             Debug.Log(ranVecs.Length);
    48.         }
    49.  
    50.     }
    51. }
    52.  
    Thanks
     
  2. Redeemer86

    Redeemer86

    Joined:
    Jul 16, 2013
    Posts:
    35
    SOLVED .... Had the set y value very low (1.5) .... putting in a decent value (200) worked