本文共 704 字,大约阅读时间需要 2 分钟。
官方手册:
解决方法:
将如下文件放入Editor文件夹下,等Unity自动刷新或重新打开Unity即可识别。
using System.IO;using UnityEditor.Experimental.AssetImporters;using UnityEngine;[ScriptedImporter(1, ".lua")]public class LuaImporter : ScriptedImporter{ public override void OnImportAsset(AssetImportContext ctx) { //读取文件内容 var luaTxt = File.ReadAllText(ctx.assetPath); //转成TextAsset(Unity可识别类型) var assetsText = new TextAsset(luaTxt); //将对象assetText添加到导入操作(AssetImportContext)的结果中。 ctx.AddObjectToAsset("main obj", assetsText); //将对象assetText作为导入操作的主要对象。 ctx.SetMainObject(assetsText); }}
这样子就可以被正确识别为TextAsset文件一样的东西了,可以在Project窗口搜索栏写入t:TextAsset进行搜索出所有.lua文件啦,打AB包时能正常打包了。
转载地址:http://igucz.baihongyu.com/