ConfigLoader.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. namespace ET.Client
  5. {
  6. [Callback(CallbackType.GetAllConfigBytes)]
  7. public class GetAllConfigBytes: IAction<ConfigComponent, Dictionary<string, byte[]>>
  8. {
  9. public void Handle(ConfigComponent configComponent, Dictionary<string, byte[]> output)
  10. {
  11. using (Game.Scene.AddComponent<ResourcesComponent>())
  12. {
  13. const string configBundleName = "config.unity3d";
  14. ResourcesComponent.Instance.LoadBundle(configBundleName);
  15. HashSet<Type> configTypes = Game.EventSystem.GetTypes(typeof (ConfigAttribute));
  16. foreach (Type configType in configTypes)
  17. {
  18. TextAsset v = ResourcesComponent.Instance.GetAsset(configBundleName, configType.Name) as TextAsset;
  19. output[configType.Name] = v.bytes;
  20. }
  21. }
  22. }
  23. }
  24. [Callback(CallbackType.GetOneConfigBytes)]
  25. public class GetOneConfigBytes: IFunc<string, byte[]>
  26. {
  27. public byte[] Handle(string configName)
  28. {
  29. //TextAsset v = ResourcesComponent.Instance.GetAsset("config.unity3d", configName) as TextAsset;
  30. //return v.bytes;
  31. throw new NotImplementedException("client cant use LoadOneConfig");
  32. }
  33. }
  34. }