Skip to content

Commit

Permalink
Added some basic particle system bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
grofit committed Mar 15, 2017
1 parent c606e81 commit 165d6df
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/Assets/BindingsRx/Bindings/ParticleSystemExtensions.cs
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); }
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/src.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
<ItemGroup>
<Compile Include="Assets\BindingsRx\Bindings\AnimatorExtensions.cs" />
<Compile Include="Assets\BindingsRx\Bindings\MaterialExtensions.cs" />
<Compile Include="Assets\BindingsRx\Bindings\ParticleSystemExtensions.cs" />
<Compile Include="Assets\BindingsRx\BindingTypes.cs" />
<Compile Include="Assets\BindingsRx\Convertors\IConvertor.cs" />
<Compile Include="Assets\BindingsRx\Convertors\IntConvertor.cs" />
Expand Down

0 comments on commit 165d6df

Please sign in to comment.