[英]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.