public void OnPreprocessBuild(BuildReport report) { Debug.Log( $"[PlotBuildTools] OnPreprocessBuild for target {report.summary.platform} at path {report.summary.outputPath}"); #region Set Build Properties LastBuildTime - Reference: https: //answers.unity.com/questions/1425758/how-can-i-find-all-instances-of-a-scriptable-objec.html //FindAssets uses tags check documentation for more info string[] guids = AssetDatabase.FindAssets($"t:{typeof(BuildSettings)}"); if (guids.Length > 1) { Debug.LogErrorFormat("[PlotBuildTools] Found more than 1 Build Properties: {0}. Using first one!", guids.Length); } if (guids.Length > 0) { string path = AssetDatabase.GUIDToAssetPath(guids[0]); BuildSettings buildSettings = AssetDatabase.LoadAssetAtPath <BuildSettings>(path); buildSettings.LastBuildTime = DateTime.Now.ToString("yyyy/MM/dd-HH:mm:ss"); // case sensitive buildSettings.AndroidBundleVersionCode = BuildSettings.GetBundleVersionCode(); EditorUtility.SetDirty(buildSettings); Debug.LogFormat("[PlotBuildTools] Updated settings LastBuildDate to \"{0}\", bundle to \"{1}\". Settings Path: {2}", buildSettings.LastBuildTime, buildSettings.AndroidBundleVersionCode, path); } else { // TODO: AUTO-CREATE ONE! Debug.LogWarning("[PlotBuildTools] Couldn't find Build Settings, please create one!"); } #endregion }