c# - Resources.Load 返回 null

标签 c# unity3d

我有以下结构 Assets -> Resources -> Levels.json 然后我运行以下方法:

void LoadLevel(int level){
    TextAsset json = Resources.Load<TextAsset>("Levels.json");
    print(json);
    Levels.CreateFromJSON(json.text);
}

发生了什么,jsonnull,我不确定为什么......我看过其他示例,看起来我正在这样做对...

最佳答案

来自 http://docs.unity3d.com/ScriptReference/Resources.html

Returns the asset at path if it can be found otherwise returns null. Only objects of type will be returned if this parameter is supplied. The path is relative to any Resources folder inside the Assets folder of your project, extensions must be omitted.

删除 .json。

关于c# - Resources.Load 返回 null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36116367/

相关文章:

c# - 在 WPF 中处理来自 c++ dll 的未处理异常

c# - C#-如何按顺时针顺序(tl,tr,br,bl)对4点列表进行排序,以用于opencv getPerspective?

android - 尝试将 Android 应用程序上传到 Play 商店时出现问题

unity3d - Unity iPhone 应用程序大小太大

function - 在 CG Shader 中为 unity3d 的两个 channel 共享一个函数

c# - Unity 3d 光子网络

c# - 为 Tablet PC 开发时,如何确定用户点击的是鼠标还是笔?

c# - 使用 XmlWriter 创建 xml 文件

c# - EF Core 2.1 启动缓慢

c# - 是否可以使用枚举动态获取静态类?