mirror of
https://github.com/boudji-ludwig-pett/cnam-geometry-dash.git
synced 2025-12-11 00:27:48 +01:00
feat: json loader (Work In Progress)
This commit is contained in:
38
Assets/LevelLoader.cs
Normal file
38
Assets/LevelLoader.cs
Normal 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()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user