using System.Collections; using System.Collections.Generic; using UnityEngine; namespace MoreMountains.Tools { /// /// A test class used to demonstrate the MMObservable in the MMObservableTest demo scene /// public class MMObservableDemoObserver : MonoBehaviour { /// the subject to look at public MMObservableDemoSubject TargetSubject; /// /// When the position changes, we move our object accordingly on the y axis /// protected virtual void OnPositionChange() { this.transform.position = this.transform.position.MMSetY(TargetSubject.PositionX.Value); } /// /// On enable we start listening for changes /// protected virtual void OnEnable() { TargetSubject.PositionX.OnValueChanged += OnPositionChange; } /// /// On enable we stop listening for changes /// protected virtual void OnDisable() { TargetSubject.PositionX.OnValueChanged -= OnPositionChange; } } }