Editor下
1 2 3 4 5 6 7 8 9 10 11 |
using UnityEditor; using UnityEngine; [InitializeOnLoad] public class EditorExecute { static EditorHelper() { Debug.Log("启动编辑器时执行"); } } |
Runtime下
1 2 3 4 5 6 7 8 9 |
using UnityEngine; public class RuntimeExecute { [RuntimeInitializeOnLoadMethod] private static void OnRuntimeMethodLoad() { Debug.Log("运行时执行"); } } |
- 本文固定链接: http://www.u3d8.com/?p=2231
- 转载请注明: 网虫虫 在 u3d8.com 发表过