少年修仙传客户端基础资源
hch
2024-05-11 eccde9043d770a64d9181c69393d3ff7c20e21bb
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
using System.Collections.Generic;
using Beebyte.Obfuscator.Assembly;
using UnityEditor;
 
namespace Beebyte.Obfuscator
{
    public class RestoreUtils
    {
        /**
         * When assemblies are declared in the 'Compiled Assemblies' list within Obfuscator options then before any
         * obfuscation they are temporarily backed up then operated on. This method is then called after obfuscation
         * to restore the original assembly and remove the backup.
         */
        public static void RestoreOriginalDlls()
        {
            try
            {
                Options options = OptionsManager.LoadOptionsIgnoringInstallFiles();
                if (options == null || options.compiledAssemblies.Length == 0)
                {
                    return;
                }
                ICollection<string> compiledAssemblyPaths = new AssemblySelector(options).GetCompiledAssemblyPaths();
                IDictionary<string, string> backupMap = FileBackup.GetBackupMap(compiledAssemblyPaths);
                //DLLs declared within 'Compiled Assemblies' will be restored from this method.
                FileBackup.Restore(backupMap);
            }
            finally
            {
                EditorApplication.update -= RestoreOriginalDlls;
            }
        }
        
        /**
         * This method restores obfuscated MonoBehaviour cs files to their original names.
         */
        public static void RestoreMonobehaviourSourceFiles()
        {
#if UNITY_3_1 || UNITY_3_2 || UNITY_3_3 || UNITY_3_4 || UNITY_3_5 || UNITY_4_0 || UNITY_4_1 || UNITY_4_2
#else
            if (BuildPipeline.isBuildingPlayer == false)
            {
#endif
                try
                {
                    EditorApplication.LockReloadAssemblies();
                    Obfuscator.RevertAssetObfuscation();
                }
                finally
                {
                    EditorApplication.update -= RestoreMonobehaviourSourceFiles;
                    EditorApplication.UnlockReloadAssemblies();
                }
#if UNITY_3_1 || UNITY_3_2 || UNITY_3_3 || UNITY_3_4 || UNITY_3_5 || UNITY_4_0 || UNITY_4_1 || UNITY_4_2
#else
            }
#endif
        }
    }
}