How can I make my levels load in random order?

So i’m pretty knew to unity and I’m trying to make a multilevel game. So I used the script :
function OnTriggerEnter (other : Collider)
{
Application.LoadLevel (“nameofyourscene”);
}
And this does work, however I want it to load a random level out of 25 different scene, and this one can only load 1 specifically.
I’m really stumped on this, so any help is appreciated.

If your Scene levels are named consistently eg… Level1, Level2, level3 …etc.
You could just do…

 Application.LoadLevel ("Level" + Random.Range(1, 25));

Application.LoadLevel takes integer arguments too. So you just generate a random integer, and load the corresponding level. There’s actually an example of this in the documentation for Random.Range, I’ll post it here:

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour {
    void Example() {
        Application.LoadLevel(Random.Range(0, Application.levelCount));
    }
}

If you have levels you don’t want to load, put them first in the load order (in the build settings), and start your random range after those.

If you want to keep the string reference you can simply add all of your levels to a list.

List<string> levels;

...

Application.LoadLevel(levels[Random.Range(0, levels.count)]);

If you want you can also remove levels from the list as they are loaded, thus preventing duplication of levels.