feat: json loader (Work In Progress)

This commit is contained in:
2025-02-03 16:56:46 +01:00
parent 51404e5cc6
commit ed5d3cd222
9 changed files with 154 additions and 93 deletions

38
Assets/LevelLoader.cs Normal file
View File

@@ -0,0 +1,38 @@
using UnityEngine;
using UnityEngine.UI;
using System.IO;
using System.Text.Json;
public class LevelLoader : MonoBehaviour
{
[SerializeField]
public Text levelNameText;
void Start()
{
levelNameText.text = "Coucou";
string filePath = "level.json";
if (File.Exists(filePath))
{
string json = File.ReadAllText(filePath);
Level level = JsonSerializer.Deserialize<Level>(json, new JsonSerializerOptions { PropertyNameCaseInsensitive = true });
Console.WriteLine($"Name: {level.Name}");
Console.WriteLine($"MusicPath: {level.MusicPath}");
Console.WriteLine($"TotalJumps: {level.TotalJumps}");
Console.WriteLine($"TotalAttempts: {level.TotalAttempts}");
Console.WriteLine($"KilledCount: {level.KilledCount}");
}
else
{
Console.WriteLine("JSON file not found.");
}
}
void Update()
{
}
}