/// <summary> /// Calls selection dialog and calculates hash for the selected build. /// </summary> /// <param name="selectedBuildPath">Selected build path or null if selection was cancelled.</param> /// <returns>Calculated hash or null in case of error / user cancellation.</returns> public static string CalculateExternalBuildHash(out string selectedBuildPath) { var buildPath = EditorUtility.OpenFilePanel("Select Standalone Windows build exe or Android build apk / aab", "", "exe,apk,aab"); selectedBuildPath = buildPath; if (string.IsNullOrEmpty(buildPath)) { return(null); } var extension = Path.GetExtension(selectedBuildPath); if (extension == null) { return(null); } extension = extension.ToLower(CultureInfo.InvariantCulture); string result = null; var sha1 = new SHA1Managed(); try { var il2Cpp = PlayerSettings.GetScriptingBackend(EditorUserBuildSettings.selectedBuildTargetGroup) == ScriptingImplementation.IL2CPP; if (extension == ".apk" || extension == ".aab") { result = GetApkHash(buildPath, CodeHashGenerator.GetFileFiltersAndroid(il2Cpp), sha1); } else { var buildFolder = Path.GetDirectoryName(selectedBuildPath); result = StandaloneWindowsWorker.GetBuildHash(buildFolder, CodeHashGenerator.GetFileFiltersStandaloneWindows(il2Cpp), sha1); } } catch (Exception e) { Debug.LogError(ACTkConstants.LogPrefix + "Error while trying to hash build: " + e); } finally { sha1.Clear(); EditorUtility.ClearProgressBar(); } return(result); }
private static FileFilter[] GetFileFilters() { var il2Cpp = false; #if UNITY_EDITOR il2Cpp = PlayerSettings.GetScriptingBackend(EditorUserBuildSettings.selectedBuildTargetGroup) == ScriptingImplementation.IL2CPP; #elif ENABLE_IL2CPP il2Cpp = true; #endif #if UNITY_ANDROID return(CodeHashGenerator.GetFileFiltersAndroid(il2Cpp)); #elif UNITY_STANDALONE_WIN return(CodeHashGenerator.GetFileFiltersStandaloneWindows(il2Cpp)); #else return(null); #endif }