Beispiel #1
0
    private static bool DoCodeInjector(string fromPath, string resultPath)
    {
        float progress = 0.0f;

        EditorUtility.DisplayProgressBar("CodeInjector", "Obfuscating and protecting code...", progress);

        CodeInjectorSetup setup = CodeInjectorSetupSettings();

        string[] files = Directory.GetFiles(fromPath, "*.dll", SearchOption.TopDirectoryOnly);
        for (int index = 0; index < files.Length; index++)
        {
            if (editorAssemblies.Contains(Path.GetFileName(files[index])))
            {
            }
            else
            {
                setup.AddAssembly(files[index]);
            }
        }
        // Դ·¾¶Ìí¼ÓΪÒÀÀµ
        setup.AddAssemblySearchDirectory(fromPath);
        setup.OutputDirectory = resultPath;

        progress = 0.25f;
        EditorUtility.DisplayProgressBar("CodeInjector", "injectoring and generating code...", progress);

        EditorUtility.ClearProgressBar();
        setup.Run();

        EditorUtility.ClearProgressBar();
        return(true);
    }
Beispiel #2
0
    public static CodeInjectorSetup CodeInjectorSetupSettings()
    {
        CodeInjectorSetup setup       = new CodeInjectorSetup();
        BuildTarget       buildTarget = EditorUserBuildSettings.activeBuildTarget;

        if (buildTarget == BuildTarget.Android)
        {
            string enginePath = PathEx.Combine(EditorApplication.applicationContentsPath, "PlaybackEngines");
            if (EditorUserBuildSettings.development)
            {
                enginePath = PathEx.Combine(enginePath, "androiddevelopmentplayer");
            }
            else
            {
                enginePath = PathEx.Combine(enginePath, "androidplayer");
            }
            enginePath = PathEx.Combine(enginePath, "Managed");
            // Ìí¼ÓUnityÒýÇæÒÀÀµ
            setup.AddAssemblySearchDirectory(enginePath);
            setup.BuildTarget = "Android";
        }
        else if (buildTarget == BuildTarget.iPhone)
        {
            string enginePath = PathEx.Combine(EditorApplication.applicationContentsPath, "PlaybackEngines");
            enginePath = PathEx.Combine(enginePath, "iossupport");
            enginePath = PathEx.Combine(enginePath, "Managed");
            // Ìí¼ÓUnityÒýÇæÒÀÀµ
            setup.AddAssemblySearchDirectory(enginePath);
            setup.BuildTarget = "iPhone";
        }
        else
        {
            string enginePath = Path.Combine(EditorApplication.applicationContentsPath, "Managed");
            // Ìí¼ÓUnityÒýÇæÒÀÀµ
            setup.AddAssemblySearchDirectory(enginePath);
            setup.BuildTarget = "Standalone";
        }

        return(setup);
    }