Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Possibles Range of Values that can be set using inspector, var testInt : int;

Discussion in 'iOS and tvOS' started by qamarzaman, Jul 27, 2011.

  1. qamarzaman

    qamarzaman

    Joined:
    Jul 1, 2010
    Posts:
    85
    Hi,
    Consider the following Script

    Code (csharp):
    1.  
    2.  
    3. //my integer variable
    4. var intValue : int;
    5.  
    6. function Update(){
    7.        
    8.        print( intValue );
    9.  
    10. }
    11.  
    12.  
    the above code will print the value what ever it will be set in the inspector.

    I want to apply the constraint on the possible range of values that can be set in the (var intValue : int; )
    intValue variable. in inspector.

    for example i want to apply the constraint that the variable intValue should only contain value between 0 - 100

    how can i do that, is there any method to set this type of constraint.

    Edit: one way could be to use the editor script that would check if value entered is more than upper limit and set the set the upper limit value, and for lower limit vise versa
     
    Last edited: Jul 27, 2011
  2. tariq86

    tariq86

    Joined:
    Nov 25, 2010
    Posts:
    7
    This would be really cool thing if it is possible............

    I also need this...
     
  3. goodhustle

    goodhustle

    Joined:
    Jun 4, 2009
    Posts:
    310
  4. nigambiz

    nigambiz

    Joined:
    Aug 26, 2013
    Posts:
    1
    zhbjvd likes this.
  5. alussam

    alussam

    Joined:
    May 13, 2018
    Posts:
    15