Version: 2023.2
言語: 日本語

BuildReport

class in UnityEditor.Build.Reporting

/

継承:Object

マニュアルに切り替える

説明

The BuildReport API gives you information about the Unity build process.

A BuildReport object is returned by BuildPipeline.BuildPlayer and can be used to discover information about the files output, the build steps taken, and other platform-specific information such as native code stripping.

For AssetBundle builds the BuildReport is available by calling GetLatestReport immediately after calling BuildPipeline.BuildAssetBundles.

                    
using System.IO;
using System.Linq;
using System.Text;
using UnityEditor;
using UnityEditor.Build;
using UnityEditor.Build.Reporting;
using UnityEngine;

public class BuildReportExample { [MenuItem("Example/Build AssetBundle")] static public void BuildBundles() { string buildOutputDirectory = "BuildOutput"; if (!Directory.Exists(buildOutputDirectory)) Directory.CreateDirectory(buildOutputDirectory);

var bundleDefinitions = new AssetBundleBuild[] { new AssetBundleBuild() { assetBundleName = "MyBundle", assetNames = new string[] { "Assets/Scenes/SampleScene.unity" } } };

BuildPipeline.BuildAssetBundles( buildOutputDirectory, bundleDefinitions, BuildAssetBundleOptions.ForceRebuildAssetBundle, EditorUserBuildSettings.activeBuildTarget);

BuildReport report = BuildReport.GetLatestReport(); if (report != null) { var sb = new StringBuilder(); sb.AppendLine("Build result : " + report.summary.result); sb.AppendLine("Build size : " + report.summary.totalSize + " bytes"); sb.AppendLine("Build time : " + report.summary.totalTime); sb.AppendLine("Error summary : " + report.SummarizeErrors()); sb.Append(LogBuildReportSteps(report)); sb.AppendLine(LogBuildMessages(report)); Debug.Log(sb.ToString()); } else { // Certain errors like invalid input can fail the build immediately, with no BuildReport written Debug.Log("AssetBundle build failed"); } }

public static string LogBuildReportSteps(BuildReport buildReport) { var sb = new StringBuilder();

sb.AppendLine($"Build steps: {buildReport.steps.Length}"); int maxWidth = buildReport.steps.Max(s => s.name.Length + s.depth) + 3; foreach (var step in buildReport.steps) { string rawStepOutput = new string('-', step.depth + 1) + ' ' + step.name; sb.AppendLine($"{rawStepOutput.PadRight(maxWidth)}: {step.duration:g}"); } return sb.ToString(); }

public static string LogBuildMessages(BuildReport buildReport) { var sb = new StringBuilder(); foreach (var step in buildReport.steps) { foreach (var message in step.messages) // If desired, this logic could ignore any Info or Warning messages to focus on more serious messages sb.AppendLine($"[{message.type}] {message.content}"); }

string messages = sb.ToString(); if (messages.Length > 0) return "Messages logged during Build:\n" + messages; else return ""; } }

// For the purpose of demonstration, this callback logs different types of errors and forces a build failure [BuildCallbackVersion(1)] class MyTroublesomeBuildCallback : IProcessSceneWithReport { public int callbackOrder { get { return 0; } } public void OnProcessScene(UnityEngine.SceneManagement.Scene scene, BuildReport report) { Debug.Log("MyTroublesomeBuildCallback called for " + scene.name); Debug.LogError("Logging an error");

throw new BuildFailedException("Forcing the build to stop"); } }

変数

packedAssetsAn array of all the PackedAssets generated by the build process.
scenesUsingAssetsAn optional array of ScenesUsingAssets generated by the build process if BuildOptions.DetailedBuildReport was used during the build.
stepsAn array of all the BuildSteps that took place during the build process.
strippingInfoThe StrippingInfo object for the build.
summaryA BuildSummary containing overall statistics and data about the build process.

Public 関数

GetFilesReturns an array of all the files output by the build process.
SummarizeErrorsReturns a string summarizing any errors that occurred during the build

Static 関数

GetLatestReportReturn the build report generated by the most recent Player or AssetBundle build

継承メンバー

変数

hideFlagsShould the object be hidden, saved with the Scene or modifiable by the user?
nameオブジェクト名

Public 関数

GetInstanceIDGets the instance ID of the object.
ToStringReturns the name of the object.

Static 関数

DestroyRemoves a GameObject, component or asset.
DestroyImmediateDestroys the object obj immediately. You are strongly recommended to use Destroy instead.
DontDestroyOnLoadDo not destroy the target Object when loading a new Scene.
FindAnyObjectByTypeRetrieves any active loaded object of Type type.
FindFirstObjectByTypeRetrieves the first active loaded object of Type type.
FindObjectsByTypeRetrieves a list of all loaded objects of Type type.
Instantiateoriginal のオブジェクトをクローンします

Operator

boolオブジェクトが存在するかどうか
operator !=二つのオブジェクトが異なるオブジェクトを参照しているか比較します
operator ==2つのオブジェクト参照が同じオブジェクトを参照しているか比較します。
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961