ShaderComponent.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using UnityEngine;
  2. using XGame;
  3. using XGame.Framework.Asyncs;
  4. using XGame.Framework.FGUI;
  5. using XGame.Framework.Loadable;
  6. using XGame.Framework.Nodes;
  7. namespace FL.Nodes
  8. {
  9. public class ShaderComponent : NodeComponent, ILoadAsyncHandle
  10. {
  11. public override void OnEnable(object intent)
  12. {
  13. }
  14. public override void OnDisable()
  15. {
  16. }
  17. void ILoadAsyncHandle.OnLoadAsync(IAsyncGroup group)
  18. {
  19. //TODO 需要做预下载
  20. var async = Context.Asset.LoadAsync<ShaderVariantCollection>("gameshadervariants");
  21. async.On(_ =>
  22. {
  23. var svc = async.Result;
  24. if (svc == null)
  25. return;
  26. svc.WarmUp();
  27. Log.Debug($"ShaderVariantCollection WarmUp.");
  28. Context.Asset.Recycle(svc);
  29. });
  30. async.Join(group);
  31. FairyGUI.UIConfig.defaultFont = AddressableDefine.font_alimama;
  32. (Context.UI as IPackageHandle).LoadFontAsync(AddressableDefine.font_alimama).Join(group);
  33. (Context.UI as IPackageHandle).LoadFontAsync(AddressableDefine.font_dengjishuzi).Join(group);
  34. }
  35. void ILoadAsyncHandle.OnUnloadAsync(IAsyncGroup group)
  36. {
  37. }
  38. }
  39. }