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

PropertyBinding issue #42

Open
alexanderlarsen opened this issue Nov 22, 2022 · 0 comments
Open

PropertyBinding issue #42

alexanderlarsen opened this issue Nov 22, 2022 · 0 comments

Comments

@alexanderlarsen
Copy link

alexanderlarsen commented Nov 22, 2022

I'm experiencing an issue with the PropertyBinding. It works mostly perfect but when I want to do a TwoWay binding, the target needs to have two UnityEvents. If there is only one, the dropdown won't appear and the single UnityEvent that does exist in the Target class won't get automatically assigned.

Steps to reproduce:

  1. Create new class with one property and one UnityEvent (that is invoked when the property changes)
  2. Create source class that implements INotifyPropertyChanged and has a property
  3. Add a PropertyBinding component to some GameObject
  4. Add the first class as the target and assign its property
  5. Select Mode = TwoWay
  6. Add the other INotifyPropertyChanged class as the source and select its property
  7. Run play mode and change the two properties

Behavior:
Source updates target property but not vice versa

If I create two UnityEvents in the target class and select one of them in the dropdown (making sure it's invoked when the property changes ofc), everything works. So it seems that the PropertyBindingEditor class needs to have something selected in the dropdown for two way data binding to work. It won't select the single UnityEvent automatically behind the scenes. I assume that was the idea, to hide the dropdown and select event automatically if there is only one event but unfortunately it doesn't work.

I simply love this data binding implementation, so I really hope there is a way to fix this. I think the problem is in the PropertyBindingEditor somewhere, but my knowledge of EditorGUI scripting and reflection isn't enough to fix it myself.

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

No branches or pull requests

1 participant