unity打开excel表格_unity 读取excel表 生成asset资源文件

这篇博客介绍了如何在Unity中读取Excel表格数据,并将数据转换为ActorDataList资产文件,如ActorData.xml、ActorDataA.xml和ActorDataB.xml。通过AssetDatabase创建或更新资源,确保数据正确导入Unity项目。
摘要由CSDN通过智能技术生成

lListAsset (rowList, xmlPath);

}

/** 生成数据文件 */

static void CreatXmlListAsset(List&ltRow&gt rl, string xmlPath)

{

if (xmlPath.Contains ("ActorData.xml")) {

GActorDataList actorDataList = null;

UnityEngine.Object oldFile = AssetDatabase.LoadAssetAtPath (xmlPath, typeof(GActorDataList));

bool newFile = false;

if (oldFile) {

actorDataList = oldFile as GActorDataList;

}else{

actorDataList = new GActorDataList();

newFile = true;

}

actorDataList.ActorDataList.Clear ();

for (int i = 0; i &lt rl.Count; i++) {

ActorData newData = new ActorData();

Row data = rl[i];

newData.id = data["id"];

newData.type = GetInt(data["type"]);

newData.nameIds = data["nameIds"];

actorDataList.ActorDataList.Add(newData);

}

if (newFile) {

AssetDatabase.CreateAsset(actorDataList, FILE_PATH + "ActorDataList.asset");

}else{

EditorUtility.SetDirty(actorDataList);

}

}

else if (xmlPath.Contains ("ActorDataA.xml")) {

GActorDataList actorDataList = null;

UnityEngine.Object oldFile = AssetDatabase.LoadAssetAtPath (xmlPath, typeof(GActorDataList));

bool newFile = false;

if (oldFile) {

actorDataList = oldFile as GActorDataList;

}else{

actorDataList = new GActorDataList();

newFile = true;

}

actorDataList.ActorDataList.Clear ();

for (int i = 0; i &lt rl.Count; i++) {

ActorData newData = new ActorData();

Row data = rl[i];

newData.id = data["id"];

newData.type = GetInt(data["type"]);

newData.nameIds = data["nameIds"];

actorDataList.ActorDataList.Add(newData);

}

if (newFile) {

AssetDatabase.CreateAsset(actorDataList, FILE_PATH + "ActorDataListA.asset");

}else{

EditorUtility.SetDirty(actorDataList);

}

}

else if (xmlPath.Contains ("ActorDataB.xml")) {

GActorDataList actorDataList = null;

UnityEngine.Object oldFile = AssetDatabase.LoadAssetAtPath (xmlPath, typeof(GActorDataList));

bool newFile = false;

if (oldFile) {

actorDataList = oldFile as GActorDataList;

}else{

actorDataList = new GActorDataList();

newFile = true;

}

actorDataList.ActorDataList.Clear ();

fo

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值