|
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
(comments are locked)
|
|
according to: http://answers.unity3d.com/questions/186832/slider-bar-in-inspector.html You can try to extend the editor.
(comments are locked)
|
|
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!
(comments are locked)
|
|
Look up for Mathf.Camp, that should make it. This has been asked many times: Example. Please google it next time. Looks like they're asking about inspector-specific clamping, not only inside the script. To where if you try to change something clamped between 0 and 5 in code, to 532340934 in the inspector it won't allow it.
May 13 '12 at 02:06 AM
Lo0NuhtiK
yes im just asking about the inspector clamping, i dont have much knowledge of making scripts outside of runtime if you know what i mean. i can set max and mins when game is running but would like to be able to do it when game isnt running for my own benifit.
May 13 '12 at 02:10 AM
reptilebeats
You could still do it with clamp and having your script run in edit mode. Only thing that sucks about that is it will run all the other stuff in your code also.
May 13 '12 at 02:30 AM
Lo0NuhtiK
yep just fond that edit line, shame it cant be set as a function, i just tried mathf but wouldnt work just set it to the first number. when i set it in if's it works. i might be using it wrong i never use math operations, i had something like pragma strict@script ExecuteInEditMode() var alphaAmount : float; function OnGUI(){ alphaAmount = Mathf.Clamp(1,0.05,0.5); }
May 13 '12 at 02:55 AM
reptilebeats
doesnt matter had to put alpha in as my value
May 13 '12 at 03:08 AM
reptilebeats
(comments are locked)
|
