[游戏开发][Unity] Xlua生成wrap文件报错、打AB包Wrap报错

这篇具有很好参考价值的文章主要介绍了[游戏开发][Unity] Xlua生成wrap文件报错、打AB包Wrap报错。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

 Xlua生成wrap文件,自带添加了ref字段报错

例如Material生成MaterialWrap时,EnableKeyword(in LocalKeyword keyword);带着in关键字,所以在Wrap文件中会自动在参数前生成ref关键字导致编译不过

解决办法:

换Xlua版本就好了,也不知道我xlua当时从哪个版本copy过来的,换了xlua-master里的Xlua源码,再次生成wrap就没问题了。

 打包时Xlua Wrap文件报错:

Assets\XLua\Gen\UnityEngine_AudioSourceWrap.cs(169,57): error CS1061: 'AudioSource' does not contain a definition for 'PlayOnGamepad' and no accessible extension method 'PlayOnGamepad' accepting a first argument of type 'AudioSource' could be found (are you missing a using directive or an assembly reference?)
Assets\XLua\Gen\UnityEngine_AudioSourceWrap.cs(197,57): error CS1061: 'AudioSource' does not contain a definition for 'DisableGamepadOutput' and no accessible extension method 'DisableGamepadOutput' accepting a first argument of type 'AudioSource' could be found (are you missing a using directive or an assembly reference?)
Assets\XLua\Gen\UnityEngine_AudioSourceWrap.cs(227,57): error CS1061: 'AudioSource' does not contain a definition for 'SetGamepadSpeakerMixLevel' and no accessible extension method 'SetGamepadSpeakerMixLevel' accepting a first argument of type 'AudioSource' could be found (are you missing a using directive or an assembly reference?)
Assets\XLua\Gen\UnityEngine_AudioSourceWrap.cs(256,57): error CS1061: 'AudioSource' does not contain a definition for 'SetGamepadSpeakerMixLevelDefault' and no accessible extension method 'SetGamepadSpeakerMixLevelDefault' accepting a first argument of type 'AudioSource' could be found (are you missing a using directive or an assembly reference?)
Assets\XLua\Gen\UnityEngine_AudioSourceWrap.cs(286,57): error CS1061: 'AudioSource' does not contain a definition for 'SetGamepadSpeakerRestrictedAudio' and no accessible extension method 'SetGamepadSpeakerRestrictedAudio' accepting a first argument of type 'AudioSource' could be found (are you missing a using directive or an assembly reference?)
Assets\XLua\Gen\UnityEngine_AudioSourceWrap.cs(311,33): error CS0234: The type or namespace name 'GamepadSpeakerOutputType' does not exist in the namespace 'UnityEngine' (are you missing an assembly reference?)
Assets\XLua\Gen\UnityEngine_AudioSourceWrap.cs(313,63): error CS0117: 'AudioSource' does not contain a definition for 'GamepadSpeakerSupportsOutputType'
Assets\XLua\Gen\UnityEngine_AudioSourceWrap.cs(982,54): error CS1061: 'AudioSource' does not contain a definition for 'gamepadSpeakerOutputType' and no accessible extension method 'gamepadSpeakerOutputType' accepting a first argument of type 'AudioSource' could be found (are you missing a using directive or an assembly reference?)
Assets\XLua\Gen\UnityEngine_AudioSourceWrap.cs(1396,29): error CS0234: The type or namespace name 'GamepadSpeakerOutputType' does not exist in the namespace 'UnityEngine' (are you missing an assembly reference?)
Assets\XLua\Gen\UnityEngine_AudioSourceWrap.cs(1397,23): error CS1061: 'AudioSource' does not contain a definition for 'gamepadSpeakerOutputType' and no accessible extension method 'gamepadSpeakerOutputType' accepting a first argument of type 'AudioSource' could be found (are you missing a using directive or an assembly reference?)
Assets\XLua\Gen\UnityEngine_MeshRendererWrap.cs(137,60): error CS1061: 'MeshRenderer' does not contain a definition for 'scaleInLightmap' and no accessible extension method 'scaleInLightmap' accepting a first argument of type 'MeshRenderer' could be found (are you missing a using directive or an assembly reference?)
Assets\XLua\Gen\UnityEngine_MeshRendererWrap.cs(151,54): error CS1061: 'MeshRenderer' does not contain a definition for 'receiveGI' and no accessible extension method 'receiveGI' accepting a first argument of type 'MeshRenderer' could be found (are you missing a using directive or an assembly reference?)
Assets\XLua\Gen\UnityEngine_MeshRendererWrap.cs(165,61): error CS1061: 'MeshRenderer' does not contain a definition for 'stitchLightmapSeams' and no accessible extension method 'stitchLightmapSeams' accepting a first argument of type 'MeshRenderer' could be found (are you missing a using directive or an assembly reference?)
Assets\XLua\Gen\UnityEngine_MeshRendererWrap.cs(211,35): error CS1061: 'MeshRenderer' does not contain a definition for 'scaleInLightmap' and no accessible extension method 'scaleInLightmap' accepting a first argument of type 'MeshRenderer' could be found (are you missing a using directive or an assembly reference?)
Assets\XLua\Gen\UnityEngine_MeshRendererWrap.cs(227,23): error CS1061: 'MeshRenderer' does not contain a definition for 'receiveGI' and no accessible extension method 'receiveGI' accepting a first argument of type 'MeshRenderer' could be found (are you missing a using directive or an assembly reference?)
Assets\XLua\Gen\UnityEngine_MeshRendererWrap.cs(242,35): error CS1061: 'MeshRenderer' does not contain a definition for 'stitchLightmapSeams' and no accessible extension method 'stitchLightmapSeams' accepting a first argument of type 'MeshRenderer' could be found (are you missing a using directive or an assembly reference?)
Error building Player because scripts had compiler errors

