using Sirenix.OdinInspector; using System; using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Text; using System.Threading; using UnityEngine; namespace ET { public class Init : SerializedMonoBehaviour { [InlineButton("RefreshKey","刷新")] [SerializeField] public string key { get; set; } [InlineButton("RefreshKeyIV", "刷新")] [SerializeField] public string keyIV { get; set; } public static byte[] xorKey; [InlineButton("RefreshXor", "刷新")] [SerializeField] public string _xorKey; public string XorKey => _xorKey; void RefreshKey() { Char[] arr = new char[16]; for (int i = 0; i < arr.Length; i++) { arr[i] = (char)RandomHelper.RandomNumber('A', 'z' + 1); } key =string.Join("",arr); } void RefreshKeyIV() { Char[] arr = new char[16]; for (int i = 0; i < arr.Length; i++) { arr[i] = (char)RandomHelper.RandomNumber('A', 'z' + 1); } keyIV = string.Join("",arr); } void RefreshXor() { Char[] arr = new char[16]; for (int i = 0; i < arr.Length; i++) { arr[i] = (char)RandomHelper.RandomNumber('A', 'z' + 1); } _xorKey =string.Join("",arr); } private void Start() { this.StartAsync(); } private void StartAsync() { try { SynchronizationContext.SetSynchronizationContext(ThreadSynchronizationContext.Instance); DontDestroyOnLoad(gameObject); string[] assemblyNames = { "Unity.Model.dll", "Unity.ModelView.dll"}; foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies()) { string assemblyName = assembly.ManifestModule.Name; if (!assemblyNames.Contains(assemblyName)) { continue; } Game.EventSystem.Add(assembly); } xorKey = Encoding.UTF8.GetBytes(_xorKey); ProtobufHelper.Init(); Game.Options = new Options(); Game.EventSystem.Publish(new ET.EventType.AppStart { key = key, keyIV = keyIV, xorKey = xorKey, }).Coroutine(); } catch (Exception e) { Log.Error(e); } } private void Update() { Game.Update(); Game.FrameFinish(); } private void LateUpdate() { Game.LateUpdate(); } private void OnApplicationQuit() { Game.Close(); } public static void Quit() { #if UNITY_EDITOR UnityEditor.EditorApplication.isPlaying = false; #else UnityEngine.Application.Quit(); #endif } } }