我上传了一个Unity WebGL游戏,是否可以在IndexedDB内的/idbfs中手动创建一个永久目录?

m1m5dgzv  于 2022-12-09  发布在  IndexedDB
关注(0)|答案(1)|浏览(367)

在Unity项目中,我在一个空的游戏对象中附加了一个脚本,代码如下所示:是否可以自己创建持久目录?

public class TestScript : MonoBehaviour
{
    private void Start()
    {
        GetDefaultDirectory();
        CreateCustomDirectory();
    }

    // It returns "idbfs/" following with a random hash, such as "66ae5aa9b53f4a794ca331d30d2cb976".
    public void GetDefaultDirectory()
    {
        Debug.Log(Application.persistentDataPath);
    }

    // Manually create a directory
    // This can be created but will be flushed away after the page is reloaded.
    public void CreateCustomDirectory()
    {
#if UNITY_WEBGL
        Directory.CreateDirectory("idbfs/abcdef");
#endif
    }
}

下面是IndexedDB的外观。这里只显示了一个随机哈希,我的自定义目录“idbfs/abcdef”不会显示。但当我使用Debug.Log检查时,它确实存在。

lnvxswe2

lnvxswe21#

在WebGL中,路径是通过md5传递的,这就是为什么你不能识别你的目录名。
这里是doc

相关问题