解决方法

 Xlua的配置文件有个专门添加[LuaCallCSharp]、[CSharpCallLua]、[BlackList]的方法,在xlua-master源码里是ExampleGenConfig.cs或者ExampleConfig.cs

BlackList的作用:生成的wrap文件中屏蔽字段和方法

BlackList如何配置:

屏蔽变量和方法的方式如下,都罗列出来了,对号入座。

屏蔽变量 

new List<string>(){"UnityEngine.AudioSource", "gamepadSpeakerOutputType"},

 屏蔽无参方法

new List<string>(){"UnityEngine.AudioSource", "DisableGamepadOutput"},

 屏蔽参数是Int32的方法

new List<string>(){"UnityEngine.AudioSource", "PlayOnGamepad","System.Int32"},

屏蔽多参数方法 

new List<string>(){"UnityEngine.AudioSource", "SetGamepadSpeakerRestrictedAudio","System.Int32","System.Boolean"},

请注意,AudioSource前面的命名空间不能省略

找到BlackList

 //黑名单
    [BlackList]
    public static List<List<string>> BlackList = new List<List<string>>()  {
                new List<string>(){"System.Xml.XmlNodeList", "ItemOf"},
                new List<string>(){"UnityEngine.WWW", "movie"},
    #if UNITY_WEBGL
                new List<string>(){"UnityEngine.WWW", "threadPriority"},
    #endif
                new List<string>(){"UnityEngine.Texture2D", "alphaIsTransparency"},
                new List<string>(){"UnityEngine.Security", "GetChainOfTrustValue"},
                new List<string>(){"UnityEngine.CanvasRenderer", "onRequestRebuild"},
                new List<string>(){"UnityEngine.Light", "areaSize"},
                new List<string>(){"UnityEngine.Light", "lightmapBakeType"},
    #if UNITY_ANDROID
                new List<string>(){"UnityEngine.Light", "SetLightDirty"},
                new List<string>(){"UnityEngine.Light", "shadowRadius"},
                new List<string>(){"UnityEngine.Light", "shadowAngle"},
    #endif
                new List<string>(){"UnityEngine.WWW", "MovieTexture"},
                new List<string>(){"UnityEngine.WWW", "GetMovieTexture"},
                new List<string>(){"UnityEngine.AnimatorOverrideController", "PerformOverrideClipListCleanup"},
    #if !UNITY_WEBPLAYER
                new List<string>(){"UnityEngine.Application", "ExternalEval"},
    #endif
                new List<string>(){"UnityEngine.GameObject", "networkView"}, //4.6.2 not support
                new List<string>(){"UnityEngine.Component", "networkView"},  //4.6.2 not support
                new List<string>(){"System.IO.FileInfo", "GetAccessControl", "System.Security.AccessControl.AccessControlSections"},
                new List<string>(){"System.IO.FileInfo", "SetAccessControl", "System.Security.AccessControl.FileSecurity"},
                new List<string>(){"System.IO.DirectoryInfo", "GetAccessControl", "System.Security.AccessControl.AccessControlSections"},
                new List<string>(){"System.IO.DirectoryInfo", "SetAccessControl", "System.Security.AccessControl.DirectorySecurity"},
                new List<string>(){"System.IO.DirectoryInfo", "CreateSubdirectory", "System.String", "System.Security.AccessControl.DirectorySecurity"},
                new List<string>(){"System.IO.DirectoryInfo", "Create", "System.Security.AccessControl.DirectorySecurity"},
                new List<string>(){"UnityEngine.MonoBehaviour", "runInEditMode"},
            };

