博客
关于我
Unity——lua文件(.lua后缀的文件)无法被Unity识别问题
阅读量:488 次
发布时间:2019-03-07

本文共 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/

你可能感兴趣的文章
vue3+element-plus 项目中 el-switch 刷新后自动触发change?坑就藏在这里!
查看>>
nodejs npm常用命令
查看>>
nodejs npm常用命令
查看>>
Nodejs process.nextTick() 使用详解
查看>>
NodeJS yarn 或 npm如何切换淘宝或国外镜像源
查看>>
nodejs 中间件理解
查看>>
nodejs 创建HTTP服务器详解
查看>>
nodejs 发起 GET 请求示例和 POST 请求示例
查看>>
NodeJS 导入导出模块的方法( 代码演示 )
查看>>
nodejs 开发websocket 笔记
查看>>
nodejs 的 Buffer 详解
查看>>
nodejs 的 path 模块详解
查看>>
NodeJS 的环境变量: 开发环境vs生产环境
查看>>
nodejs 读取xlsx文件内容
查看>>
nodejs 运行CMD命令
查看>>
Nodejs+Express+Mysql实现简单用户管理增删改查
查看>>
nodejs+nginx获取真实ip
查看>>
nodejs-mime类型
查看>>
NodeJs——(11)控制权转移next
查看>>
NodeJS、NPM安装配置步骤(windows版本)
查看>>