监听Unity3d启动事件[InitializeOnLoad]

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

示例

using UnityEngine;
using UnityEditor;
//这个类放在Editor目录下
//加上这个标签可以监听UnityEditor启动
[InitializeOnLoad]
public class Startup 
{
    static Startup()
    {
        Debug.Log("[Startup] Startup()");
        Debug.Log("applicationContentsPath="+EditorApplication.applicationContentsPath);
        Debug.Log("applicationPath=" + EditorApplication.applicationPath);
        Debug.Log("currentScene=" + EditorApplication.currentScene);

        EditorApplication.delayCall += DelayCall;
        EditorApplication.update += Update;
    }

    private static void DelayCall()
    {
        Debug.Log("DelayCall");
    }

    private static void Update()
    {
        Debug.Log("Update");
    }
}

打开UnityEditor

111111.jpg

标签: Unity3d

Powered by emlog  蜀ICP备18021003号-1   sitemap

川公网安备 51019002001593号