If the main camera of the game has a profiler script attached and it is enabled, a null exception is thrown on startup:
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.
We can confirm this.
Null ref also occurs when adding via script
Occurs at: game.ProfilingSystem.EnableProfiling();
TopDownRPG -> PlayerController.cs
using Xenko.Core.Diagnostics;
using Xenko.Games;
using Xenko.Profiling;
.
.
.
public override void Start()
{
base.Start();
.
.
.
//Attempt to display FPS
var game = (Game)Game;
game.ProfilingSystem.EnableProfiling();
Profiler.Enable(GameProfilingKeys.GameDrawFPS);
}
at Xenko.Profiling.GameProfilingSystem.Draw(GameTime gameTime)
at Xenko.Games.GameSystemCollection.Draw(GameTime gameTime)
at Xenko.Games.GameBase.Draw(GameTime gameTime)
at Xenko.Games.GameBase.DrawFrame()
at Xenko.Games.GameBase.TickInternal()
System.NullReferenceException: Object reference not set to an instance of an object.
at Xenko.Profiling.GameProfilingSystem.Draw(GameTime gameTime)
at Xenko.Games.GameSystemCollection.Draw(GameTime gameTime)
at Xenko.Games.GameBase.Draw(GameTime gameTime)
at Xenko.Games.GameBase.DrawFrame()
at Xenko.Games.GameBase.TickInternal()
Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.
at Xenko.Profiling.GameProfilingSystem.Draw(GameTime gameTime)
at Xenko.Games.GameSystemCollection.Draw(GameTime gameTime)
at Xenko.Games.GameBase.Draw(GameTime gameTime)
at Xenko.Games.GameBase.DrawFrame()
at Xenko.Games.GameBase.TickInternal()
at Xenko.Games.GameBase.Tick()
at Xenko.Games.GamePlatform.Tick()
at Xenko.Games.GamePlatform.OnRunCallback()
at Xenko.Games.WindowsMessageLoop.Run(Control form, RenderCallback renderCallback, Boolean useApplicationDoEvents)
at Xenko.Games.GameWindowWinforms.Run()
at Xenko.Games.GameBase.Run(GameContext gameContext)
at TopDownRPG2.TopDownRPG2App.Main(String[] args) in C:UsersGregDocumentsXenkoTopDownRPG2TopDownRPG2TopDownRPG2.WindowsTopDownRPG2App.cs:line 11
Press any key to continue . . .
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.
I think that ContentManager is not registered with Service before GameProfiler is created.
DebugText has same problem.
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 b887069aacce
Please reopen if not working
yes, i can confirm that this is working now. thanks for the fix.
Most helpful comment
GameProfiler's Content is null.
I think that ContentManager is not registered with Service before GameProfiler is created.
DebugText has same problem.
This script which is placed in Default Scene seems to work.