Exemplo n.º 1
0
        public static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProject)
        {
            var setting = UPRToolSetting.Instance;

            if (scriptBackend == ScriptingImplementation.Mono2x && (target == BuildTarget.StandaloneWindows || target == BuildTarget.StandaloneWindows64))
            {
                string AssemblyPath = pathToBuiltProject.Replace(".exe", "_Data/Managed/");

                if (setting.enableMonoProfiler)
                {
                    InjectMethods.InjectAllMethods(AssemblyPath + "Assembly-CSharp.dll");
                    Debug.Log("Listening Lua Profiler Success");
                }

                if (setting.loadScene)
                {
                    InjectUtils.addProfiler(AssemblyPath, "UnityEngine.CoreModule.dll", "SceneManager", "LoadScene");
                }
                if (setting.loadAsset)
                {
                    InjectUtils.addProfiler(AssemblyPath, "UnityEngine.AssetBundleModule.dll", "AssetBundle", "LoadAsset");
                }
                if (setting.loadAssetBundle)
                {
                    InjectUtils.addProfiler(AssemblyPath, "UnityEngine.AssetBundleModule.dll", "AssetBundle", "LoadFromFile");
                }
                if (setting.instantiate)
                {
                    InjectUtils.addProfiler(AssemblyPath, "UnityEngine.CoreModule.dll", "Object", "Instantiate");
                }
            }
        }
        public void OnPostBuildPlayerScriptDLLs(BuildReport report)
        {
            string AssemblyPath = "";

            if ((report.summary.platform == BuildTarget.StandaloneWindows || report.summary.platform == BuildTarget.StandaloneWindows64) && scriptBackend == ScriptingImplementation.IL2CPP)
            {
                // windows didn't support il2cpp injection
                Debug.Log("Windows IL2CPP hasn't support listening function");
                return;

                /*
                 * scriptBackend = PlayerSettings.GetScriptingBackend(BuildTargetGroup.Standalone);
                 * if (scriptBackend == ScriptingImplementation.IL2CPP)
                 * {
                 *  AssemblyPath = "./Temp/StagingArea/Il2Cpp/Managed/";
                 *  if (!Directory.Exists(AssemblyPath))
                 *  {
                 *      AssemblyPath = "./Temp/StagingArea/Data/Managed/";
                 *  }
                 * }
                 */
            }
            else if (report.summary.platform == BuildTarget.Android)
            {
                scriptBackend = PlayerSettings.GetScriptingBackend(BuildTargetGroup.Android);
                if (scriptBackend == ScriptingImplementation.IL2CPP)
                {
                    AssemblyPath = "./Temp/StagingArea/Il2Cpp/Managed/";
                    if (!Directory.Exists(AssemblyPath))
                    {
                        AssemblyPath = "./Temp/StagingArea/Data/Managed/";
                    }
                }
            }

            if (AssemblyPath != "")
            {
                var setting = UPRToolSetting.Instance;
                if (setting.loadScene)
                {
                    InjectUtils.addProfiler(AssemblyPath, "UnityEngine.CoreModule.dll", "SceneManager", "LoadScene");
                }
                if (setting.loadAsset)
                {
                    InjectUtils.addProfiler(AssemblyPath, "UnityEngine.AssetBundleModule.dll", "AssetBundle", "LoadAsset");
                }
                if (setting.loadAssetBundle)
                {
                    InjectUtils.addProfiler(AssemblyPath, "UnityEngine.AssetBundleModule.dll", "AssetBundle", "LoadFromFile");
                }
                if (setting.instantiate)
                {
                    InjectUtils.addProfiler(AssemblyPath, "UnityEngine.CoreModule.dll", "Object", "Instantiate");
                }
            }
        }
Exemplo n.º 3
0
        public void OnPostGenerateGradleAndroidProject(string path)
        {
            var setting = UPRToolSetting.Instance;
            var backend = PlayerSettings.GetScriptingBackend(BuildTargetGroup.Android);

            if (backend == ScriptingImplementation.IL2CPP)
            {
                return;
            }

            // both for export android project and apk
            if (Directory.Exists(path + "/src/main/assets/bin/Data/Managed/"))
            {
                AssemblyPath = path + "/src/main/assets/bin/Data/Managed/";
            }

            if (string.IsNullOrEmpty(AssemblyPath))
            {
                Debug.Log("[UPR package]: Could not find assembly file. Injection Error");
                return;
            }


            if (setting.enableMonoProfiler)
            {
                InjectMethods.InjectAllMethods(AssemblyPath + "Assembly-CSharp.dll");
                Debug.Log("Listening Mono Profiler Success");
            }

            if (backend == ScriptingImplementation.Mono2x)
            {
                if (setting.loadScene)
                {
                    InjectUtils.addProfiler(AssemblyPath, "UnityEngine.CoreModule.dll", "SceneManager", "LoadScene");
                }
                if (setting.loadAsset)
                {
                    InjectUtils.addProfiler(AssemblyPath, "UnityEngine.AssetBundleModule.dll", "AssetBundle", "LoadAsset");
                    InjectUtils.addProfiler(AssemblyPath, "UnityEngine.AssetBundleModule.dll", "AssetBundle", "Load");
                }
                if (setting.loadAssetBundle)
                {
                    InjectUtils.addProfiler(AssemblyPath, "UnityEngine.AssetBundleModule.dll", "AssetBundle", "LoadFromFile");
                }
                if (setting.instantiate)
                {
                    InjectUtils.addProfiler(AssemblyPath, "UnityEngine.CoreModule.dll", "Object", "Instantiate");
                }
            }
        }
        public void OnPostGenerateGradleAndroidProject(string path)
        {
            var setting = UPRToolSetting.Instance;
            var backend = PlayerSettings.GetScriptingBackend(BuildTargetGroup.Android);

            if (!Directory.Exists(AssemblyPath))
            {
                AssemblyPath = "./Temp/gradleOut/unityLibrary/src/main/assets/bin/Data/Managed/";
            }

            if (setting.enableMonoProfiler)
            {
                InjectMethods.InjectAllMethods(AssemblyPath + "Assembly-CSharp.dll");
                Debug.Log("Listening Mono Profiler Success");
            }

            if (backend == ScriptingImplementation.Mono2x)
            {
                if (setting.loadScene)
                {
                    InjectUtils.addProfiler(AssemblyPath, "UnityEngine.CoreModule.dll", "SceneManager", "LoadScene");
                }
                if (setting.loadAsset)
                {
                    InjectUtils.addProfiler(AssemblyPath, "UnityEngine.AssetBundleModule.dll", "AssetBundle", "LoadAsset");
                    InjectUtils.addProfiler(AssemblyPath, "UnityEngine.AssetBundleModule.dll", "AssetBundle", "Load");
                }
                if (setting.loadAssetBundle)
                {
                    InjectUtils.addProfiler(AssemblyPath, "UnityEngine.AssetBundleModule.dll", "AssetBundle", "LoadFromFile");
                }
                if (setting.instantiate)
                {
                    InjectUtils.addProfiler(AssemblyPath, "UnityEngine.CoreModule.dll", "Object", "Instantiate");
                }
            }
        }