少年修仙传客户端代码仓库
hch
2025-06-12 204ef05a831c9484e2abc561d27ecbff7c797453
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
using UnityEngine;
using System;
using System.IO;
using vnxbqy.UI;
 
 
public class ResourcesPath : Singleton<ResourcesPath>
{
    public const string AssetDependentFileBundleName =
#if UNITY_ANDROID
        "android";
#elif UNITY_IOS
        "ios";
#else
        "standalone";
#endif
 
    public const string windowFileBundleName = "ui/window";
    public const string uiprefabFileBundleName = "ui/prefab";
 
    public readonly static string ResourcesOutPath = Application.dataPath + "/ResourcesOut/";
    public const string ResourcesOutAssetPath = "Assets/ResourcesOut/";
    public const string AssetDependentFileAssetName = "AssetBundleManifest";
    public const string ABExtention = ".unity3d";
 
    public readonly string StreamingAssetPath;
    public readonly string ExternalStorePath;
 
    #region 具体asset资源读取路径
 
    public static readonly string MOB_FOLDER_NAME = "gmodels/";
    public static readonly string MOB_SUFFIX = "prefab_race_";
 
    public static readonly string EFFECT_Folder_Name = "effect/";
 
    public static readonly string UI_SPRITE_SUFFIX = "UI/Sprite";
    public static readonly string UI_WINDOW_SUFFIX = "UI/Window";
    public static readonly string UI_PRIORITYWINDOW_SUFFIX = "UI/PriorityWindow";
    public static readonly string UI_FONT_SUFFIX = "UI/Font";
    public static readonly string UI_PREFAB_SUFFIX = "UI/Prefab";
 
    public static readonly string CONFIG_FODLER = ResourcesOutPath + "refdata/Config";
 
    public static readonly string AUDIO_SUFFIX = "Audio/";
    public static readonly string VIDEO_SUFFIX = "Video/";
 
 
    #endregion
 
    public void Init()
    {
    }
 
    public ResourcesPath()
    {
#if UNITY_ANDROID 
        StreamingAssetPath = Application.streamingAssetsPath + "/android/";
#elif UNITY_IOS
        StreamingAssetPath = Application.streamingAssetsPath + "/ios/";
#else
        StreamingAssetPath = Application.streamingAssetsPath + "/standalone/";
#endif
 
        if (!Application.isEditor)
        {
            switch (Application.platform)
            {
                case RuntimePlatform.WindowsPlayer:
                    ExternalStorePath = Path.GetDirectoryName(Application.streamingAssetsPath) + "/ExternalAssets/";
                    break;
                default:
                    ExternalStorePath = Application.persistentDataPath + "/";
                    break;
            }
        }
        else
        {
            ExternalStorePath = Application.persistentDataPath + "/";
        }
 
        DebugEx.Log("Stream Path: " + StreamingAssetPath);
        DebugEx.Log("External Path: " + ExternalStorePath);
    }
 
    public void CleanCache()
    {
        ConfirmCancel.ShowPopConfirm(Language.Get("Mail101"),
        Language.Get("CleanCache2"), (bool isOk) =>
        {
            if (isOk)
            {
                try
                {
                    // 获取persistentDataPath下的所有文件和文件夹  
                    string[] files = Directory.GetFiles(ExternalStorePath);
                    string[] dirs = Directory.GetDirectories(ExternalStorePath);
 
                    // 删除所有文件  
                    foreach (string file in files)
                    {
                        if (file.Contains("config"))
                        {
                            continue;
                        }
                        File.Delete(file);
                    }
 
 
                    // 递归删除所有文件夹  
                    foreach (string dir in dirs)
                    {
                        if (dir.Contains("config"))
                        {
                            continue;
                        }
                        Directory.Delete(dir, true);
                    }
 
                    files = Directory.GetFiles(ExternalStorePath + "/config");
                    foreach (string file in files)
                    {
                        bool isDelete = true;
                        foreach (string filename in ConfigInitiator.builtinConfig)
                        {
                            if (file.Contains(filename))
                            {
                                isDelete = false;
                                break;
                            }
                        }
 
                        if (isDelete)
                            File.Delete(file);
                    }
 
 
                }
                catch (System.Exception e)
                {
                    Debug.LogError("Failed to clean persistent data: " + e.Message);
                }
                finally
                {
                    Clock.AlarmAfter(0.1f, () =>
                    {
                        Application.Quit();
                    });
                    Debug.Log("Persistent data cleaned.");
                }
 
            }
        });
 
        
    }
}