ConfigLoader.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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. Dictionary<string, UnityEngine.Object> keys = ResourcesComponent.Instance.GetBundleAll(configBundleName);
  16. foreach (var kv in keys)
  17. {
  18. TextAsset v = kv.Value as TextAsset;
  19. string key = kv.Key;
  20. output[key] = v.bytes;
  21. }
  22. }
  23. }
  24. }
  25. [Callback(CallbackType.GetOneConfigBytes)]
  26. public class GetOneConfigBytes: IFunc<string, byte[]>
  27. {
  28. public byte[] Handle(string configName)
  29. {
  30. //TextAsset v = ResourcesComponent.Instance.GetAsset("config.unity3d", configName) as TextAsset;
  31. //return v.bytes;
  32. throw new NotImplementedException("client cant use LoadOneConfig");
  33. }
  34. }
  35. }