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
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 @@ -27,12 +28,12 @@ public int Score
{
get
{
return _score;
return _reactiveScore.Value;
}
set
{
_score = value;
HudUI.ScoreLabel.text = $"Score: {_score:000}/{ScoreMax:000}";
_reactiveScore.Value = value;
HudUI.ScoreLabel.text = $"Score: {_reactiveScore.Value:000}/{ScoreMax:000}";
}
}

Expand Down Expand Up @@ -102,11 +103,13 @@ private set
private InputAction _toggleThemeInputAction;

// Data
private int _score = 0;
private int _lives = 0;
private bool _isEnabledInput = true;
private bool _isPlayerGrounded = false;

// R3 ReactiveProperty demonstration
private readonly ReactiveProperty<int> _reactiveScore = new ReactiveProperty<int>(0);

// Audio
private const string PlayerResetAudioClip = "ItemRead01";
private const string GameWinAudioClip = "Music_Win01";
Expand All @@ -122,6 +125,12 @@ protected void Start()
{
Debug.Log($"{GetType().Name}.Start()");

// R3 ReactiveProperty demonstration - Subscribe to score changes
_reactiveScore.Subscribe(newScore =>
{
Debug.Log($"[R3 Demo] Score changed to: {newScore}");
}).AddTo(this);

// Input
_movePlayerInputAction = InputSystem.actions.FindAction("MovePlayer");
_jumpPlayerInputAction = InputSystem.actions.FindAction("JumpPlayer");
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