| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- using System;
- using System.Reflection;
- using System.Threading;
- using UnityEngine;
- namespace ET
- {
- public interface IEntry
- {
- void Start();
- void Update();
- void LateUpdate();
- void OnApplicationQuit();
- }
-
- public class Init: MonoBehaviour
- {
- private IEntry entry;
-
- private void Awake()
- {
- SynchronizationContext.SetSynchronizationContext(ThreadSynchronizationContext.Instance);
-
- DontDestroyOnLoad(gameObject);
- Assembly modelAssembly = null;
- if (Define.IsEditor)
- {
- UnityEngine.Debug.Log("unity editor mode!");
- foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
- {
- string assemblyName = $"{assembly.GetName().Name}.dll";
- if (assemblyName != "Unity.ModelView.dll")
- {
- continue;
- }
- modelAssembly = assembly;
- break;
- }
- }
- else
- {
- UnityEngine.Debug.Log("unity standalone mode!");
- foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
- {
- string assemblyName = $"{assembly.GetName().Name}.dll";
- if (assemblyName != "Unity.ModelView.dll")
- {
- continue;
- }
- modelAssembly = assembly;
- break;
- }
- }
- if (!Define.UseLua)
- {
- Type initType = modelAssembly.GetType("ET.MonoEntry");
- this.entry = Activator.CreateInstance(initType) as IEntry;
- }
- else
- {
- Type initType = this.GetType().Assembly.GetType("ET.LuaEntry");
- this.entry = Activator.CreateInstance(initType) as IEntry;
- }
- }
- private void Start()
- {
- this.entry.Start();
- }
- private void Update()
- {
- this.entry.Update();
- }
- private void LateUpdate()
- {
- this.entry.LateUpdate();
- }
- private void OnApplicationQuit()
- {
- this.entry.OnApplicationQuit();
- }
- }
- }
|