Skip to content

Commit

Permalink
feat: シーンが読み込まれるときのイベント
Browse files Browse the repository at this point in the history
  • Loading branch information
EbiseLutica committed Feb 1, 2024
1 parent 1c8af7d commit 4afa86a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Promete/PrometeApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,7 @@ public void Dispose()
/// <exception cref="ArgumentException">指定したシーンが存在しない。</exception>
public void LoadScene<TScene>() where TScene : Scene
{
currentScene?.OnDestroy();

currentScene = provider.GetService<TScene>() ?? throw new ArgumentException($"The scene \"{nameof(TScene)}\" is not registered.");
currentScene.OnStart();
LoadScene(typeof(TScene));
}

/// <summary>
Expand All @@ -153,6 +150,7 @@ public void LoadScene(Type typeScene)
currentScene?.OnDestroy();

currentScene = provider.GetService(typeScene) as Scene ?? throw new ArgumentException($"The scene \"{typeScene}\" is not registered.");
SceneWillChange?.Invoke();
currentScene.OnStart();
}

Expand Down Expand Up @@ -263,4 +261,6 @@ public PrometeApp Build<TWindow>() where TWindow : IWindow
return new PrometeApp(services, rendererTypes);
}
}

public event Action? SceneWillChange;
}

0 comments on commit 4afa86a

Please sign in to comment.