Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Problem with array of Vector2

Discussion in 'iOS and tvOS' started by EducaSoft, Dec 29, 2009.

  1. EducaSoft

    EducaSoft

    Joined:
    Sep 9, 2007
    Posts:
    650
    I have this code which defines an array of Vector2 values


    Code (csharp):
    1. private var road_uvs = new Array();
    2. private var i:int;
    3. private var ar_uvs = new Array
    4. (Vector2(0,0),Vector2(1,0),Vector2(0,0.1111111), Vector2(1,0.1111111), Vector2(0,0.2222222),Vector2(1,0.2222222), Vector2(0,0.3333333),Vector2(1,0.3333333),Vector2(0,0.4444444), Vector2(1,0.4444444),Vector2(0,0.5555555), Vector2(1,0.5555555), Vector2(0,0.6666666),Vector2(1,0.6666666), Vector2(0,0.7777777),Vector2(1,0.7777777),Vector2(0,0.8888888), Vector2(1,0.8888888),Vector2(0,1),Vector2(1,1));


    and then want to call

    for (i=0;i<20;i++)
    {
    road_uvs.Add(Vector2(ar_uvs[0],ar_uvs[1]));
    }



    But somehow on iphone this doesn't want to run, because its not strongly typed. Can somebody please help me I here? Is this possible at all on Iphone ?

    Any help would be greatly appreciated.
     
  2. Wozik

    Wozik

    Joined:
    Apr 10, 2009
    Posts:
    662
    Code (csharp):
    1. private var ar_uvs: [b]Vector2[/b] = new Array
    2. (Vector2(0,0),Vect.....
    ?
     
  3. 1r0nM0nkey

    1r0nM0nkey

    Joined:
    Apr 8, 2009
    Posts:
    131
    I don't know javascript, but it looks like you are referencing a 1D array as a 2D array.

    Code (csharp):
    1.  
    2. private var ar_uvs = new Array( ... );
    3.  
    4. ar_uvs[i][0];
    5.  
    6.  
    ... seems like a bad idea to me.