我有以下结构 Assets -> Resources -> Levels.json
然后我运行以下方法:
void LoadLevel(int level){
TextAsset json = Resources.Load<TextAsset>("Levels.json");
print(json);
Levels.CreateFromJSON(json.text);
}
发生了什么,json
是 null
,我不确定为什么......我看过其他示例,看起来我正在这样做对...
最佳答案
来自 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/