Search Unity

Rangeint Enigma

Discussion in 'Scripting' started by JesterGameCraft, Apr 15, 2019.

  1. JesterGameCraft

    JesterGameCraft

    Joined:
    Feb 26, 2013
    Posts:
    452
    I've looked over documentation for RangeInt and it seems like an array where you can specify a start, length. But I'm not clear on how to access it. Anyone have an example or used it in the past?
     
  2. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,195
    It's not an array, from what I can tell. As the documentation mentions, it's just a description of some integer numbers. It looks like it's intended to allow a convenient way to hold on to a couple of numbers often used to describe how you want to interact with an array.

    Consider the a string method like Substring, that generally requires you to pass it a start index and a length. You might want to write a substring method that instead takes a RangeInt parameter, which defined both values in one object.

    So, it just looks like a wrapper to hold a couple of number, no extra functionality.
     
  3. JesterGameCraft

    JesterGameCraft

    Joined:
    Feb 26, 2013
    Posts:
    452
    Thanks for looking at it. I think you're right, looking at it again it seems to be kind of metadata about a Range of Integers. I find documentation confusing though. If it is just a meta data about a range you can only retrieve the start, end and length of the range (fair enough). But in documentation for "start" parameter it talks about index of the range. I think that's a bit misleading since there is no way (that I can tell) to use the index to get range values.
     
  4. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,195
    Yeah, I've been using Unity for a couple of years now, and I've never come across RangeInt, and I had to look it up too. It seems like a fairly specialized object intended to be used for array lookups, so that's perhaps why the documentation for it sounds array-like.
     
  5. JesterGameCraft

    JesterGameCraft

    Joined:
    Feb 26, 2013
    Posts:
    452
    Cool. Thanks for taking the time on this. Regards...