| | |
| | | using System.Collections;
|
| | | using System.Collections.Generic;
|
| | | using UnityEngine;
|
| | | using UnityEngine;
|
| | | using UnityEditor;
|
| | | using System.IO;
|
| | | using UnityEngine.UI;
|
| | | using System.Reflection;
|
| | |
|
| | |
|
| | | [InitializeOnLoad]
|
| | | public class ExportVersionConfigEx : EditorWindow {
|
| | | private const string VersionConfigAssetPath = "Assets/Resources/VersionConfig.asset";
|
| | | private const string VersionConfigExAssetPath = "Assets/Resources/VersionConfigEx.txt";
|
| | |
|
| | | static ExportVersionConfigEx()
|
| | | {
|
| | | EditorApplication.playModeStateChanged -= OnPlayModeStateChanged;
|
| | | EditorApplication.playModeStateChanged += OnPlayModeStateChanged;
|
| | | }
|
| | |
|
| | | [MenuItem("程序/同步VersionConfigEx.txt", false)]
|
| | | private static async void Export()
|
| | | public static void Export()
|
| | | {
|
| | | //生成VersionConfigEx.txt 提供给AOT启动时使用
|
| | | await VersionConfig.GetAsync();
|
| | | var json = JsonUtility.ToJson(VersionConfig.config);
|
| | | string versionConfigExFile = Application.dataPath + "/Resources/VersionConfigEx.txt";
|
| | | if (File.Exists(versionConfigExFile))
|
| | | SyncVersionConfigEx();
|
| | | }
|
| | |
|
| | | public static bool SyncVersionConfigEx()
|
| | | {
|
| | | var versionConfig = AssetDatabase.LoadAssetAtPath<VersionConfig>(VersionConfigAssetPath);
|
| | | if (versionConfig == null)
|
| | | {
|
| | | File.Delete(versionConfigExFile);
|
| | | Debug.LogError($"同步VersionConfigEx.txt失败,找不到配置: {VersionConfigAssetPath}");
|
| | | return false;
|
| | | }
|
| | |
|
| | | VersionConfig.config = versionConfig;
|
| | | if (LocalSave.GetBool("RestoreTest"))
|
| | | {
|
| | | versionConfig.m_AppId = "test";
|
| | | LocalSave.SetBool("RestoreTest", false);
|
| | | EditorUtility.SetDirty(versionConfig);
|
| | | Debug.Log("appid 恢复test");
|
| | | }
|
| | |
|
| | | string versionConfigExFile = Path.Combine(Application.dataPath, "Resources", "VersionConfigEx.txt");
|
| | | string versionConfigExDirectory = Path.GetDirectoryName(versionConfigExFile);
|
| | | if (!Directory.Exists(versionConfigExDirectory))
|
| | | {
|
| | | Directory.CreateDirectory(versionConfigExDirectory);
|
| | | }
|
| | |
|
| | | var json = JsonUtility.ToJson(versionConfig);
|
| | | File.WriteAllText(versionConfigExFile, json);
|
| | | AssetDatabase.SaveAssets();
|
| | | AssetDatabase.Refresh();
|
| | | AssetDatabase.ImportAsset(VersionConfigExAssetPath, ImportAssetOptions.ForceUpdate);
|
| | | VersionConfigEx.config = null;
|
| | | Debug.Log("同步VersionConfigEx.txt成功");
|
| | | return true;
|
| | | }
|
| | |
|
| | | private static void OnPlayModeStateChanged(PlayModeStateChange state)
|
| | | {
|
| | | if (state != PlayModeStateChange.ExitingEditMode)
|
| | | {
|
| | | return;
|
| | | }
|
| | |
|
| | | if (!SyncVersionConfigEx())
|
| | | {
|
| | | EditorApplication.isPlaying = false;
|
| | | }
|
| | | }
|
| | |
|
| | |
|