外部资源加载

约定需要外部加载的资源为外部资源,如程序打包后可以直接替换的视频、音频、图片等资源。

使用方式

需要外部加载的资源,可以通过调用Managements.Resource.Append...相关接口进行资源加载,随后便可以使用Managements.Resource.Get接口获取资源

using System.IO;
using UnityEngine;
using UNIHper;

public class SceneEntryScript : SceneScriptBase
{
    // Called once after scene is loaded
    private async void Start()
    {
        // 将StreamingAssets/Textures下的所有图片加入资源系统
        var _loadedTextures = await Managements.Resource.AppendTexture2Ds(
            Path.Combine(Application.streamingAssetsPath, "Textures")
        );

        // 获取已加载的名为"external_background"的图片
        var _background = Managements.Resource.Get<Texture2D>("external_background");
    }
}

Last updated