标签:注册 mod initial rap 初始化 using mat attribute mode
"Editor"文件夹下的PlayModeStateChangedHandler.cs
using UnityEngine;
using UnityEditor;
//允许在 Unity 加载时初始化编辑器类,无需用户操作。
[InitializeOnLoadAttribute]
public static class PlayModeStateChangedHandler{
//初始化类时,注册事件处理函数
static PlayModeStateChangedHandler(){
EditorApplication.playModeStateChanged+=OnPlayerModeStateChanged;
}
private static void OnPlayerModeStateChanged(PlayModeStateChange playModeState){
Debug.LogFormat("state:{0} will:{1} isPlaying:{2}",playModeState,EditorApplication.isPlayingOrWillChangePlaymode,EditorApplication.isPlaying);
}
//当点"Play"按钮进入播放模式时
//输出:
//state:ExitingEditMode will:True isPlaying:False
//state:EnteredPlayMode will:True isPlaying:True
}
Unity 侦听进入播放模式、Unity加载时初始化编辑器类
标签:注册 mod initial rap 初始化 using mat attribute mode
原文地址:https://www.cnblogs.com/kingBook/p/12160804.html