ContentDirectoryHandle
A handle that references a registered content directory.
阅读时间1 分钟最后更新于 1 个月前
Definition
- Type: Struct
- Namespace: Unity.Loading
- Assembly: UnityEngine.ContentLoadModule
public struct ContentDirectoryHandle
Remarks
This handle is returned from ContentLoadManager.RegisterContentDirectory. Keep the handle to call ContentLoadManager.UnregisterContentDirectory after all loadables and scenes from that directory are released. Valid handles expose metadata such as ContentDirectoryHandle.BuildName from the content manifest, and can be used to query root assets from a specific content directory via ContentLoadManager.GetRootAssets.
Additional Resources: ContentLoadManager.RegisterContentDirectory
Examples
using Unity.Loading;using UnityEngine;namespace BuildDocExamples{ public class ContentDirectoryHandle_RegisterUnregisterExample : MonoBehaviour { void Start() { string path = Application.streamingAssetsPath + "/DLC/MyContent"; ContentDirectoryHandle handle = ContentLoadManager.RegisterContentDirectory(path); try { ScriptableObject[] roots = ContentLoadManager.GetRootAssets<ScriptableObject>(handle); // Load assets from roots, then release loadables and unload scenes before unregistering. } finally { ContentLoadManager.UnregisterContentDirectory(handle); } } }}