我正在开发一个需要引用.txt文件的HoloLens项目.我将这些文件存储在Unity的"Resources"文件夹中,并让它们完美地运行(通过Unity运行时):
string basePath = Application.dataPath;
string metadataPath = String.Format(@"\Resources\...\metadata.txt", list);
// If metadata exists, set title and introduction strings.
if (File.Exists(basePath + metadataPath))
{
using (StreamReader sr = new StreamReader(new FileStream(basePath + metadataPath, FileMode.Open)))
{
...
}
}
Run Code Online (Sandbox Code Playgroud)
但是,在为HoloLens部署构建程序时,我能够运行代码,但它不起作用.没有任何资源出现,当检查HoloLens Visual Studio解决方案(通过在Unity中选择构建创建)时,我甚至没有看到资源或资源文件夹.我想知道我做错了什么,或者是否有一种特殊的方式来处理这些资源.
还有图像和声音文件......
foreach (string str in im)
{
spriteList.Add(Resources.Load<Sprite>(str));
}
Run Code Online (Sandbox Code Playgroud)
字符串'str'有效; 它与Unity完全一致.然而,再次,它在通过HoloLens运行时没有加载任何东西.