FiberInit_Main.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. using System.Collections.Generic;
  2. using MemoryPack;
  3. namespace ET
  4. {
  5. [Invoke((long)SceneType.Main)]
  6. public class FiberInit_Main: AInvokeHandler<FiberInit, ETTask>
  7. {
  8. public override async ETTask Handle(FiberInit fiberInit)
  9. {
  10. Scene root = fiberInit.Fiber.Root;
  11. await EventSystem.Instance.PublishAsync(root, new EntryEvent1());
  12. await EventSystem.Instance.PublishAsync(root, new EntryEvent2());
  13. await EventSystem.Instance.PublishAsync(root, new EntryEvent3());
  14. AA aa = root.AddComponent<AA>();
  15. BB bb = aa.AddComponent<BB>();
  16. CC cc = aa.AddComponent<CC>();
  17. bb.B = 1;
  18. cc.C = 2;
  19. cc.IsSerilizeWithParent = true;
  20. byte[] bytes = MemoryPackSerializer.Serialize(aa);
  21. AA aa2 = MemoryPackSerializer.Deserialize<AA>(bytes);
  22. Log.Debug($"11111111111111111111111111: {aa2}");
  23. byte[] bytes2 = MongoHelper.Serialize(aa);
  24. AA aa3 = MongoHelper.Deserialize<AA>(bytes2);
  25. Log.Debug($"11111111111111111111111111: {aa3}");
  26. }
  27. }
  28. }