Version: Unity 6.6 Alpha (6000.6)
LanguageEnglish
  • C#

BuildHistory.TryGetFilePath

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Declaration

public static bool TryGetFilePath(GUID buildSessionGuid, string filename, out string filePath);

Parameters

Parameter Description
buildSessionGuid The unique session GUID of the build to search within.
filename The name of the file to locate, for example contentlayout.json.
filePath When this method returns, contains the absolute path to the file if it exists.

Returns

bool true if the build is tracked and the file exists on disk; otherwise false.

Description

Attempts to get the path to a specific file within a build's metadata folder.

using UnityEditor;
using UnityEditor.Build;
using UnityEditor.Build.Reporting;
using UnityEngine;

public class GetTepFileExample { [MenuItem("Example/BuildHistory/Get Build Performance Profiling File Path")] static public void GetTraceEventFilePath() { // Example showing how to get the path to the trace event file // recording build performance profiling information about the latest build. if (!BuildHistory.TryGetLatestBuild(out GUID latestBuildGuid)) { Debug.Log("No builds found in build history."); return; }

// Check if the latest build wrote a profiler file string tepFilename = "BuildContentTEP.json"; if (BuildHistory.TryGetFilePath(latestBuildGuid, tepFilename, out string tepFilePath)) { Debug.Log($"Found Trace Event file for latest build: {tepFilePath}."); } else { // The file might not exist if the latest build wasn't a ContentDirectory build, // or if Build Performance Profiling is not enabled. Debug.Log($"Trace Event file '{tepFilename}' not found for the latest build."); } } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961