// called by Unity public void OnPostprocessBuild(BuildReport report) { if (!ACTkSettings.Instance.PreGenerateBuildHash || !CodeHashGenerator.IsTargetPlatformCompatible()) { return; } try { EditorUtility.DisplayProgressBar("ACTk: Generating code hash", "Preparing...", 0); var hashedBuilds = GetHashedBuilds(report); if (hashedBuilds == null || hashedBuilds.Count == 0) { Debug.Log(ACTkConstants.LogPrefix + "Couldn't pre-generate code hash. " + "Please run your build and generate hash with CodeHashGenerator."); return; } foreach (var hashedBuild in hashedBuilds) { hashedBuild.PrintToConsole(); } #pragma warning disable 618 if (HashesGenerate != null) { var obsoleteDictionary = new Dictionary <string, string>(); foreach (var hashedBuild in hashedBuilds) { obsoleteDictionary.Add(hashedBuild.BuildPath, hashedBuild.SummaryHash); } HashesGenerate.Invoke(report, obsoleteDictionary); } #pragma warning restore 618 if (HashesGenerated != null) { HashesGenerated.Invoke(report, hashedBuilds.ToArray()); } } catch (Exception e) { Debug.LogError(e); } finally { EditorUtility.ClearProgressBar(); } }
private static void DrawHashSection() { using (var changed = new EditorGUI.ChangeCheckScope()) { var betaColor = ColorTools.GetPurpleString(); var fold = GUITools.DrawFoldHeader("Code Hash Generator <color=#" + betaColor + ">BETA</color>", ACTkEditorPrefsSettings.HashFoldout); if (changed.changed) { ACTkEditorPrefsSettings.HashFoldout = fold; } } if (!ACTkEditorPrefsSettings.HashFoldout) { return; } GUILayout.Space(-3f); using (GUITools.Vertical(GUITools.PanelWithBackground)) { var option = ACTkSettings.Instance.PreGenerateBuildHash; EditorGUI.BeginChangeCheck(); option = EditorGUILayout.ToggleLeft(new GUIContent("Generate code hash on build completion", "Generates hash after build is finished, prints it to the console & sends it via CodeHashGeneratorPostprocessor."), option); if (EditorGUI.EndChangeCheck()) { ACTkSettings.Instance.PreGenerateBuildHash = option; } EditorGUILayout.Space(); GUILayout.Label("Can differ from runtime hash if you post-process code in resulting build (e.g. obfuscate, compress, etc.).", GUITools.RichLabel); GUILayout.Space(5f); EditorGUILayout.HelpBox("Always make sure post-build hash equals runtime one if you're using it for later comparison", MessageType.Info, true); if (!CodeHashGenerator.IsTargetPlatformCompatible()) { EditorGUILayout.HelpBox("Current platform is not supported: Windows or Android required", MessageType.Warning, true); } GUILayout.Space(3); } }
// called by Unity public void OnPostprocessBuild(BuildReport report) { if (!ACTkSettings.Instance.PreGenerateBuildHash || !CodeHashGenerator.IsTargetPlatformCompatible()) { return; } try { EditorUtility.DisplayProgressBar("ACTk: Generating code hash", "Preparing...", 0); var hashes = GetHashes(report); if (hashes == null || hashes.Count == 0) { Debug.Log(ACTkConstants.LogPrefix + "Couldn't pre-generate code hash. " + "Please run your build and generate hash with CodeHashGenerator."); return; } foreach (var hash in hashes) { Debug.Log(ACTkConstants.LogPrefix + "Pre-generated code hash: " + hash.Value + "\nBuild: " + hash.Key); } if (HashesGenerate != null) { HashesGenerate.Invoke(report, hashes); } } catch (Exception e) { Debug.LogError(e); } finally { EditorUtility.ClearProgressBar(); } }