NVentimiglia / Unity3d-Foundation

Unity3d Databinding, MVVM, Tasks, Localization

Home Page:http://www.nicholasventimiglia.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Updating the binding value when a GameObject is not active

Caiuse opened this issue · comments

Hi There,

I keep running into the issues around data-bound field not updating when the GameObject on which they are attached is not active. Is there any work around to this or suggestions which will allow an inactive GameObject still receiving updates.

Example structure:

  • Parent ( BindingContext & ViewModel )
  • -- Child ( Inactive GO, ListBinder )

When the Child is inactive any changes the ObservableList on the ViewModel are not reflected.

Best Regards, Caius.

This is not currently supported as the BindingBase hooks into the OnEnable event.

https://github.com/NVentimiglia/Unity3d-Foundation/blob/master/Foundation/Assets/Foundation/Databinding/Observers/BindingBase.cs#L169

You can try changing this to Awake / OnDestroy

Alternatively you can add a "DoNotUnbindOnDisable" flag of some sorts

Thank you for your quick response to this. I think the "DoNotUnbindOnDisable" flag would be a perfectly elegant solution to this very use-case centred issue.