From 662a30ae88938be42661f7450a25c159e2a4428e Mon Sep 17 00:00:00 2001 From: KOGA Mitsuhiro Date: Tue, 13 Feb 2024 21:26:01 +0900 Subject: [PATCH 1/5] Add: R3 and dependencies dll --- src/LitMotion/Packages/manifest.json | 16 ++- src/LitMotion/Packages/packages-lock.json | 98 +++++++++++++++++++ .../PackageManagerSettings.asset | 18 +++- 3 files changed, 127 insertions(+), 5 deletions(-) diff --git a/src/LitMotion/Packages/manifest.json b/src/LitMotion/Packages/manifest.json index 46d95a03..25ca8242 100644 --- a/src/LitMotion/Packages/manifest.json +++ b/src/LitMotion/Packages/manifest.json @@ -1,5 +1,6 @@ { "dependencies": { + "com.cysharp.r3": "https://github.com/Cysharp/R3.git?path=src/R3.Unity/Assets/R3.Unity", "com.cysharp.unitask": "https://github.com/Cysharp/UniTask.git?path=src/UniTask/Assets/Plugins/UniTask", "com.cysharp.zstring": "https://github.com/Cysharp/ZString.git?path=src/ZString.Unity/Assets/Scripts/ZString", "com.neuecc.unirx": "https://github.com/neuecc/UniRx.git?path=Assets/Plugins/UniRx/Scripts", @@ -12,6 +13,10 @@ "com.unity.ugui": "2.0.0", "com.unity.visualeffectgraph": "16.0.4", "com.unity.visualscripting": "1.8.0", + "org.nuget.microsoft.bcl.timeprovider": "8.0.1", + "org.nuget.r3": "0.1.21", + "org.nuget.system.componentmodel.annotations": "5.0.0", + "org.nuget.system.threading.channels": "8.0.0", "com.unity.modules.accessibility": "1.0.0", "com.unity.modules.ai": "1.0.0", "com.unity.modules.androidjni": "1.0.0", @@ -44,5 +49,14 @@ "com.unity.modules.vr": "1.0.0", "com.unity.modules.wind": "1.0.0", "com.unity.modules.xr": "1.0.0" - } + }, + "scopedRegistries": [ + { + "name": "Unity NuGet", + "url": "https://unitynuget-registry.azurewebsites.net", + "scopes": [ + "org.nuget" + ] + } + ] } diff --git a/src/LitMotion/Packages/packages-lock.json b/src/LitMotion/Packages/packages-lock.json index 1cbf9b9d..e7aefad4 100644 --- a/src/LitMotion/Packages/packages-lock.json +++ b/src/LitMotion/Packages/packages-lock.json @@ -1,5 +1,14 @@ { "dependencies": { + "com.cysharp.r3": { + "version": "https://github.com/Cysharp/R3.git?path=src/R3.Unity/Assets/R3.Unity", + "depth": 0, + "source": "git", + "dependencies": { + "com.unity.modules.imgui": "1.0.0" + }, + "hash": "3bf68621f9af5cacf5a1f1e2920a1f89a08b6c06" + }, "com.cysharp.unitask": { "version": "https://github.com/Cysharp/UniTask.git?path=src/UniTask/Assets/Plugins/UniTask", "depth": 0, @@ -257,6 +266,95 @@ }, "url": "https://packages.unity.com" }, + "org.nuget.microsoft.bcl.asyncinterfaces": { + "version": "8.0.0", + "depth": 1, + "source": "registry", + "dependencies": { + "org.nuget.system.threading.tasks.extensions": "4.5.4" + }, + "url": "https://unitynuget-registry.azurewebsites.net" + }, + "org.nuget.microsoft.bcl.timeprovider": { + "version": "8.0.1", + "depth": 0, + "source": "registry", + "dependencies": { + "org.nuget.microsoft.bcl.asyncinterfaces": "8.0.0" + }, + "url": "https://unitynuget-registry.azurewebsites.net" + }, + "org.nuget.r3": { + "version": "0.1.21", + "depth": 0, + "source": "registry", + "dependencies": { + "org.nuget.microsoft.bcl.timeprovider": "8.0.0", + "org.nuget.system.buffers": "4.5.1", + "org.nuget.system.componentmodel.annotations": "5.0.0", + "org.nuget.system.memory": "4.5.5", + "org.nuget.system.runtime.compilerservices.unsafe": "6.0.0", + "org.nuget.system.threading.channels": "8.0.0" + }, + "url": "https://unitynuget-registry.azurewebsites.net" + }, + "org.nuget.system.buffers": { + "version": "4.5.1", + "depth": 1, + "source": "registry", + "dependencies": {}, + "url": "https://unitynuget-registry.azurewebsites.net" + }, + "org.nuget.system.componentmodel.annotations": { + "version": "5.0.0", + "depth": 0, + "source": "registry", + "dependencies": {}, + "url": "https://unitynuget-registry.azurewebsites.net" + }, + "org.nuget.system.memory": { + "version": "4.5.5", + "depth": 1, + "source": "registry", + "dependencies": { + "org.nuget.system.buffers": "4.5.1", + "org.nuget.system.numerics.vectors": "4.4.0", + "org.nuget.system.runtime.compilerservices.unsafe": "4.5.3" + }, + "url": "https://unitynuget-registry.azurewebsites.net" + }, + "org.nuget.system.numerics.vectors": { + "version": "4.4.0", + "depth": 2, + "source": "registry", + "dependencies": {}, + "url": "https://unitynuget-registry.azurewebsites.net" + }, + "org.nuget.system.runtime.compilerservices.unsafe": { + "version": "6.0.0", + "depth": 1, + "source": "registry", + "dependencies": {}, + "url": "https://unitynuget-registry.azurewebsites.net" + }, + "org.nuget.system.threading.channels": { + "version": "8.0.0", + "depth": 0, + "source": "registry", + "dependencies": { + "org.nuget.system.threading.tasks.extensions": "4.5.4" + }, + "url": "https://unitynuget-registry.azurewebsites.net" + }, + "org.nuget.system.threading.tasks.extensions": { + "version": "4.5.4", + "depth": 1, + "source": "registry", + "dependencies": { + "org.nuget.system.runtime.compilerservices.unsafe": "4.5.3" + }, + "url": "https://unitynuget-registry.azurewebsites.net" + }, "com.unity.modules.accessibility": { "version": "1.0.0", "depth": 0, diff --git a/src/LitMotion/ProjectSettings/PackageManagerSettings.asset b/src/LitMotion/ProjectSettings/PackageManagerSettings.asset index 112a053b..deb8287e 100644 --- a/src/LitMotion/ProjectSettings/PackageManagerSettings.asset +++ b/src/LitMotion/ProjectSettings/PackageManagerSettings.asset @@ -13,11 +13,12 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: m_EnablePreReleasePackages: 0 - m_EnablePackageDependencies: 0 m_AdvancedSettingsExpanded: 1 m_ScopedRegistriesSettingsExpanded: 1 m_SeeAllPackageVersions: 0 + m_DismissPreviewPackagesInUse: 0 oneTimeWarningShown: 0 + oneTimeDeprecatedPopUpShown: 0 m_Registries: - m_Id: main m_Name: @@ -25,11 +26,20 @@ MonoBehaviour: m_Scopes: [] m_IsDefault: 1 m_Capabilities: 7 - m_UserSelectedRegistryName: + m_ConfigSource: 0 + - m_Id: scoped:project:Unity NuGet + m_Name: Unity NuGet + m_Url: https://unitynuget-registry.azurewebsites.net + m_Scopes: + - org.nuget + m_IsDefault: 0 + m_Capabilities: 0 + m_ConfigSource: 4 + m_UserSelectedRegistryName: Unity NuGet m_UserAddingNewScopedRegistry: 0 m_RegistryInfoDraft: m_Modified: 0 m_ErrorMessage: - m_UserModificationsInstanceId: -830 - m_OriginalInstanceId: -832 + m_UserModificationsInstanceId: -852 + m_OriginalInstanceId: -854 m_LoadAssets: 0 From ae01351b70b7a53c107c29b0ac01529b96e62aec Mon Sep 17 00:00:00 2001 From: KOGA Mitsuhiro Date: Tue, 13 Feb 2024 21:26:10 +0900 Subject: [PATCH 2/5] Add: support R3.Observable --- README.md | 1 + README_JA.md | 1 + .../Assets/LitMotion/Runtime/External/R3.meta | 8 +++ .../External/R3/LitMotionR3Extensions.cs | 54 ++++++++++++++++++ .../External/R3/LitMotionR3Extensions.cs.meta | 11 ++++ .../Assets/LitMotion/Runtime/LitMotion.asmdef | 10 ++++ .../Tests/Runtime/ExternalExtensions.cs | 25 +++++++++ .../Tests/Runtime/ExternalExtensions.cs.meta | 3 + .../Runtime/LitMotion.Tests.Runtime.asmdef | 8 ++- .../Assets/LitMotion/Tests/Runtime/R3Test.cs | 56 +++++++++++++++++++ .../LitMotion/Tests/Runtime/R3Test.cs.meta | 3 + .../LitMotion/Tests/Runtime/UniRxTest.cs | 4 +- 12 files changed, 181 insertions(+), 3 deletions(-) create mode 100644 src/LitMotion/Assets/LitMotion/Runtime/External/R3.meta create mode 100644 src/LitMotion/Assets/LitMotion/Runtime/External/R3/LitMotionR3Extensions.cs create mode 100644 src/LitMotion/Assets/LitMotion/Runtime/External/R3/LitMotionR3Extensions.cs.meta create mode 100644 src/LitMotion/Assets/LitMotion/Tests/Runtime/ExternalExtensions.cs create mode 100644 src/LitMotion/Assets/LitMotion/Tests/Runtime/ExternalExtensions.cs.meta create mode 100644 src/LitMotion/Assets/LitMotion/Tests/Runtime/R3Test.cs create mode 100644 src/LitMotion/Assets/LitMotion/Tests/Runtime/R3Test.cs.meta diff --git a/README.md b/README.md index f4e40d20..82e0944e 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,7 @@ The full version of documentation can be found [here](https://annulusgames.githu - Character animation for TextMeshPro text. - Motion Tracker Window for monitoring motions in progress. - Convert to Observables using UniRx. +- Convert to Observables using R3. - Supports async/await via UniTask. - Extend types using `IMotionOptions` and `IMotionAdapter`. diff --git a/README_JA.md b/README_JA.md index ade5420b..42aa8e62 100644 --- a/README_JA.md +++ b/README_JA.md @@ -31,6 +31,7 @@ LitMotionは[Magic Tween](https://github.com/AnnulusGames/MagicTween)に続い - TextMeshProのテキストを文字ごとにアニメーション可能 - MotionTrackerウィンドウによる動作中のモーションの追跡 - UniRxを利用したObservableへの変換 +- R3を利用したObservableへの変換 - UniTaskを利用したasync/await対応 - `IMotionOptions`と`IMotionAdapter`を用いた型の拡張 diff --git a/src/LitMotion/Assets/LitMotion/Runtime/External/R3.meta b/src/LitMotion/Assets/LitMotion/Runtime/External/R3.meta new file mode 100644 index 00000000..85f0cf12 --- /dev/null +++ b/src/LitMotion/Assets/LitMotion/Runtime/External/R3.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8e2e973abce4a31438b6901111ed7a03 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/LitMotion/Assets/LitMotion/Runtime/External/R3/LitMotionR3Extensions.cs b/src/LitMotion/Assets/LitMotion/Runtime/External/R3/LitMotionR3Extensions.cs new file mode 100644 index 00000000..bf9d7082 --- /dev/null +++ b/src/LitMotion/Assets/LitMotion/Runtime/External/R3/LitMotionR3Extensions.cs @@ -0,0 +1,54 @@ +#if LITMOTION_SUPPORT_R3 +using R3; + +namespace LitMotion +{ + public static class LitMotionR3Extensions + { + /// + /// Create the motion as Observable. + /// + /// The type of value to animate + /// The type of special parameters given to the motion data + /// The type of adapter that support value animation + /// This builder + /// Observable of the created motion. + public static Observable ToObservable(this MotionBuilder builder) + where TValue : unmanaged + where TOptions : unmanaged, IMotionOptions + where TAdapter : unmanaged, IMotionAdapter + { + var subject = new Subject(); + var callbacks = builder.BuildCallbackData(subject, static (x, subject) => subject.OnNext(x)); + callbacks.OnCompleteAction += () => subject.OnCompleted(); + callbacks.OnCancelAction += () => subject.OnCompleted(); + var scheduler = builder.buffer.Scheduler; + var entity = builder.BuildMotionData(); + + builder.Schedule(scheduler, ref entity, ref callbacks); + return subject; + } + + /// + /// Create a motion data and bind it to ReactiveProperty. + /// + /// The type of value to animate + /// The type of special parameters given to the motion data + /// The type of adapter that support value animation + /// This builder + /// Target object that implements IProgress + /// Handle of the created motion data. + public static MotionHandle BindToReactiveProperty(this MotionBuilder builder, ReactiveProperty reactiveProperty) + where TValue : unmanaged + where TOptions : unmanaged, IMotionOptions + where TAdapter : unmanaged, IMotionAdapter + { + Error.IsNull(reactiveProperty); + return builder.BindWithState(reactiveProperty, static (x, target) => + { + target.Value = x; + }); + } + } +} +#endif diff --git a/src/LitMotion/Assets/LitMotion/Runtime/External/R3/LitMotionR3Extensions.cs.meta b/src/LitMotion/Assets/LitMotion/Runtime/External/R3/LitMotionR3Extensions.cs.meta new file mode 100644 index 00000000..4390118f --- /dev/null +++ b/src/LitMotion/Assets/LitMotion/Runtime/External/R3/LitMotionR3Extensions.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 78c4cfe16961d754ca0e1cd47cf6cccf +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/LitMotion/Assets/LitMotion/Runtime/LitMotion.asmdef b/src/LitMotion/Assets/LitMotion/Runtime/LitMotion.asmdef index 297eda30..4793901e 100644 --- a/src/LitMotion/Assets/LitMotion/Runtime/LitMotion.asmdef +++ b/src/LitMotion/Assets/LitMotion/Runtime/LitMotion.asmdef @@ -26,6 +26,16 @@ "name": "com.neuecc.unirx", "expression": "", "define": "LITMOTION_SUPPORT_UNIRX" + }, + { + "name": "com.cysharp.r3", + "expression": "", + "define": "LITMOTION_SUPPORT_R3" + }, + { + "name": "org.nuget.r3", + "expression": "", + "define": "LITMOTION_SUPPORT_R3" } ], "noEngineReferences": false diff --git a/src/LitMotion/Assets/LitMotion/Tests/Runtime/ExternalExtensions.cs b/src/LitMotion/Assets/LitMotion/Tests/Runtime/ExternalExtensions.cs new file mode 100644 index 00000000..70b1131f --- /dev/null +++ b/src/LitMotion/Assets/LitMotion/Tests/Runtime/ExternalExtensions.cs @@ -0,0 +1,25 @@ +namespace LitMotion.Tests.Runtime +{ + static class ExternalExtensions + { +#if LITMOTION_TEST_R3 + public static R3.Observable ToR3Observable(this MotionBuilder builder) + where TValue : unmanaged + where TOptions : unmanaged, IMotionOptions + where TAdapter : unmanaged, IMotionAdapter + { + return LitMotionR3Extensions.ToObservable(builder); + } +#endif + +#if LITMOTION_TEST_UNIRX + public static System.IObservable ToRxObservable(this MotionBuilder builder) + where TValue : unmanaged + where TOptions : unmanaged, IMotionOptions + where TAdapter : unmanaged, IMotionAdapter + { + return LitMotionUniRxExtensions.ToObservable(builder); + } +#endif + } +} \ No newline at end of file diff --git a/src/LitMotion/Assets/LitMotion/Tests/Runtime/ExternalExtensions.cs.meta b/src/LitMotion/Assets/LitMotion/Tests/Runtime/ExternalExtensions.cs.meta new file mode 100644 index 00000000..038e55ec --- /dev/null +++ b/src/LitMotion/Assets/LitMotion/Tests/Runtime/ExternalExtensions.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 850a216eea3a43c68cee68a9d3d41e7f +timeCreated: 1707117147 \ No newline at end of file diff --git a/src/LitMotion/Assets/LitMotion/Tests/Runtime/LitMotion.Tests.Runtime.asmdef b/src/LitMotion/Assets/LitMotion/Tests/Runtime/LitMotion.Tests.Runtime.asmdef index a4f1db65..25569e73 100644 --- a/src/LitMotion/Assets/LitMotion/Tests/Runtime/LitMotion.Tests.Runtime.asmdef +++ b/src/LitMotion/Assets/LitMotion/Tests/Runtime/LitMotion.Tests.Runtime.asmdef @@ -15,7 +15,8 @@ "allowUnsafeCode": false, "overrideReferences": true, "precompiledReferences": [ - "nunit.framework.dll" + "nunit.framework.dll", + "R3.dll" ], "autoReferenced": false, "defineConstraints": [ @@ -31,6 +32,11 @@ "name": "com.neuecc.unirx", "expression": "", "define": "LITMOTION_TEST_UNIRX" + }, + { + "name": "com.cysharp.r3", + "expression": "", + "define": "LITMOTION_TEST_R3" } ], "noEngineReferences": false diff --git a/src/LitMotion/Assets/LitMotion/Tests/Runtime/R3Test.cs b/src/LitMotion/Assets/LitMotion/Tests/Runtime/R3Test.cs new file mode 100644 index 00000000..ab024842 --- /dev/null +++ b/src/LitMotion/Assets/LitMotion/Tests/Runtime/R3Test.cs @@ -0,0 +1,56 @@ +#if LITMOTION_TEST_R3 +using System; +using System.Collections; +using UnityEngine; +using UnityEngine.TestTools; +using R3; +using NUnit.Framework; + +namespace LitMotion.Tests.Runtime +{ + public class R3Test + { + readonly CompositeDisposable disposables = new(); + + [OneTimeTearDown] + public void OneTimeTearDown() + { + disposables.Dispose(); + } + + [UnityTest] + public IEnumerator Test_ToObservable() + { + bool completed = false; + LMotion.Create(0f, 10f, 2f) + .WithOnComplete(() => completed = true) + .ToR3Observable() + .Subscribe(x => Debug.Log(x)) + .AddTo(disposables); + while (!completed) yield return null; + } + + [UnityTest] + public IEnumerator Test_BindToReactiveProperty() + { + var reactiveProperty = new ReactiveProperty(); + reactiveProperty.AddTo(disposables); + + bool completed = false; + LMotion.Create(0f, 10f, 2f) + .WithOnComplete(() => completed = true) + .BindToReactiveProperty(reactiveProperty) + .ToDisposable() + .AddTo(disposables); + + reactiveProperty.Subscribe(x => + { + Debug.Log(x); + }) + .AddTo(disposables); + + while (!completed) yield return null; + } + } +} +#endif \ No newline at end of file diff --git a/src/LitMotion/Assets/LitMotion/Tests/Runtime/R3Test.cs.meta b/src/LitMotion/Assets/LitMotion/Tests/Runtime/R3Test.cs.meta new file mode 100644 index 00000000..84e0a2bc --- /dev/null +++ b/src/LitMotion/Assets/LitMotion/Tests/Runtime/R3Test.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: a3294b2d86c549029554aab3acae47b7 +timeCreated: 1706465161 \ No newline at end of file diff --git a/src/LitMotion/Assets/LitMotion/Tests/Runtime/UniRxTest.cs b/src/LitMotion/Assets/LitMotion/Tests/Runtime/UniRxTest.cs index 3bdb9c0f..baed14e0 100644 --- a/src/LitMotion/Assets/LitMotion/Tests/Runtime/UniRxTest.cs +++ b/src/LitMotion/Assets/LitMotion/Tests/Runtime/UniRxTest.cs @@ -23,8 +23,8 @@ public IEnumerator Test_ToObservable() { bool completed = false; LMotion.Create(0f, 10f, 2f) - .WithOnComplete(() => completed = true) - .ToObservable() + .WithOnComplete(() => completed = true) + .ToRxObservable() .Subscribe(x => Debug.Log(x)) .AddTo(disposables); while (!completed) yield return null; From 998772026bd580c2167709d9f50ba70ee3b54719 Mon Sep 17 00:00:00 2001 From: KOGA Mitsuhiro Date: Mon, 19 Feb 2024 23:04:04 +0900 Subject: [PATCH 3/5] Fix: integration docs --- docs/articles/en/integration-unirx.md | 2 +- docs/articles/en/integration-unitask.md | 2 +- docs/articles/ja/integration-unirx.md | 2 +- docs/articles/ja/integration-unitask.md | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/articles/en/integration-unirx.md b/docs/articles/en/integration-unirx.md index cf257b63..a9b0b3df 100644 --- a/docs/articles/en/integration-unirx.md +++ b/docs/articles/en/integration-unirx.md @@ -2,7 +2,7 @@ By integrating [UniRx](https://github.com/neuecc/UniRx) into your project, it adds extension methods compatible with Reactive Extensions (Rx). -If you have installed UniRx via the Package Manager, the following functionality will be automatically added. However, if you have imported UniRx via a unitypackage or similar method, you'll need to add `LITMOTION_UNIRX_SUPPORT` to `Settings > Player > Scripting Define Symbols`. +If you have installed UniRx via the Package Manager, the following functionality will be automatically added. However, if you have imported UniRx via a unitypackage or similar method, you'll need to add `LITMOTION_SUPPORT_UNIRX` to `Settings > Player > Scripting Define Symbols`. ### Creating Motion as an Observable diff --git a/docs/articles/en/integration-unitask.md b/docs/articles/en/integration-unitask.md index 4c0c6bf3..ab0c8a35 100644 --- a/docs/articles/en/integration-unitask.md +++ b/docs/articles/en/integration-unitask.md @@ -2,7 +2,7 @@ Introducing [UniTask](https://github.com/Cysharp/UniTask) into your project adds extension methods that allow motion waiting to be compatible with async/await. -If you have installed UniTask via the Package Manager, the following functionality will be automatically added. However, if you have imported UniTask via a unitypackage or similar method, you'll need to add `LITMOTION_UNITASK_SUPPORT` to `Settings > Player > Scripting Define Symbols`. +If you have installed UniTask via the Package Manager, the following functionality will be automatically added. However, if you have imported UniTask via a unitypackage or similar method, you'll need to add `LITMOTION_SUPPORT_UNITASK` to `Settings > Player > Scripting Define Symbols`. ### Waiting for Motion diff --git a/docs/articles/ja/integration-unirx.md b/docs/articles/ja/integration-unirx.md index 0c6d1116..447be5cf 100644 --- a/docs/articles/ja/integration-unirx.md +++ b/docs/articles/ja/integration-unirx.md @@ -2,7 +2,7 @@ プロジェクトに[UniRx](https://github.com/neuecc/UniRx)を導入することでReactive Extensions(Rx)に対応した拡張メソッドが追加されます。 -UniRxをPackage Managerから導入した場合は自動で以下の機能が追加されます。unitypackage等で導入した場合は、`Project Settings > Player > Scripting Define Symbols`に`LITMOTION_UNIRX_SUPPORT`を追加する必要があります。 +UniRxをPackage Managerから導入した場合は自動で以下の機能が追加されます。unitypackage等で導入した場合は、`Project Settings > Player > Scripting Define Symbols`に`LITMOTION_SUPPORT_UNIRX`を追加する必要があります。 ### モーションをObservableとして作成 diff --git a/docs/articles/ja/integration-unitask.md b/docs/articles/ja/integration-unitask.md index 8c12ba3e..7dda47cc 100644 --- a/docs/articles/ja/integration-unitask.md +++ b/docs/articles/ja/integration-unitask.md @@ -2,7 +2,7 @@ プロジェクトに[UniTask](https://github.com/Cysharp/UniTask)を導入することで、モーションの待機をasync/awaitに対応させる拡張メソッドが追加されます。 -UniTaskをPackage Managerから導入した場合は自動で以下の機能が追加されます。unitypackage等で導入した場合は、`Project Settings > Player > Scripting Define Symbols`に`LITMOTION_UNITASK_SUPPORT`を追加する必要があります。 +UniTaskをPackage Managerから導入した場合は自動で以下の機能が追加されます。unitypackage等で導入した場合は、`Project Settings > Player > Scripting Define Symbols`に`LITMOTION_SUPPORT_UNITASK`を追加する必要があります。 ### モーションの待機 @@ -20,4 +20,4 @@ await LMotion.Create(0f, 10f, 2f).Bind(x => Debug.Log(x)) .ToUniTask(cts.Token); ``` -CancellationTokenを渡すと、非同期処理がキャンセルされた際に自動でモーションの再生もキャンセルされます。 \ No newline at end of file +CancellationTokenを渡すと、非同期処理がキャンセルされた際に自動でモーションの再生もキャンセルされます。 From 1105e0bf356201923b2ffd621aba301b61d3da3c Mon Sep 17 00:00:00 2001 From: KOGA Mitsuhiro Date: Mon, 19 Feb 2024 23:02:18 +0900 Subject: [PATCH 4/5] Add: integration-r3 docs --- docs/articles/en/integration-r3.md | 28 ++++++++++++++++++++++++++++ docs/articles/en/toc.yml | 4 +++- docs/articles/ja/integration-r3.md | 28 ++++++++++++++++++++++++++++ docs/articles/ja/toc.yml | 4 +++- 4 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 docs/articles/en/integration-r3.md create mode 100644 docs/articles/ja/integration-r3.md diff --git a/docs/articles/en/integration-r3.md b/docs/articles/en/integration-r3.md new file mode 100644 index 00000000..45fdfc38 --- /dev/null +++ b/docs/articles/en/integration-r3.md @@ -0,0 +1,28 @@ +# R3 + +By integrating [R3](https://github.com/Cysharp/R3) into your project, it adds extension methods compatible with Reactive Extensions (Rx). + +If you have installed R3 via the Package Manager, the following functionality will be automatically added. However, if you have imported UniRx via a unitypackage or similar method, you'll need to add `LITMOTION_SUPPORT_R3` to `Settings > Player > Scripting Define Symbols`. + +### Creating Motion as an Observable + +You can create motion as an `IObservable` using the `ToObservable()` method: + +```cs +var observable = LMotion.Create(0f, 5f, 2f).ToObservable(); +observable.Subscribe(x => +{ + Debug.Log(x); +}) +.AddTo(gameObject); +``` + +### Binding to ReactiveProperty + +There's a provided extension method to bind the created motion to a `ReactiveProperty`: + +```cs +var reactiveProperty = new ReactiveProperty(); +LMotion.Create(0f, 10f, 2f) + .BindToReactiveProperty(reactiveProperty); +``` diff --git a/docs/articles/en/toc.yml b/docs/articles/en/toc.yml index d49f8ea6..37ac7e7a 100644 --- a/docs/articles/en/toc.yml +++ b/docs/articles/en/toc.yml @@ -47,6 +47,8 @@ href: motion-tracker.md - name: Integrations +- name: R3 + href: integration-r3.md - name: UniRx href: integration-unirx.md - name: UniTask @@ -56,4 +58,4 @@ - name: Concepts - name: Design Philosophy - href: design-philosophy.md \ No newline at end of file + href: design-philosophy.md diff --git a/docs/articles/ja/integration-r3.md b/docs/articles/ja/integration-r3.md new file mode 100644 index 00000000..aab05541 --- /dev/null +++ b/docs/articles/ja/integration-r3.md @@ -0,0 +1,28 @@ +# R3 + +プロジェクトに[R3](https://github.com/Cysharp/R3)を導入することでReactive Extensions(Rx)に対応した拡張メソッドが追加されます。 + +R3をPackage Managerから導入した場合は自動で以下の機能が追加されます。unitypackage等で導入した場合は、`Project Settings > Player > Scripting Define Symbols`に`LITMOTION_SUPPORT_R3`を追加する必要があります。 + +### モーションをObservableとして作成 + +`ToObservable()`を使用することで、モーションを`IObservable`として作成できます。 + +```cs +var observable = LMotion.Create(0f, 5f, 2f).ToObservable(); +observable.Subscribe(x => +{ + Debug.Log(x); +}) +.AddTo(gameObject); +``` + +### ReactivePropertyへバインド + +作成したモーションを`ReactiveProperty`にバインドする拡張メソッドが用意されています。 + +```cs +var reactiveProperty = new ReactiveProperty(); +LMotion.Create(0f, 10f, 2f) + .BindToReactiveProperty(reactiveProperty); +``` diff --git a/docs/articles/ja/toc.yml b/docs/articles/ja/toc.yml index c97dc9b3..44c4082b 100644 --- a/docs/articles/ja/toc.yml +++ b/docs/articles/ja/toc.yml @@ -47,6 +47,8 @@ href: motion-tracker.md - name: Integrations +- name: R3 + href: integration-r3.md - name: UniRx href: integration-unirx.md - name: UniTask @@ -56,4 +58,4 @@ - name: Concepts - name: 設計思想 - href: design-philosophy.md \ No newline at end of file + href: design-philosophy.md From cc31b1687ec39a87f575fedf6fc8fe7c1741c95e Mon Sep 17 00:00:00 2001 From: KOGA Mitsuhiro Date: Tue, 13 Feb 2024 23:46:21 +0900 Subject: [PATCH 5/5] Update: R3 --- src/LitMotion/Packages/manifest.json | 2 +- src/LitMotion/Packages/packages-lock.json | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/LitMotion/Packages/manifest.json b/src/LitMotion/Packages/manifest.json index 25ca8242..9286d41c 100644 --- a/src/LitMotion/Packages/manifest.json +++ b/src/LitMotion/Packages/manifest.json @@ -14,7 +14,7 @@ "com.unity.visualeffectgraph": "16.0.4", "com.unity.visualscripting": "1.8.0", "org.nuget.microsoft.bcl.timeprovider": "8.0.1", - "org.nuget.r3": "0.1.21", + "org.nuget.r3": "1.1.10", "org.nuget.system.componentmodel.annotations": "5.0.0", "org.nuget.system.threading.channels": "8.0.0", "com.unity.modules.accessibility": "1.0.0", diff --git a/src/LitMotion/Packages/packages-lock.json b/src/LitMotion/Packages/packages-lock.json index e7aefad4..ddc51ce2 100644 --- a/src/LitMotion/Packages/packages-lock.json +++ b/src/LitMotion/Packages/packages-lock.json @@ -7,7 +7,7 @@ "dependencies": { "com.unity.modules.imgui": "1.0.0" }, - "hash": "3bf68621f9af5cacf5a1f1e2920a1f89a08b6c06" + "hash": "f0d7a6ee7f8a31dfeef3e25f120d4e2e55ecbdbe" }, "com.cysharp.unitask": { "version": "https://github.com/Cysharp/UniTask.git?path=src/UniTask/Assets/Plugins/UniTask", @@ -285,7 +285,7 @@ "url": "https://unitynuget-registry.azurewebsites.net" }, "org.nuget.r3": { - "version": "0.1.21", + "version": "1.1.10", "depth": 0, "source": "registry", "dependencies": {