对参考文章1的内容进行学习。打包后的.txt文件是否 能够被unity打包后的.exe文件 读取。
using UnityEngine;
using System.Collections;
using System.Xml.Linq;
using System.Xml;
using System.IO;
public class Test_XML : MonoBehaviour {
private string _result;
// Use this for initialization
void Start()
{
StartCoroutine(LoadXML());
}
// Update is called once per frame
void Update()
{
}
/// <summary>
/// 如前文所述,streamingAssets只能使用www来读取,
/// 如果不是使用www来读取的同学,就不要问为啥读不到streamingAssets下的内容了。
/// 这里还可以使用了persistenDataPath来保存从streamingassets那里读到内容。
/// </summary>
IEnumerator LoadXML()
{
string sPath = Application.streamingAssetsPath + "/Test.xml";
WWW www = new WWW(sPath);
yield return www;
_result = www.text;
}
void OnGUI()
{
GUIStyle titleStyle = new GUIStyle();
titleStyle.fontSize = 20;
titleStyle.normal.textColor = new Color

本文探讨了在Unity中将项目打包为.exe文件后,如何读取StreamingAssets文件夹内的.txt.xml文本文件。实验表明,.xml文件可以成功在打包后的.exe中被读取。同时提出了对声音和图片文件MOD化的可能性。
最低0.47元/天 解锁文章
1万+

被折叠的 条评论
为什么被折叠?



