diff --git a/Unity/Assets/Scripts/Runtime/RMC.MyProject.Runtime.asmdef b/Unity/Assets/Scripts/Runtime/RMC.MyProject.Runtime.asmdef index 216cfc5..a9c19cf 100644 --- a/Unity/Assets/Scripts/Runtime/RMC.MyProject.Runtime.asmdef +++ b/Unity/Assets/Scripts/Runtime/RMC.MyProject.Runtime.asmdef @@ -4,7 +4,8 @@ "references": [ "GUID:75469ad4d38634e559750d17036d5f7c", "GUID:8d0b5587a0a8ae741afbfe3a79c2872a", - "GUID:9f522e882e6bd48429f616f259fa6318" + "GUID:9f522e882e6bd48429f616f259fa6318", + "R3.Unity" ], "includePlatforms": [], "excludePlatforms": [], 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..acb915b 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 Demo: Update reactive score + _reactiveScore.Value = _score; } } @@ -113,6 +117,9 @@ private set private const string PlayerJumpAudioClip = "ItemUpdate01"; private const string PlayerMoveAudioClip = "Click01"; + // R3 Reactive Property Demo + private ReactiveProperty _reactiveScore = new ReactiveProperty(0); + // Unity Methods --------------------------------- /// @@ -122,6 +129,12 @@ protected void Start() { Debug.Log($"{GetType().Name}.Start()"); + // R3 ReactiveProperty Demo: Subscribe to reactive score changes + _reactiveScore.Subscribe(score => + { + Debug.Log($"[R3 Demo] Reactive Score changed to: {score}"); + }); + // Input _movePlayerInputAction = InputSystem.actions.FindAction("MovePlayer"); _jumpPlayerInputAction = InputSystem.actions.FindAction("JumpPlayer"); @@ -321,6 +334,15 @@ private void PlayAudioClip(string audioClipName) { AudioManager.Instance.PlayAudioClip(audioClipName); } + + /// + /// Clean up resources when the GameObject is destroyed + /// + protected void OnDestroy() + { + // R3 ReactiveProperty Demo: Dispose of reactive property + _reactiveScore?.Dispose(); + } // Event Handlers -------------------------------- 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",