Loadable.cs 713 B

1234567891011121314151617181920212223242526
  1. namespace XGame.Framework.Loadable
  2. {
  3. public class Loadable : AsyncLoadable, ILoadable
  4. {
  5. public void LoadSync()
  6. {
  7. Assert.IsFalse(State != LoadState.None, $"Connot LoadSync On State {State} Loadable: {this} ");
  8. OnLoadSync();
  9. State = LoadState.Loaded;
  10. OnLoaded();
  11. }
  12. public void UnloadSync()
  13. {
  14. Assert.IsFalse(State != LoadState.Loaded, $"Connot UnloadSync On State {State} Loadable: {this} ");
  15. OnUnloadSync();
  16. State = LoadState.Unloaded;
  17. OnUnloaded();
  18. }
  19. protected virtual void OnLoadSync() { }
  20. protected virtual void OnUnloadSync() { }
  21. }
  22. }