chore: initial commit
This commit is contained in:
1073
Assets/Feel/MMTools/Demos/MMObservable/MMObservableDemo.unity
Normal file
1073
Assets/Feel/MMTools/Demos/MMObservable/MMObservableDemo.unity
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4b0c11e0a4798e04c82c84e3f89de5e2
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,40 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MoreMountains.Tools
|
||||
{
|
||||
/// <summary>
|
||||
/// A test class used to demonstrate the MMObservable in the MMObservableTest demo scene
|
||||
/// </summary>
|
||||
[AddComponentMenu("")]
|
||||
public class MMObservableDemoObserver : MonoBehaviour
|
||||
{
|
||||
/// the subject to look at
|
||||
public MMObservableDemoSubject TargetSubject;
|
||||
|
||||
/// <summary>
|
||||
/// When the position changes, we move our object accordingly on the y axis
|
||||
/// </summary>
|
||||
protected virtual void OnPositionChange()
|
||||
{
|
||||
this.transform.position = this.transform.position.MMSetY(TargetSubject.PositionX.Value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// On enable we start listening for changes
|
||||
/// </summary>
|
||||
protected virtual void OnEnable()
|
||||
{
|
||||
TargetSubject.PositionX.OnValueChanged += OnPositionChange;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// On enable we stop listening for changes
|
||||
/// </summary>
|
||||
protected virtual void OnDisable()
|
||||
{
|
||||
TargetSubject.PositionX.OnValueChanged -= OnPositionChange;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7626ba85783411047a182b9352e58a60
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,54 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MoreMountains.Tools
|
||||
{
|
||||
/// <summary>
|
||||
/// 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
|
||||
/// </summary>
|
||||
[AddComponentMenu("")]
|
||||
public class MMObservableDemoObserverAutoSleep : MonoBehaviour
|
||||
{
|
||||
public MMObservableDemoSubject TargetSubject;
|
||||
|
||||
protected virtual void OnSpeedChange()
|
||||
{
|
||||
this.transform.position = this.transform.position.MMSetY(TargetSubject.PositionX.Value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// On awake we start listening for changes
|
||||
/// </summary>
|
||||
protected virtual void Awake()
|
||||
{
|
||||
TargetSubject.PositionX.OnValueChanged += OnSpeedChange;
|
||||
this.enabled = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// On destroy we stop listening for changes
|
||||
/// </summary>
|
||||
protected virtual void OnDestroy()
|
||||
{
|
||||
TargetSubject.PositionX.OnValueChanged -= OnSpeedChange;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// On enable we do nothing
|
||||
/// </summary>
|
||||
protected virtual void OnEnable()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// On disable we do nothing
|
||||
/// </summary>
|
||||
protected virtual void OnDisable()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a97d79031ec706140a9e04a5b21e82f7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,24 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MoreMountains.Tools
|
||||
{
|
||||
/// <summary>
|
||||
/// A test class used to demonstrate how MMObservable works in the MMObservableTest demo scene
|
||||
/// </summary>
|
||||
[AddComponentMenu("")]
|
||||
public class MMObservableDemoSubject : MonoBehaviour
|
||||
{
|
||||
/// a public float we expose, outputting the x position of our object
|
||||
public MMObservable<float> PositionX = new MMObservable<float>();
|
||||
|
||||
/// <summary>
|
||||
/// On Update we update our x position
|
||||
/// </summary>
|
||||
protected virtual void Update()
|
||||
{
|
||||
PositionX.Value = this.transform.position.x;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e6fd774b01b4cbd4e8230b76b6eeda5c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user