- Home /
Why can't I use uint for the inspector?
Basically when I make a public variable in a class of MonoBehaviour an unsigned integer in C# the Inspector does not add them. They work fine though, the code compiles and runs normally. I just can't let the designer edit them. Changing them to integers or floats makes them pop up in the Inspector.
Is this a bug? Can I work around it?
Here's a code example if you so dearly desire. Tile Size will show up, Width and Height won't.
public uint m_Width = 50, m_Height = 50;
public float m_TileSize = 1.0f;
Answer by Jamora · Mar 04, 2014 at 09:22 PM
It is not a bug. They just haven't been implemented in the inspector code. Long does show up on the inspector, so if you really really require only positive, huge, integer values, you can use a long and then use the OnValidate method to check for negative values, or the Range attribute.
Answer by rutter · Mar 04, 2014 at 09:24 PM
Unity's built-in serialization doesn't handle uints, which is a bit of a bummer.
If you really need a workaround, check these other two threads:
You can write your own editor script to clamp or otherwise manage values. You can ultimately serialize an array of bytes, if you're really set on using uints.
Answer by Gnemlock · Jan 22, 2017 at 01:58 PM
Running Unity 5.5.0f3, I can confirm that Unity now supports the display of uint
types in the inspector.
Your answer
![](https://koobas.hobune.stream/wayback/20220613135357im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
"the process can not access the file because it is being used by another program" 3 Answers
Pixelartifacts on edges when activating Antialiasing... 4 Answers
ExternalEval not working on Mac? 0 Answers
Running straight and to the right at the same time 1 Answer
Possible Bug - Cannot remove script component from game object. 2 Answers