Hello, I am experiencing an issue with Godot 4.0.2, where functionality is broken upon transition back to my main menu scene.
Reproduction
- Open main menu, select "Level start"
- Level 1 scene opens
- in level 1 scene, pause menu is available
- Open the pause menu, and select the button to go to the main menu
MainMenu.Pressed += () => GetTree().ChangeSceneToFile(MainMenuPath); - After returning to the main menu, none of the buttons are functioning as expected (none of the code appears to run for the corresponding pressed signals
Any help is appreciated, I've had this issue for awhile in general when trying to reload scenes, or transition to already loaded scenes, but I really want to resolve this issue, because it is becoming quite a big issue for me, that keeps putting roadblocks in front of me!
Let me know if you need any further context, I will provide some snippets below!
Code Snippets
MainMenu.cs
using AutoAvians.autoloads.transition_manager;
using Godot;
using GodotUtilities;
namespace AutoAvians.ui.menus.main_menu;
public partial class MainMenu : Menu
{
[ExportCategory("MainMenu Buttons")]
[Export] private Button _levelSelectButton;
[Export] private Button _optionsButton;
[Export] private Button _quitButton;
[Export] private Button _startButton;
[ExportCategory("Main Menu Scenes")]
[Export] public PackedScene FirstLevel;
public override void _EnterTree()
{
base._EnterTree();
}
/// <summary>
/// Called when the main-menu is instanced, sets up signals and vars
/// </summary>
public override void _Ready()
{
base._Ready();
_levelSelectButton.Pressed += OnLevelSelectPressed;
_startButton.Pressed += OnStartButtonPressed;
_quitButton.Pressed += OnQuitButtonPressed;
_optionsButton.Pressed += OnOptionsButtonPressed;
}
// Other button methods ommitted for conciseness
/// <summary>
/// Called when the start button is pressed on the main menu
/// </summary>
private void OnStartButtonPressed()
{
GD.Print("Start Button Pressed");
TransitionManager.TransitionInstance.LevelStart(FirstLevel);
}
}
TransitionManager.TransitionInstace.LevelStart()
public void LevelStart(PackedScene newScene)
{
string levelFile = newScene.ResourcePath.GetFile();
string levelName = Path.GetFileNameWithoutExtension(levelFile);
Signals.Instance.EmitSignal("LevelStarted", newScene, levelName);
GetTree().ChangeSceneToPacked(newScene);
}
Return to main menu call from **PauseMenu.cs ** _Ready()
MainMenu.Pressed += () => GetTree().ChangeSceneToFile(MainMenuPath);