Система перехода между сценами. И главное меню. Типа.

This commit is contained in:
Евгений Титаренко 2024-08-25 12:27:06 +03:00
parent 8e4304ebc6
commit f45ebbceb6
7 changed files with 172 additions and 1 deletions

22
scripts/SceneManager.cs Normal file
View file

@ -0,0 +1,22 @@
using Godot;
using System;
using System.Linq;
using Godot.Collections;
public partial class SceneManager : Node
{
[Export] public Dictionary<string, string> Scenes;
public string CurrentScene;
public void SwitchScene(string sceneName)
{
GetTree().ChangeSceneToFile(Scenes[sceneName]);
}
public override void _Ready()
{
var scenePath = (string)ProjectSettings.GetSetting("application/run/main_scene");
CurrentScene = Scenes.First(pair => pair.Value == scenePath).Key;
}
}