mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-05 13:01:52 +00:00
Profiling for starting play mode, fixed unnecessary font loading
This commit is contained in:
@@ -837,6 +837,8 @@ namespace GlitchyEditor
|
||||
/// Starts the play mode for the current scene
|
||||
private void OnScenePlay()
|
||||
{
|
||||
Debug.Profiler.ProfileFunction!();
|
||||
|
||||
Log.EngineLogger.AssertDebug(_scriptSerializer.SerializedObjectCount == 0, "Somehow some entities are serialized.");
|
||||
|
||||
if (Application.Instance.Settings.EditorSettings.ClearLogOnPlay)
|
||||
|
||||
@@ -17,5 +17,17 @@ namespace GlitchyEngine.Core
|
||||
{
|
||||
ReleaseRef();
|
||||
}
|
||||
|
||||
public int ReleaseRefGetCount()
|
||||
{
|
||||
int count = ReleaseRefNoDelete();
|
||||
|
||||
if (count == 0)
|
||||
{
|
||||
delete this;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace GlitchyEngine.World
|
||||
cameraEntity
|
||||
};
|
||||
|
||||
Font _font ~ _.ReleaseRef();
|
||||
static Font _font;
|
||||
|
||||
/// Gets or sets the name of the scene.
|
||||
public StringView Name
|
||||
@@ -122,12 +122,20 @@ namespace GlitchyEngine.World
|
||||
}
|
||||
});
|
||||
|
||||
if (_font == null)
|
||||
_font = new Font(@"C:\Windows\Fonts\arial.ttf", 24);
|
||||
else
|
||||
_font..AddRef();
|
||||
|
||||
//_font = new Font(@"C:\Windows\Fonts\Cascadia Code.ttf", 24);
|
||||
}
|
||||
|
||||
public ~this()
|
||||
{
|
||||
if (_font.ReleaseRefGetCount() == 0)
|
||||
{
|
||||
_font = null;
|
||||
}
|
||||
}
|
||||
|
||||
/// Copies all entities with their components to the given target-scene.
|
||||
@@ -138,6 +146,8 @@ namespace GlitchyEngine.World
|
||||
/// TODO: Honestly, I'm not quite sure what simulation mode is actually good for. Maybe we better just remove it?
|
||||
public void CopyTo(Scene target, bool copyScripts)
|
||||
{
|
||||
Debug.Profiler.ProfileFunction!();
|
||||
|
||||
// Copy entities
|
||||
for (let sourceHandle in _ecsWorld.Enumerate())
|
||||
{
|
||||
@@ -198,6 +208,8 @@ namespace GlitchyEngine.World
|
||||
/// Copies the all components of type TComponent from source scene to the corresponding entities in target scene.
|
||||
private static void CopyComponents<TComponent>(Scene source, Scene target) where TComponent : struct, new
|
||||
{
|
||||
Debug.Profiler.ProfileFunction!();
|
||||
|
||||
for (let (sourceHandle, sourceComponent) in source._ecsWorld.Enumerate<TComponent>())
|
||||
{
|
||||
Entity sourceEntity = .(sourceHandle, source);
|
||||
|
||||
Reference in New Issue
Block a user