然后把我下面这一段加入到中间

    //Texture
    new List<string>(){"UnityEngine.Texture", "imageContentsHash"},

    //MeshRenderer
    new List<string>(){"UnityEngine.MeshRenderer", "scaleInLightmap"},
    new List<string>(){"UnityEngine.MeshRenderer", "receiveGI"},
    new List<string>(){"UnityEngine.MeshRenderer", "stitchLightmapSeams"},
    new List<string>(){"UnityEngine.MeshRenderer", "scaleInLightmap"},
    new List<string>(){"UnityEngine.MeshRenderer", "receiveGI"},
    new List<string>(){"UnityEngine.MeshRenderer", "stitchLightmapSeams"},

    //AudioSource
    new List<string>(){"UnityEngine.AudioSource", "gamepadSpeakerOutputType"},
    new List<string>(){"UnityEngine.AudioSource", "PlayOnGamepad","System.Int32"},
    new List<string>(){"UnityEngine.AudioSource", "DisableGamepadOutput"},
    new List<string>(){"UnityEngine.AudioSource", "SetGamepadSpeakerMixLevel","System.Int32","System.Int32"},
    new List<string>(){"UnityEngine.AudioSource", "SetGamepadSpeakerMixLevelDefault","System.Int32"},
    new List<string>(){"UnityEngine.AudioSource", "SetGamepadSpeakerRestrictedAudio","System.Int32","System.Boolean"},
    new List<string>(){"UnityEngine.AudioSource", "GamepadSpeakerSupportsOutputType","UnityEngine.GamepadSpeakerOutputType"},

再次执行Clear Generated Code、Generated Code后,会发现Wrap文件里的相关变量和方法都消失了。再次打包则不会报错文章来源地址https://www.toymoban.com/news/detail-765822.html

