Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Unity/Assets/Scripts/Runtime/RMC.MyProject.Runtime.asmdef
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"references": [
"GUID:75469ad4d38634e559750d17036d5f7c",
"GUID:8d0b5587a0a8ae741afbfe3a79c2872a",
"GUID:9f522e882e6bd48429f616f259fa6318"
"GUID:9f522e882e6bd48429f616f259fa6318",
"R3.Unity"
],
"includePlatforms": [],
"excludePlatforms": [],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Threading.Tasks;
using R3;
using RMC.Audio;
using RMC.MyProject.UI;
using UnityEngine;
Expand Down Expand Up @@ -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;
}
}

Expand Down Expand Up @@ -113,6 +117,9 @@ private set
private const string PlayerJumpAudioClip = "ItemUpdate01";
private const string PlayerMoveAudioClip = "Click01";

// R3 Reactive Property Demo
private ReactiveProperty<int> _reactiveScore = new ReactiveProperty<int>(0);

// Unity Methods ---------------------------------

/// <summary>
Expand All @@ -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");
Expand Down Expand Up @@ -321,6 +334,15 @@ private void PlayAudioClip(string audioClipName)
{
AudioManager.Instance.PlayAudioClip(audioClipName);
}

/// <summary>
/// Clean up resources when the GameObject is destroyed
/// </summary>
protected void OnDestroy()
{
// R3 ReactiveProperty Demo: Dispose of reactive property
_reactiveScore?.Dispose();
}

// Event Handlers --------------------------------

Expand Down
1 change: 1 addition & 0 deletions Unity/Packages/manifest.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down