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

Problem With Fixed Arrays

Discussion in 'Scripting' started by ZeWitcher, Jul 22, 2012.

  1. ZeWitcher

    ZeWitcher

    Joined:
    Jul 13, 2012
    Posts:
    12
    Hello everyone. I'm new with Unity and I'm using JavaScript,

    In Adobe Flash Professional there is a Vector class which is similar to Unity's float[] (Using float as an example). The only problem is that Unity's float[] class has a fixed range. I know Arrays are a solution to my problem but float[]s are more efficient and strong. Is there anyway to create one with a variable range?
     
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Use List. The syntax in Unityscript is the same as C# but with an extra ".", such as "x = new List.<float>()" instead of "x = new List<float>()".

    --Eric
     
  3. ZeWitcher

    ZeWitcher

    Joined:
    Jul 13, 2012
    Posts:
    12
    So its not possible to do such thing in JavaScript, right?
     
    Last edited: Jul 22, 2012
  4. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Well, yes, the point of my post is that it is possible. (Unity doesn't really use Javascript, even though they call it that; it's more accurately called Unityscript.)

    --Eric
     
  5. ZeWitcher

    ZeWitcher

    Joined:
    Jul 13, 2012
    Posts:
    12
    I just found out that I need to import them first...