Hexadecimal integers in the Inspector?

I have created a script component which contains a number of integers which would more conveniently be entered & displayed in the Inspector as hexadecimal, rather than decimal - but I can’t find a way to do this (seems like it should be an attribute?).

I can do the conversion in my head, but this is not quite so convenient!

Am I missing something & there is a way to do this (I have done a lot of searching & nothing has shown up)?

You need to write a custom inspector for things like that. Here is an example.

1 Like

Or just use a string field if you don’t mind that the conversion may fail for invalid user entries and requires extra handling code for invalid entries. Convert to and from hex strings is simple.

Great occasion for using the OnValidate function. :slight_smile:

I think I’ll just use a string field. Thanks for the responses. Must say I’m surprised a hex formatting attribute isn’t standard.

It is hard to read and rarely used. Hex comes into play when you use bitmasks, and for bitmasks there’s already flags

1 Like

Really I’m not sure if there’d be much call for it. I used hex a lot back in the old days when I was memory mapping my dad’s Apple IIe, but now I’m curious what you’d need hex formatting for in this day in age. Surely you’d want to abstract that away if at all possible.

Added a hexadecimal convertor for integers when the display as hexadecimal option is enabled.
When the update is live, Ill post again.

Colors are the only things I can think of, but colors would be handled by a color picker.

What advantage does it have over the one posted by @ ?

1 Like