-
Notifications
You must be signed in to change notification settings - Fork 208
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
Setter for Value property in FloatReference #12
Comments
On second thought, maybe instead we don't allow The property can be changed to this:
|
Sorry, I'm not the maintainer; but I got a notification, and it occurred to me to mention that I also extended the solution in this repo with differentiated read-only and writeable classes, and a lot of other features. :) If you want, you can look into it as a possible implementation. For example this is a writeable float property, which extends the basic concrete read-only class, which is further derived from a generic abstract base class I also ended up differentiating 'properties' and 'events', because in my use I realized that a lot of times all I want is to push a notification to a component with a certain payload, without having an initial value set. But possibly there were other reasons too; I can't quite remember because it was ages ago. :) |
@baratgabor I see. I do think that creating separate read-only and writeable classes is a good solution because you have a choice on whether modifications are allowed. Thanks for showing me! |
Hello Ryan! I'm probably very late but amazing sharing; it completely changed the way on how I worked with Unity and this is so beneficial. Thank you!
I am thinking of adding a
set
to theValue
property so that when other scripts assign a value, theValue
property can receive it, then modify, based on whetherUseConstant
istrue
orfalse
,ConstantValue
orVariable.Value
.The property will look like this:
And in other scripts, one can simply do something like this:
So far, the only implication I have seen was that setting via a
FloatReference
, you may be expecting a variable to get updated, but ifUseConstant
istrue
, the constant is updated and not the variable. So, for example, if you decrement the player's HP and the HP is of typeFloatReference
withUseConstant
set totrue
, then this may not update the UI for the HP (e.g. say a HP bar) which depends on aFloatVariable
to determine the fill amount, making others think that the player's HP is not decreasing.But then if such a case happens,
FloatVariable
should be used to adjust HP instead ofFloatReference
, which will make it clear to the team that modifications made to it will be clearly shown.The text was updated successfully, but these errors were encountered: