void onStateChanged(LoaderProps newProps) { // Only update from the state if the props we need change if (!newProps.Equals(this.props)) { this.props.Set(newProps.chapter, newProps.state, newProps.scene); this.stateChanged(); } }
// Use this for initialization IEnumerator Start() { // Setup the AssetBundleManager yield return(StartCoroutine(Initialize())); // Subscribe to the game state Unidux.Subject .TakeUntilDisable(this) .StartWith(Unidux.State) .Subscribe(state => { var newProps = new LoaderProps(); newProps.Set(state.Game.Chapter, state.Game.State, state.Game.Scene); this.onStateChanged(newProps); }) .AddTo(this); }
// Clean way to check if the props have changed public bool Equals(LoaderProps newProps) { return(this.chapter == newProps.chapter && this.state == newProps.state && this.scene == newProps.scene); }