在unity运行的时执行,RuntimeInitializeLoadType运行时间点枚举
//
// 摘要:
// Set RuntimeInitializeOnLoadMethod type.
public enum RuntimeInitializeLoadType
{
//
// 摘要:
// After Scene is loaded.
AfterSceneLoad = 0,
//
// 摘要:
// Before Scene is loaded.
BeforeSceneLoad = 1,
//
// 摘要:
// Callback when all assemblies are loaded and preloaded assets are initialized.
AfterAssembliesLoaded = 2,
//
// 摘要:
// Immediately before the splash screen is shown.
BeforeSplashScreen = 3,
//
// 摘要:
// Callback used for registration of subsystems
SubsystemRegistration = 4
}
使用示例
public class HookLuaSetup : MonoBehaviour
#if UNITY_5 || UNITY_2017_1_OR_NEWER
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
#endif
public static void OnStartGame()
{
GameObject go = new GameObject();
go.AddComponent();
}
}
用法:制作的工具初始化,不需要手动挂载mono脚本
文章评论