简体   繁体   English

自定义.plist文件未添加到ios项目

[英]Custom .plist file not added to ios project

I'm storing materials paths in .plist in Unity and rendering them in my objects at runtime. 我将材料路径存储在Unity中的.plist中,并在运行时将它们渲染到我的对象中。 Code looks like this: 代码如下所示:

public static Dictionary<string, object> uiElements = (Dictionary<string, object>)Plist.readPlist("Assets/EditUI.plist");

foreach (string key in User.purchasedItems.Keys) 
{
    GameObject tmpObj = (GameObject)Instantiate(Resources.Load(key) ,position ,Quaternion.identity);
    tmpObj.transform.localScale = Vector3.one;
    tmpObj.SetActive(true);
}

It's working fine in Unity editor, but when I made iOS build (Xcode project), nothing is being loaded. 它在Unity编辑器中运行良好,但是当我进行iOS构建(Xcode项目)时,没有任何内容被加载。 Everything is empty. 一切都是空的。 I couldn't figure out whether the problem is with plist path or loading on runtime. 我无法弄清楚问题是plist路径还是运行时加载。 Something related to custom plist is also posted here with no solution: 与自定义plist相关的东西也在这里发布,没有解决方案:

http://answers.unity3d.com/questions/468667/custom-plist-file-not-added-to-ios-project.html http://answers.unity3d.com/questions/468667/custom-plist-file-not-added-to-ios-project.html

You'll need to use Unity's iOS Scripting API to add the file to the Xcode project. 您需要使用Unity的iOS Scripting API将文件添加到Xcode项目中。 Create a PostProcessBuild script that does something like this: 创建一个PostProcessBuild脚本,它执行以下操作:

[PostProcessBuild]
public static void OnPostProcessBuild(BuildTarget buildTarget, string path)
{
    // Go get pbxproj file
    string projPath = path + "/Unity-iPhone.xcodeproj/project.pbxproj";

    // PBXProject class represents a project build settings file,
    // here is how to read that in.
    PBXProject proj = new PBXProject ();
    proj.ReadFromFile (projPath);

    // This is the Xcode target in the generated project
    string target = proj.TargetGuidByName ("Unity-iPhone");

    // Copy plist from the project folder to the build folder
    FileUtil.CopyFileOrDirectory ("Assets/EditUI.plist", path + "/EditUI.plist");
    proj.AddFileToBuild (target, proj.AddFile("EditUI.plist", "EditUI.plist"));

    // Write PBXProject object back to the file
    proj.WriteToFile (projPath);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 iOS for Windows Phone 8中的plist文件 - File like plist in iOS for Windows Phone 8 尽管有info.plist属性,Xamarin IOS项目仍允许旋转 - Xamarin IOS project allows rotation despite info.plist property 将文件添加到项目,该文件将被添加到exe,并且可以在运行时访问 - Adding a file to a project, that will be added to the exe, and be accessable at runtime 我无法写入添加到项目中的 txt 文件 - I can't write to txt file which is added into project XNA的内容项目中添加的引用的文件路径是什么? - What is the file path for references added in Content project in XNA? 如何在编译之前读取添加到项目中的文本文件? - How to read a text file which is added to project before complilation? 添加单元测试项目时,已存在名称已存在的文件或文件夹 - A file or folder with the name already exists when unit test project added 如何引用添加到Visual Studio项目的json文件 - How to refer to json file added to Visual Studio project 获取添加到可执行应用程序项目的文件夹中的“链接文件”的路径? - Get path to “linked file” added to a folder in a project of executable app? 在其他系统中作为指向 Visual Studio 项目的链接添加的文件路径丢失 - Loss of file path added as a link to Visual Studio project in other systems
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM