Property BuildPath
BuildPath
The build path used by the Addressables system for its initialization data.
선언
public static string BuildPath { get; }
프로퍼티 값
타입 | 설명 |
---|---|
string |
참고
Addressables.BuildPath returns the path used by the Addressables system for its built initialization data. This path is to the Addressables folder in the Project Library folder for the active platform.This folder contains the settings, local catalog and addressables managed local asset bundles.
예
Gets the runtime settings from the buildPath and returns the Addressables package version that the content was built using.
public string GetBuiltContentAddressablesVersion()
{
string settingsPath = Addressables.BuildPath + "/settings.json";
if (System.IO.File.Exists(settingsPath))
{
string json = System.IO.File.ReadAllText(settingsPath);
ResourceManagerRuntimeData activeRuntimeSettings =
JsonUtility.FromJson<ResourceManagerRuntimeData>(json);
return activeRuntimeSettings.AddressablesVersion;
}
return null;
}
In this example we add a build pre-process hook. When building a player this throws an exception if the content has not been built. This could be useful when 'Build Addressables on Player Build' is not set in Addressables Settings.
#if UNITY_EDITOR
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEditor.AddressableAssets;
using UnityEditor.AddressableAssets.Build;
using UnityEditor.AddressableAssets.Settings.GroupSchemas;
using UnityEditor.Build;
using UnityEditor.Build.Reporting;
using UnityEngine;
using UnityEngine.AddressableAssets;
public class ContentBuiltCheck : IPreprocessBuildWithReport
{
public int callbackOrder => 1;
public void OnPreprocessBuild(BuildReport report)
{
// we don't want to throw the exception in our continuous integration environment
if (Application.isBatchMode)
{
return;
}
var settingsPath = Addressables.BuildPath + "/settings.json";
if (!File.Exists(settingsPath))
{
throw new System.Exception("Player content has not been built. Aborting build until content is built. This can be done from the Addressables window in the Build->Build Player Content menu command.");
}
}
}
#endif