using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace MoreMountains.Tools
{
///
/// A test class used to demonstrate the MMObservable pattern in the MMObservableDemo scene
/// This one disables itself on Awake, and passively listens for changes, even when disabled
///
public class MMObservableDemoObserverAutoSleep : MonoBehaviour
{
public MMObservableDemoSubject TargetSubject;
protected virtual void OnSpeedChange()
{
this.transform.position = this.transform.position.MMSetY(TargetSubject.PositionX.Value);
}
///
/// On awake we start listening for changes
///
protected virtual void Awake()
{
TargetSubject.PositionX.OnValueChanged += OnSpeedChange;
this.enabled = false;
}
///
/// On destroy we stop listening for changes
///
protected virtual void OnDestroy()
{
TargetSubject.PositionX.OnValueChanged -= OnSpeedChange;
}
///
/// On enable we do nothing
///
protected virtual void OnEnable()
{
}
///
/// On disable we do nothing
///
protected virtual void OnDisable()
{
}
}
}