小编mll*_*ild的帖子

Unity C# - 是否有比 UnityWebRequest、WWW 或 File.ReadAllBytes 更快的方法从磁盘加载大量图像文件?

它是一款 VN 风格的游戏,包含用户生成的内容,我需要立即加载图像。

由于它是用户生成的内容,图像将位于游戏的文件夹中。由于同样的原因,我无法预加载图像,因为我不知道下一个要加载的图像是什么。

我尝试过 UnityWebRequest、WWW 或 File.ReadAllBytes,但它们的延迟都比我预期的要长,即使我在 SSD 上运行它也是如此。

有更快的方法吗?

我用于测试图像加载时间的代码

using UnityEngine;
using System.IO;
using UnityEngine.Networking;
using System.Collections;
using UnityEngine.UI;
using System.Threading.Tasks;

/// <summary>
/// 2020/19/05 -- Unity 2019.3.3f1 -- C#
/// </summary>

public class itemCreatorImageLoad : MonoBehaviour
{
    public Image image; // this is referencing to a UI Panel
    private Texture2D texture2D;
    private UnityWebRequest uwr;
    public RawImage rawImage; // this is referencing to a UI rawImage

// path = @"C:\UnityTests\Referencing\Referencing\Assets\StreamingAssets\Items\image.png"
// the @ handles the / and …
Run Code Online (Sandbox Code Playgroud)

c# image unity-game-engine image-loading

5
推荐指数
1
解决办法
2176
查看次数

标签 统计

c# ×1

image ×1

image-loading ×1

unity-game-engine ×1