到了这里,关于[游戏开发][Unity] Xlua生成wrap文件报错、打AB包Wrap报错的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • [游戏开发][Unity]Assetbundle下载篇(1)热更前准备与下载AB包清单

    打包与资源加载框架目录 热更流程都不是固定的,每个人写的状态机也有所差别,但是一些必要步骤肯定不可能少,例如下载清单,对比版本,下载AB包,标记下载完成。我接下来的每一篇文章都是下载AB包的重要步骤,大概率是不能省略的。 检查沙盒路径是否存在 检查下载

    2024年02月15日
    浏览(39)
  • [游戏开发][Unity]Assetbundle加载篇(4)检查断点续传以及开始下载AB包

    打包与资源加载框架目录 下 载 AB包之前,要检查该AB包是否下载中断过,例如用户杀程序,卡死等情况。 前文有讲解过,下载AB包会先下载到临时文件夹,全部下载成功后,全部剪切到persistentDataPath沙盒目录中。 回顾一下之前的筛选机制,哪些AB包可以加入下载列表,其中并

    2024年02月08日
    浏览(47)
  • [游戏开发][Unity]Assetbundle下载篇(4)检查断点续传以及开始下载AB包

    打包与资源加载框架目录 下 载 AB包之前,要检查该AB包是否下载中断过,例如用户杀程序,卡死等情况。 前文有讲解过,下载AB包会先下载到临时文件夹,全部下载成功后,全部剪切到persistentDataPath沙盒目录中。 回顾一下之前的筛选机制,哪些AB包可以加入下载列表,其中并

    2024年02月09日
    浏览(46)
  • 第二节 弹性盒子( justify-content属性、align-items属性、flex-direction属性、flex-wrap属性)

    弹性盒子( Flexible Box 或 flexbox):CSS3的一种新布局模式。 是一种当页面需要适应不同的屏幕大小以及设备类型时确保元素拥有恰当的行为的布局方式。 row(默认值):主轴为水平方向,起点在左端;  row-reverse:主轴为水平方向,起点在右端; column:主轴为垂直方向,起点

    2023年04月17日
    浏览(47)
  • Unity xLua开发环境搭建与基础进阶

    Unity是一款非常流行的游戏开发引擎,而xLua是一个为Unity开发者提供的Lua框架,可以让开发者使用Lua语言来进行游戏开发。在本文中,我们将介绍如何搭建Unity xLua开发环境,并进行基础进阶的学习。 环境搭建 首先,我们需要下载xLua框架,可以在GitHub上找到最新的版本。下载

    2024年02月22日
    浏览(49)
  • Unity3D xLua开发环境搭建详解

    xLua是一种基于Lua语言的开发框架,可以帮助开发者在Unity3D中使用Lua脚本来开发游戏。 对惹,这里有一 个游戏开发交流小组 ,希望大家可以点击进来一起交流一下开发经验呀! 在本文中,我们将详细介绍如何搭建Unity3D xLua开发环境,包括安装Unity3D和xLua插件,配置环境变量

    2024年02月22日
    浏览(41)
  • 修改element-ui中Tabs标签页下划线默认颜色的方法以及为什么设置了.el-tabs /deep/ .el-tabs__nav-wrap::after不起效果

    类似图上的灰色线段,这是Tabs的默认样式, 在项目中的路径位置在:node_modules/element-ui/theme-chalk/tag.css   (我原本想在源文件直接改颜色的,但是找了一圈不知道哪个是他的颜色哈哈哈) 方法是: /deep/ 深度作用操作符:可以使样式作用的更深,例如影响子组件。 同时,

    2024年02月09日
    浏览(38)
  • Unity组件开发--AB包打包工具

    1.项目工程路径下创建文件夹:ABundles 2.AB包打包脚本: 3.需要打包的场景添加到打包配置: 4.unity编辑器生成菜单: 5.场景加载AB包管理器:

    2024年04月28日
    浏览(36)
  • 基于Unity开发WebGL项目加载AB包(三)

    在前两篇文章中,我们分别了解了WebGL如何通过StreamingAssets加载AB包资源(链接:基于Unity开发WebGL项目加载AB包(一)_梵高先森丶的博客-CSDN博客)和如何通过局域网(本地服务器)加载AB包资源(链接:基于Unity开发WebGL项目加载AB包(二)_梵高先森丶的博客-CSDN博客),那么本文,

    2024年02月13日
    浏览(38)
  • 【游戏开发算法每日一记】使用随机prime算法生成错综复杂效果的迷宫(C#,C++和Unity版)

    👨‍💻个人主页 :@元宇宙-秩沅 👨‍💻 hallo 欢迎 点赞👍 收藏⭐ 留言📝 加关注✅! 👨‍💻 本文由 秩沅 原创 👨‍💻 收录于专栏 :Unity基础实战 1.首先全部判定为墙,最外的为路包裹墙( 类似于防止数组越界 ) 2.红色为它的检测范围(假设检测点在如图所示的位置)—

    2024年02月05日
    浏览(41)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包