unity I want to generate a beautiful random number list

Asked 1 years ago, Updated 1 years ago, 368 views

I'd like to use a list initialized with random numbers in unity c#, but with this method, the code will be this long.
For me, who has become python, it's very troublesome to write like this every time

Is there any way to make a list of random numbers cleaner, preferably one line?

List<int>outputs=new List<int>();
    foreach(intz_inEnumerable.Range(0,output))
    {
        outputs.Add(Random.Range(0,wall_len));
    }

c# unity3d random

2022-12-13 11:41

1 Answers

Enumerable.Range(0,output).Select(_=>Random.Range(0,wall_len))).ToList();


2022-12-14 06:25

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.