监听Unity3d启动事件[InitializeOnLoad]

作者:追风剑情 发布于:2018-3-8 15:18 分类:Unity3d

示例

  1. using UnityEngine;
  2. using UnityEditor;
  3. //这个类放在Editor目录下
  4. //加上这个标签可以监听UnityEditor启动
  5. [InitializeOnLoad]
  6. public class Startup
  7. {
  8. static Startup()
  9. {
  10. Debug.Log("[Startup] Startup()");
  11. Debug.Log("applicationContentsPath="+EditorApplication.applicationContentsPath);
  12. Debug.Log("applicationPath=" + EditorApplication.applicationPath);
  13. Debug.Log("currentScene=" + EditorApplication.currentScene);
  14.  
  15. EditorApplication.delayCall += DelayCall;
  16. EditorApplication.update += Update;
  17. }
  18.  
  19. private static void DelayCall()
  20. {
  21. Debug.Log("DelayCall");
  22. }
  23.  
  24. private static void Update()
  25. {
  26. Debug.Log("Update");
  27. }
  28. }

打开UnityEditor

111111.jpg

标签: Unity3d

Powered by emlog  蜀ICP备18021003号-1   sitemap

川公网安备 51019002001593号