diff --git a/README.md b/README.md index fc5332f..0cc1e10 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,7 @@ This template contains the following: | [Cinemachine](https://docs.unity3d.com/Packages/com.unity.cinemachine@latest) | Advanced camera system for dynamic shots. | | [Physics](https://docs.unity3d.com/Manual/PhysicsSection.html) | Physics simulation for 2D and 3D games. | | [ProBuilder](https://docs.unity3d.com/Packages/com.unity.probuilder@latest) | 3D modeling and level design toolset. | +| [R3](https://github.com/Cysharp/R3) | Reactive Extensions for Unity with ReactiveProperty. | | [Rendering: Post-Processing](https://docs.unity3d.com/Packages/com.unity.postprocessing@latest) | Visual effects like color grading and bloom. | | [Rendering: URP](https://docs.unity3d.com/Packages/com.unity.render-pipelines.universal@latest) | Efficient rendering pipeline for various platforms. | | [Text Mesh Pro](https://docs.unity3d.com/Packages/com.unity.textmeshpro@latest) | High-quality text rendering and formatting. | diff --git a/Unity/Assets/Scripts/Runtime/RMC/[MyProject]/Scenes/Scene01_Intro.cs b/Unity/Assets/Scripts/Runtime/RMC/[MyProject]/Scenes/Scene01_Intro.cs index 9d1220a..8ba4208 100644 --- a/Unity/Assets/Scripts/Runtime/RMC/[MyProject]/Scenes/Scene01_Intro.cs +++ b/Unity/Assets/Scripts/Runtime/RMC/[MyProject]/Scenes/Scene01_Intro.cs @@ -1,4 +1,5 @@ using System.Threading.Tasks; +using R3; using RMC.Audio; using RMC.MyProject.UI; using UnityEngine; @@ -33,6 +34,9 @@ public int Score { _score = value; HudUI.ScoreLabel.text = $"Score: {_score:000}/{ScoreMax:000}"; + + // R3 ReactiveProperty demonstration - Update reactive property when score changes + _reactiveScore.Value = _score; } } @@ -107,6 +111,9 @@ private set private bool _isEnabledInput = true; private bool _isPlayerGrounded = false; + // R3 ReactiveProperty demonstration + private ReactiveProperty _reactiveScore = new ReactiveProperty(0); + // Audio private const string PlayerResetAudioClip = "ItemRead01"; private const string GameWinAudioClip = "Music_Win01"; @@ -122,6 +129,12 @@ protected void Start() { Debug.Log($"{GetType().Name}.Start()"); + // R3 ReactiveProperty demonstration - Subscribe to value changes + _reactiveScore.Subscribe(value => + { + Debug.Log($"[R3 Demo] ReactiveScore changed to: {value}"); + }); + // Input _movePlayerInputAction = InputSystem.actions.FindAction("MovePlayer"); _jumpPlayerInputAction = InputSystem.actions.FindAction("JumpPlayer"); @@ -134,6 +147,9 @@ protected void Start() Lives = LivesMax; SetInstructions(); SetTitle(); + + // R3 ReactiveProperty demonstration - Set initial value to trigger subscription + _reactiveScore.Value = 1; } /// diff --git a/Unity/Packages/manifest.json b/Unity/Packages/manifest.json index 07cc287..9016856 100644 --- a/Unity/Packages/manifest.json +++ b/Unity/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.rmc.rmc-audio": "1.8.4", "com.rmc.rmc-core": "1.9.5", "com.rmc.rmc-readme": "1.2.2",