I'm not able to fetch the name of the currently active scene.
Just for testing purposes i created the script beneath and attached it to a gameobject.
After loading i still get the old scene name when pressing Mouse1. I don't understand why. 😣
I also created a gameobject in the new scene with this script attached:
But even this just just logs "minimal" into the console, when first loading the minimal scene. It works fine when starting with the new scene.
I'm lost. Send help 🙏
Just for testing purposes i created the script beneath and attached it to a gameobject.
using Sandbox;
public sealed class SceneManagerLogic : Component
{
protected override void OnStart()
{
GameObject.Flags |= GameObjectFlags.DontDestroyOnLoad;
}
protected override void OnUpdate()
{
if ( Input.Pressed( "Attack1" ) ) { Log.Info("Current Scene: " + this.GameObject.Scene); }
if ( Input.Pressed( "Attack2" ) ) { Scene.LoadFromFile( "scenes/new scene.scene" ); }
}
}After loading i still get the old scene name when pressing Mouse1. I don't understand why. 😣
I also created a gameobject in the new scene with this script attached:
using Sandbox;
public sealed class SpamSceneName : Component
{
protected override void OnUpdate()
{
Log.Info( $"Scene Spammer: {this.GameObject.Name} {this.GameObject.Scene.Name} {Game.ActiveScene}" );
}
}But even this just just logs "minimal" into the console, when first loading the minimal scene. It works fine when starting with the new scene.
I'm lost. Send help 🙏