-
Notifications
You must be signed in to change notification settings - Fork 171
Set default values for normalized position to -1 #567
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
Conversation
|
It was discussed in the discord channel. The reason for this PR is to allow developers to actually set It didn't work before because JSON serializer omitted
|
src/RustCui.cs
Outdated
| [DefaultValue(-1f)] | ||
| public float HorizontalNormalizedPosition { get; set; } = -1f; | ||
|
|
||
| [JsonProperty("verticalNormalizedPosition")] | ||
| public float VerticalNormalizedPosition { get; set; } | ||
| [DefaultValue(-1f)] | ||
| public float VerticalNormalizedPosition { get; set; } = -1f; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, I might be missing something but is there a reason we are not looking to do something like this instead?
| [DefaultValue(-1f)] | |
| public float HorizontalNormalizedPosition { get; set; } = -1f; | |
| [JsonProperty("verticalNormalizedPosition")] | |
| public float VerticalNormalizedPosition { get; set; } | |
| [DefaultValue(-1f)] | |
| public float VerticalNormalizedPosition { get; set; } = -1f; | |
| public float? HorizontalNormalizedPosition { get; set; } | |
| [JsonProperty("verticalNormalizedPosition")] | |
| public float? VerticalNormalizedPosition { get; set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would work fine too. 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will work too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was made like this only to avoid nullability of value types. But both approaches are valid.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nullable value types use more memory compared to just value type. Because it is being wrapped into Nullable struct. I don't have benchmarks, nor does it matter a lot.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah if you want me to commit your suggestion for easier merge I don't mind (or if you wanna do it manually), it would work fine both ways only difference is that they won't be able to set -1f with the original commit which can only be used to do some animation so exact value doesn't matter.
Value 0 was default and therefore omitted
|
Thanks :) |
Setting 0 was getting omitted
Credit: Evora