Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Bad comment for unity's function "int" Random.Range.

Discussion in 'Documentation' started by eyalm, Jan 18, 2016.

  1. eyalm

    eyalm

    Joined:
    Dec 20, 2015
    Posts:
    42
    In untiy:
    //
    // Summary:
    // Returns a random float number between and min [inclusive] and max [inclusive]
    // (Read Only).
    public static int Range(int min, int max);

    in documents:
    http://docs.unity3d.com/ScriptReference/Random.Range.html
    Returns a random float number between and min [inclusive] and max [inclusive] (Read Only).

    The true one is the document's version, I'v checked.
     
  2. duck

    duck

    Unity Technologies

    Joined:
    Oct 21, 2008
    Posts:
    358
    There are two different versions of this function.

    The version which accepts float values is inclusive for both parameters.

    The version which accepts int values is exclusive on its max value (which maxes it convenient for referencing a random index of an array).

    eg:

    myArray[Random.Range(0,myArray.Length)]
     
  3. eyalm

    eyalm

    Joined:
    Dec 20, 2015
    Posts:
    42
    I'm talking only on the int version ( look at the code example i'v posted ).
     
  4. duck

    duck

    Unity Technologies

    Joined:
    Oct 21, 2008
    Posts:
    358
    I still can't work out where you're seeing the bad version. You seem to be saying the docs are right, but there is some example code somewhere that is wrong? Where is it? Let me know and I'll fix it! :)
     
  5. eyalm

    eyalm

    Joined:
    Dec 20, 2015
    Posts:
    42
    You can see the mistake when opening visual studio/mono developer and right click on the Random.Range function and pick "Go To Definition".
    There you will see the functions with their comments.
     
  6. duck

    duck

    Unity Technologies

    Joined:
    Oct 21, 2008
    Posts:
    358
    Oooh I see, looks like that's actually coming from the Unity sourcecode itself! I'll see what I can do.
     
  7. duck

    duck

    Unity Technologies

    Joined:
    Oct 21, 2008
    Posts:
    358
    Which version of Unity are you seeing this in? I just had a look in 5.3 and I'm seeing a different (correct) version, and I also notice that the commands marked 'obsolete' in mine aren't marked like that in yours, so perhaps you're looking at an older version of unity?

    Here's what mine looks like:

     
  8. Chris_TerraTech

    Chris_TerraTech

    Joined:
    Sep 16, 2014
    Posts:
    30
    Sorry for the thread necro, but I'm also seeing this in 5.3.4f1.