Corgi Engine  v9.2
MoreMountains.Tools.MMObservable< T > Struct Template Reference

This struct lets you declare observable properties. For example, let's say you have a class called Character, and you declare its speed like so : More...

Public Attributes

Action OnValueChanged
 
Action< T > OnValueChangedTo
 
Action< T, T > OnValueChangedFromTo
 

Properties

T??? Value [get, set]
 

Detailed Description

This struct lets you declare observable properties. For example, let's say you have a class called Character, and you declare its speed like so :

public MMObservable<float> Speed;

then, in any other class, you can register to OnValueChanged events on that property (usually in OnEnable) :

protected virtual void OnEnable() { _myCharacter.Speed.OnValueChanged += OnSpeedChange; }

and unsubscribe like so :

protected virtual void OnDisable() { _myCharacter.Speed.OnValueChanged -= OnSpeedChange; }

and then all you need is a method to handle that speed change :

protected virtual void OnSpeedChange() { MMDebug.DebugLogInfo(_myCharacter.Speed.Value); }

You can look at the MMObservableTest demo scene for an example of how it's used.

Template Parameters
T

Member Data Documentation

◆ OnValueChanged

Action MoreMountains.Tools.MMObservable< T >.OnValueChanged

◆ OnValueChangedFromTo

Action<T,T> MoreMountains.Tools.MMObservable< T >.OnValueChangedFromTo

◆ OnValueChangedTo

Action<T> MoreMountains.Tools.MMObservable< T >.OnValueChangedTo

Property Documentation

◆ Value

T??? MoreMountains.Tools.MMObservable< T >.Value
getset

The documentation for this struct was generated from the following file: