-
-
Notifications
You must be signed in to change notification settings - Fork 963
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Profiler Script throws null exception on startup #41
Comments
We can confirm this. Null ref also occurs when adding via script TopDownRPG -> PlayerController.cs
[Game]: Error: Unexpected exception. System.NullReferenceException: Object reference not set to an instance of an object. Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object. |
was trying to fix it but had to do other stuff. if someone works on it, please comment here so we are not doing it twice. |
GameProfiler's Content is null. This script which is placed in Default Scene seems to work. public class RecreateGameProfilerAndDebugTextScript : StartupScript
{
public override void Start()
{
// GameProfiler
GameProfiler.DisableProfiling();
Game.GameSystems.Remove(GameProfiler);
Services.RemoveService<GameProfilingSystem>();
var gameProfiler = new GameProfilingSystem(Services);
Services.AddService(gameProfiler);
Game.GameSystems.Add(gameProfiler);
// DebugText
DebugText.Enabled = false;
DebugText.Visible = false;
Game.GameSystems.Remove(DebugText);
Services.RemoveService<DebugTextSystem>();
var debugText = new DebugTextSystem(Services);
Services.AddService(debugText);
Game.GameSystems.Add(debugText);
// Reload current scene
var result = Content.TryGetAssetUrl(SceneSystem.SceneInstance.RootScene, out var url);
if (!result)
{
}
Content.Unload(SceneSystem.SceneInstance.RootScene);
var scene = Content.Load<Scene>(url);
var script = scene.Entities.SelectMany((e) => e.Components).OfType<RecreateGameProfilerAndDebugTextScript>().First();
script.Entity.Remove(script);
SceneSystem.SceneInstance.RootScene = scene;
}
} |
@EternalTamago thanks a lot, that workaround works! |
Supposed to be fixed by b887069 |
yes, i can confirm that this is working now. thanks for the fix. |
Easy performance gain but still crash sometimes
If the main camera of the game has a profiler script attached and it is enabled, a null exception is thrown on startup:
[Game]: Error: Unexpected exception. System.NullReferenceException:
bei Xenko.Profiling.GameProfilingSystem.Draw(GameTime gameTime)
bei Xenko.Games.GameSystemCollection.Draw(GameTime gameTime)
bei Xenko.Games.GameBase.Draw(GameTime gameTime)
bei Xenko.Games.GameBase.DrawFrame()
bei Xenko.Games.GameBase.TickInternal()
if the script is disabled, the exception does not occur.
The text was updated successfully, but these errors were encountered: