Files
edmand46 6d115f158e Server-side scenario execution: new Rudder.Core.dll, realtime/planstore glue removed
- Rudder.Core.dll rebuilt from csharp-sdk effects rewrite (96,768 bytes)
- Realtime/ adapters, UnityRealtimeTransportFactory, UnityPlanStateStore,
  UnityPlanScheduler, WebGL jslib and RealtimeUrl config deleted (with .meta)
- Scenarios sample rewired to client.Effects; samples login path updated
- AGENTS.md/README/CHANGELOG/package docs + agent skill updated; realtime.md skill doc removed
2026-09-04 14:23:38 +03:00

61 lines
1.8 KiB
C#

using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using RudderSdk.Unity;
namespace RudderSdk.Unity.Samples
{
public class RemoteConfigSample : MonoBehaviour
{
[SerializeField] string nickname = "Player";
[SerializeField] string region = "global";
[SerializeField] string language = "en";
[SerializeField] string roundSecondsKey = "demo_round_seconds";
[SerializeField] string playerSpeedKey = "demo_player_speed";
readonly SamplePage _page = new SamplePage(
"Remote Config",
"Load the project's remote config cache, then read typed values with fallbacks.");
void Start()
{
_page.Run(this, async () =>
{
await Rudder.Initialize().Auth.LoginWithDeviceAsync(region, language, nickname);
_page.Log("Signed in");
await Load();
});
}
void OnGUI()
{
_page.Draw(() =>
{
if (_page.Button("Reload"))
_page.Run(this, Load);
});
}
async Task Load()
{
var client = Rudder.Initialize();
_page.Log("RemoteConfig.LoadAsync()");
var configs = await client.RemoteConfig.LoadAsync();
var roundSeconds = client.RemoteConfig.Get(roundSecondsKey, 150f);
var playerSpeed = client.RemoteConfig.Get(playerSpeedKey, 260f);
var text = new StringBuilder();
text.AppendLine(roundSecondsKey + " = " + roundSeconds);
text.AppendLine(playerSpeedKey + " = " + playerSpeed);
text.AppendLine();
text.AppendLine("All keys (" + configs.Count + "):");
foreach (var pair in configs)
text.AppendLine(" " + pair.Key + " = " + pair.Value.Value + " (" + pair.Value.ValueType + ")");
_page.SetOutput(text.ToString());
_page.SetStatus("Loaded " + configs.Count + " config(s)");
}
}
}