using System.Collections; using System.Collections.Generic; using UnityEngine; using System.IO; using System; #if UNITY_EDITOR using UnityEditor; #endif public class InGameDownTestUtility { public static bool enable { get { return LocalSave.GetBool("InGameDownLoadTestEanble", false); } set { LocalSave.SetBool("InGameDownLoadTestEanble", value); } } public static bool isWifi { get { return LocalSave.GetBool("InGameDownLoadWifi", true); } set { LocalSave.SetBool("InGameDownLoadWifi", value); } } public static bool isReadStreamingAssets { get { return LocalSave.GetBool("isReadStreamingAssets", false); } set { LocalSave.SetBool("isReadStreamingAssets", value); } } public static bool isReadVesionEx { get { return LocalSave.GetBool("isReadVesionEx", false); } set { LocalSave.SetBool("isReadVesionEx", value); } } public static bool isPartPackage { get { return LocalSave.GetBool("InGameDownLoadPartPackage", false); } set { LocalSave.SetBool("InGameDownLoadPartPackage", value); } } public static void ClearAssets() { Directory.Delete(Application.persistentDataPath, true); LocalSave.DeleteKey("HasDownLoadFullAsset"); } #if UNITY_EDITOR [RuntimeInitializeOnLoadMethod] public static void Init() { if (InGameDownTestUtility.enable) { VersionConfig.Get().assetAccess = InstalledAsset.NullAsset; } else { VersionConfig.Get().assetAccess = InstalledAsset.IngoreDownLoad; } VersionConfig.Get().partAssetPackage = InGameDownTestUtility.isPartPackage; } #endif public static bool GetReadVerionEx() { #if UNITY_EDITOR //生成VersionConfigEx.txt 提供给AOT启动时使用 var json = JsonUtility.ToJson(VersionConfig.Get()); string versionConfigExFile = Application.dataPath + "/Resources/VersionConfigEx.txt"; if (File.Exists(versionConfigExFile)) { File.Delete(versionConfigExFile); } File.WriteAllText(versionConfigExFile, json); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); Debug.Log("同步VersionConfigEx.txt成功"); #endif return enable && isReadVesionEx; } }