i am using random.range function...its generating random number..but its nt appearing

on my gui text…here is my code…plz help…

#pragma strict
var rand:float;


function Start()
{
rand = Random.Range(0.0, 10.0);
}

You are not telling it to be displayed that is why.

You could print to console like so:

Or as Meltdown suggested use a GUI.Label to display it on the actual screen:

Additionally you should be able to see the value of rand if you click the object which has the script attached to it and press play. The inspector should have a value for rand in the script component section.

please see the code monodevelop gives an following error…
No appropriate version of ‘UnityEngine.GUI.Label’ for the argument list ‘(UnityEngine.Rect, int)’ was found. (BCE0023) (Assembly-UnityScript)

#pragma strict

var rand:int;

function Start()

{

rand = Random.Range(0, 10);

}

function OnGUI()
{

;
GUI.Label(Rect(20,20,100,30),rand);


}

rand.ToString() should work. Or the equivalent in UnityScript.

In boo, I would write it:

import UnityEngine

class RandomInt(MonoBehaviour):
     public rand as int

     def Start():
          rand = Random.Range(0, 10)

     def OnGUI():
          GUI.Label(Rect(20, 20, 100, 30), rand.ToString())

I saw you made a typo as well but I think you can easily spot it :slight_smile:

This is good practice by the way, I tried to do the same thing, but the GUI.Label function only takes a Texture2D parameter or a string you can’t just put an int into place without converting.

IDK if you were talking to me or OP, but mine did have an error. heh. Forgot a “)”

Yeah I noticed that as well but I was talking to Sidhesh hehe.

Are you talking about the extraneous “;” in his script? I’m not 100% sure if it would cause a major error or not. I don’t worry about it at all in Boo, so I don’t really know xD

Well in fact the script still works with the extra semicolon it just looked wrong to me :stuck_out_tongue:

Alright, I thought it would, since basically “;” just denotes the end of a line. :stuck_out_tongue:

Forgive me because I’m learning how to program myself this is crucial information to me :slight_smile:

But you are right anyway.

Oh no worries, contact me for any help. While I’m not a master at C# or UnityScript, I probably can still help.

Maybe I will thanks for the offer.

Of course. Anyways, derailing of topic ended. Did you achieve the help you needed, OP?