setting max varible value

i was just wandering how you make a maximum varible float number in unity. not during runtime but in editor, so basically i could set a max and min to 1,10 and i would not be able to go past that in the inspector

cheers

@reptilebeats you can use the prefix [Range(numMin, numMax)] before the variable like this:

using UnityEngine;
using System.Collections;

public class FightingScript : MonoBehaviour
{
	[Range(0, 1)]public float health;
	[Range(0, 100)]public int minDamage;
	[Range(0, 100)]public int maxDamage;
}

I found a good hack for this:

If you put the Mathf.Clamp() function in the OnDrawGizmos override, it’ll get called in the editor without having to mess with the rest of your script.

It works great for me!

according to: slider bar in inspector - Questions & Answers - Unity Discussions

You can try to extend the editor.

I use this:

Note for future readers: this is JS-like Unity Script, not C#.
Article on Unity Script removal: UnityScript’s long ride off into the sunset | Unity Blog

var myFloat : float;
var maxFloatNum : float;
function Update ()
{
    if(myFloat > maxFloatNum)// Replace maxFloatNum with any number
    {
        myFloat = maxFloatNum ;
    }
}

Look up for Mathf.Camp, that should make it.

This has been asked many times: Example. Please google it next time.

u can simply put this [Range (0f,10f)] above the field and it should clamp it.
so :
[Range (0f,10f)]
Public float number;