Basic Observable Pattern in Unity
- SBObservable - Generic Typed observable object using a action callback when data is changed
- ObservableList - Generic Typed observable list using action callbacks when list is changed.
public SBObservable<Texture2D> store = new SBObservable<Texture2D>();
model.dataUpdated += (T obj) =>
{
//Ugly type casting, know a better way to do this?
Texture2D newT2 = (Texture2D)(object)obj;
Image.sprite = Sprite.Create(newT2, new Rect(0.0f, 0.0f, newT2.width, newT2.height), new Vector2(0.5f, 0.5f), 100.0f);
};
store.Data = texture;