-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added some basic particle system bindings
- Loading branch information
Showing
3 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
src/Assets/BindingsRx/Bindings/ParticleSystemExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using System; | ||
using BindingsRx.Filters; | ||
using UniRx; | ||
using UnityEngine; | ||
|
||
namespace BindingsRx.Bindings | ||
{ | ||
public static class ParticleSystemExtensions | ||
{ | ||
public static IDisposable BindPlayTo(this ParticleSystem input, IReactiveProperty<bool> property, BindingTypes bindingType = BindingTypes.Default, params IFilter<bool>[] filters) | ||
{ | ||
return GenericBindings.Bind(() => input.isPlaying, x => { | ||
if (x) { input.Play(); } | ||
else { input.Stop(); } | ||
}, property, bindingType, filters).AddTo(input); | ||
} | ||
|
||
public static IDisposable BindPlayTo(this ParticleSystem input, Func<bool> getter, Action<bool> setter, BindingTypes bindingType = BindingTypes.Default, params IFilter<bool>[] filters) | ||
{ | ||
return GenericBindings.Bind(() => input.isPlaying, x => | ||
{ | ||
if (x) { input.Play(); } | ||
else { input.Stop(); } | ||
}, getter, setter, bindingType, filters).AddTo(input); | ||
} | ||
|
||
public static IDisposable BindTimeTo(this ParticleSystem input, IReactiveProperty<float> property, BindingTypes bindingType = BindingTypes.Default, params IFilter<float>[] filters) | ||
{ return GenericBindings.Bind(() => input.time, x => input.time = x, property, bindingType, filters).AddTo(input); } | ||
|
||
public static IDisposable BindTimeTo(this ParticleSystem input, Func<float> getter, Action<float> setter, BindingTypes bindingType = BindingTypes.Default, params IFilter<float>[] filters) | ||
{ return GenericBindings.Bind(() => input.time, x => input.time = x, getter, setter, bindingType, filters).AddTo(input); } | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
src/Assets/BindingsRx/Bindings/ParticleSystemExtensions.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters