yyl
2026-05-11 51b0f6ed9f4e1d3bb6f8144470b46908c7699a96
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.IO;
using System;
using Cysharp.Threading.Tasks;
 
#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()
    {
#if !UNITY_WEBGL
        Directory.Delete(Application.persistentDataPath, true);
#endif
        LocalSave.DeleteKey("HasDownLoadFullAsset");
    }
 
#if UNITY_EDITOR
    [RuntimeInitializeOnLoadMethod]
    public static void Init()
    {
        VersionConfig.GetAsync().ContinueWith(config => {
            if (InGameDownTestUtility.enable)
            {
                config.assetAccess = InstalledAsset.NullAsset;
            }
            else
            {
                config.assetAccess = InstalledAsset.IngoreDownLoad;
            }
 
            config.partAssetPackage = InGameDownTestUtility.isPartPackage;
        }).Forget();
 
    }
#endif
 
    public static bool GetReadVerionEx()
    {
#if UNITY_EDITOR
        VersionConfig.GetAsync().ContinueWith(config =>
        {
            //生成VersionConfigEx.txt 提供给AOT启动时使用
            var json = JsonUtility.ToJson(config);
            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成功");
        }).Forget();
 
#endif
        return enable && isReadVesionEx;
    }
 
 
    public static bool GetDownloadEnable()
    {
        return enable;
    }
}