Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


TryGetFilePath(GUID, string, out string)

Attempts to get the path to a specific file within a build's metadata folder.
Read time 1 minuteLast updated 10 days ago

Definition

TryGetFilePath(GUID, string, string)

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

Parameters

buildSessionGuid

GUID
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

Type

Description

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

Examples

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. Debug.Log($"Trace Event file '{tepFilename}' not found for the latest build."); } }}