Comments (4)
I had a go of modifying the slider example from our example project to use min values other than 0.
What I observed was that moving the sliders worked as expected, and I could move one slider beyond the minimum value of the other one fine.
I noticed that when I changed the value the slider was bound to externally to a value outside the range of the slider, the property would be set once with that value, then immediately again with the min value of the slider. Is this the issue you're talking about?
from unity-weld.
Thanks for the in depth tests. No, that's not the issue I'm having. I just did some more tests and I'm having a hard time debugging it.
The problem is, that this problem doesn't show up in the UI. Like your example, my slider is working fine and if I connect a Text object to it, it shows the correct value all the time.
The thing is though, in my "set" method for this property I'm also calling PlayerPrefs.SetInt("DayOfYear", value)
. When my application is restarted, I'm reading that value back from the PlayerPrefs. And THAT'S how I discovered the problem. Somehow, my property's "set" method is called with an incorrect value, and somehow at the same time the UI doesn't reflect that wrong value. I want the range to be [1, 365], but that results in PlayerPrefs always storing the value 1 (well, it's the last value that's written). If I set the range of the slider to [0, 365], everything works as expected.
Since this incorrect value seems to come from Unity's side, I'm not sure there's anything you could do really. These are the two consecutive calls I get:
That last zero gets changed into a 1 later, because it's outside the range. As you might notice, the localCursor value for the second call is a lot more to the left, compared to the first call. I noticed that this is something that happens during debugging, because I moved my mouse pointer to my screen on the left after the first breakpoint was hit. So at one point I thought that this whole problem might only occur during debugging, but that's not the case as I can see by the value that is stored by the PlayerPrefs call.
So, right now I've just decided to set the range to [0, 365] and live with it. It's pretty confusing to me why the call with this wrong value happens and how it could be that the UI is NOT showing this wrong value. Maybe I'm doing something wrong, but my code is pretty simple so I don't think it's me:
[Binding]
public int DayOfYear
{
get
{
return dayOfYear;
}
set
{
if (dayOfYear == value)
{
return; // No change.
}
dayOfYear = value;
PlayerPrefs.SetInt("DayOfYear", value);
OnPropertyChanged("DayOfYear");
}
}
from unity-weld.
Hmm looks like this is the just way Unity UI works. I'll close this for now because it looks like you have a workaround and I'm not sure what we could do from our side to fix it, but let us know if you have an idea how we could better handle it.
from unity-weld.
Fair enough. I also noticed that when I place an OnPropertyChanged
call somewhere in my code to trigger a UI update, besides the "get" method, the "set" method is also called by Unity. Pretty strange and wrong behavior in my opinion.
from unity-weld.
Related Issues (20)
- Binding to game object visibility HOT 2
- Dropdown Binding automatic updates upon list changes HOT 7
- InputField binding binds to wrong event HOT 1
- Problem of TypeResolver for Interface HOT 2
- How to approach drag-drop behavior? HOT 6
- Binding through custom string instead of function name HOT 3
- Bugged images after binding a Sprite in Image Component using OneWayPropertyBinding HOT 2
- Access object of collection HOT 1
- Implement Clean Mvvm Architecture HOT 2
- Binding to parent viewmodel afte Collection Binding doesn't work HOT 1
- Ahead of time Compilation Problem with Binding on iOS HOT 3
- Why custom ObservableList? HOT 5
- CollectionBinding to unassigned property
- How to properly bind to ViewModel data that is avaialbe after Awake? HOT 1
- (Fix Included) Does not update all bindings in VM when passing Null or String.Empty HOT 2
- FloatToStringAdapterOptions removed at runtime
- Event Binding Execution Order Issue causing Race Condition
- Is this project dead? HOT 4
- can I use unity weld on IL2CPP ? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from unity-weld.