Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add HexAttribute #283

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Add HexAttribute #283

wants to merge 3 commits into from

Conversation

nitz
Copy link

@nitz nitz commented Nov 16, 2021

HexPropertyDrawer will draw an integer type decorated with [Hex] represented as a hexadecimal string. The user can modify the hex value and it will re-serialize as expected. If the 0x is removed from the field, or the user enters a decimal number, that number will be serialized as decimal, but still displayed as hexadecimal.

HexAttribute allows a manual setting of a minimum display width, adjusting how many potential 0s the hexadecimal string is padded with. By default, the the minimum width will be automatically determined based on the type of the field.

Added to readme, example code:

public class NaughtyComponent : MonoBehaviour
{
	[Hex]
	public int myHexValue = 0x1234;
	[Hex]
	public int myIntValue = 1234;
}

Produces:

Hex_Inspector

`HexPropertyDrawer` will draw an integer type decorated with `[Hex]` represented as a hexadecimal string. The user can modify the hex value and it will re-serialize as expected. If the `0x` is removed from the field, or the user enters a decimal number, that number will be serialized as decimal, but still displayed as hexadecimal.

`HexAttribute` allows a manual setting of a minimum display width, adjusting how many potential 0s the hexadecimal string is padded with. By default, the the minimum width will be automatically determined based on the type of the field.
@nitz nitz changed the title Add hex Add HexAttribute Nov 16, 2021
@nitz
Copy link
Author

nitz commented Jun 14, 2022

Updated this PR to not conflict with base.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant