user interface - How do I load random levels? -


i'm using unity 3 build game. have basic gui button when clicked, user taken random level. there 10 levels in game. below copy of code i'm trying implement.

function ongui () {     // make background box     gui.box (rect (10,10,100,90), "oracle");      if (gui.button (rect (20,40,80,20),9));     {         application.loadlevel(random.range(0,9));     } } 

it's not happening. i've tried:

function ongui () {     // make background box     gui.box (rect (10,10,100,90), "oracle");       if (gui.button (rect (20,40,80,20)));     {         application.loadlevel(random.range(0, application.levelcount 9));     } } 

i've never used random.range function before , confused @ proper format.

also have ez gui available , wondering if enter correct random range script 'script' dropdown or 'script method' drop down work it, i'd rather use custom button. assistance appreciated.

here code worked. rebuilding , adding few more levels try straight unity docs , see if random scene loads number of scenes in build. digitald

static var levelcount : int;

function ongui () {    // make background box     gui.box (rect (10,10,100,90), "oracle");      if (gui.button (rect (20,40,80,20), "genie")) {         application.loadlevel (random.range(0, application.levelcount-5));      }  } 

Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -