Entry.cs 912 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Reflection;
  6. using UnityEngine;
  7. public static class Entry
  8. {
  9. public static void Start()
  10. {
  11. Debug.Log("[Entry::Start] 看到这个日志表示你成功运行了热更新代码");
  12. Run_InstantiateByAddComponent();
  13. Run_AOTGeneric();
  14. }
  15. private static void Run_InstantiateByAddComponent()
  16. {
  17. // 代码中动态挂载脚本
  18. GameObject cube = new GameObject("");
  19. cube.AddComponent<InstantiateByAddComponent>();
  20. }
  21. struct MyVec3
  22. {
  23. public int x;
  24. public int y;
  25. public int z;
  26. }
  27. private static void Run_AOTGeneric()
  28. {
  29. // 泛型实例化
  30. var arr = new List<MyVec3>();
  31. arr.Add(new MyVec3 { x = 1 });
  32. Debug.Log("[Demos.Run_AOTGeneric] 成功运行泛型代码");
  33. }
  34. }