initialising a list with values, and adding a range to a list

So i have a public static generic list of vector2 type, and i’m trying to do this from within a function:

RVPoints.AddRange({
        new Vector2(0.0f, 1),//nothing
        new Vector2(0.01f, 1),//ULtiny
        new Vector2(0.1f, 3),//ULsmall
        new Vector2(0.75f, 7),//ULmedium
        new Vector2(4.0f, 10),//ULLarge
        new Vector2(10.0f, 12),//ULveryLarge
        new Vector2(100.0f, 15),//ULMassive
        new Vector2(1000.0f, 20),//ULColossal
        new Vector2(Mathf.Infinity, 1),
        });

This refuses to compile. why?

however, more importantly, this isn’t even what i want to do. What i really want is for the list to be initialised with those values to begin with, rather than having to use addrange to put them in, since i’m entering them manually at authortime. i couldn’t figure out a way to do that either though

help me out a little here?

Edit to add: The error message i get is “Unexpected symbol {” at the first usage of that character in the example code

ArrayUtility.AddRange is a static method, so you should use it like this:

ArrayUtility.AddRange(RVPoints, new Vector2[]{
     new Vector2(0.0f, 1),//nothing
     new Vector2(0.01f, 1),//ULtiny
     new Vector2(0.1f, 3),//ULsmall
     new Vector2(0.75f, 7),//ULmedium
     new Vector2(4.0f, 10),//ULLarge
     new Vector2(10.0f, 12),//ULveryLarge
     new Vector2(100.0f, 15),//ULMassive
     new Vector2(1000.0f, 20),//ULColossal
     new Vector2(Mathf.Infinity, 1),
     });

You may declare a public array of Vector2 like this:

public Vector2[] vectors;

Then, in the inspector you find something like this:

36624-array.png

At this stage, in the inspector, you will be able to change the size of the array, and fill the appeared fields to populate it with Vector2 elements.

You’re trying to declare an array like this: { stuff }, which is not something you can do in C#. You’re required to specify the type of the array.

As for your other question, you can pass in an array in the list constructor, but that’s not really any different from using AddRange. If the number of items in the list doesn’t change, then don’t use a list, use an array.