xLua中导出Dotween
本文为作者原创,转载请注明出处:https://www.cnblogs.com/zhaoqingqing/p/6753701.html
前言#
在xlua的lua脚本中使用dotween,官方的文档中有提到可以导出,但未介绍详细的步骤,相信比较多的朋友有需要,刚好项目中也在使用xlua和dotween,所以做个笔记。
基础知识:
xLua:https://github.com/Tencent/xLua
dotween:http://dotween.demigiant.com/
关于dotween的使用,可以参考我之前的文章
我的测试环境:
xLua 2.1.6
dotween 1.1.x
unity 5.3.5/5.4
本文的测试代码:
https://github.com/zhaoqingqing/blog_samplecode/blob/master/unity_helper/XLuaCustomExport.cs
https://github.com/zhaoqingqing/blog_samplecode/blob/master/unity_helper/xlua_dotween_test.lua
导出Dotween#
1、在项目的Asset目录下(自己项目的Scripts目录),新建一个class,命名为:XLuaCustomExport.cs
2、导出脚本如下,如果在手机上调用报错,但PC上正常,请检查是否添加了[ReflectionUse]标签
using System; using System.Collections.Generic; using System.Linq; using System.Reflection; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; using XLua; /// <summary> /// xlua自定义导出 /// </summary> public static class XLuaCustomExport { /// <summary> /// dotween的扩展方法在lua中调用 /// </summary> [LuaCallCSharp] [ReflectionUse] public static List<Type> dotween_lua_call_cs_list = new List<Type>() { typeof(DG.Tweening.AutoPlay), typeof(DG.Tweening.AxisConstraint), typeof(DG.Tweening.Ease), typeof(DG.Tweening.LogBehaviour), typeof(DG.Tweening.LoopType), typeof(DG.Tweening.PathMode), typeof(DG.Tweening.PathType), typeof(DG.Tweening.RotateMode), typeof(DG.Tweening.ScrambleMode), typeof(DG.Tweening.TweenType), typeof(DG.Tweening.UpdateType), typeof(DG.Tweening.DOTween), typeof(DG.Tweening.DOVirtual), typeof(DG.Tweening.EaseFactory), typeof(DG.Tweening.Tweener), typeof(DG.Tweening.Tween), typeof(DG.Tweening.Sequence), typeof(DG.Tweening.TweenParams), typeof(DG.Tweening.Core.ABSSequentiable), typeof(DG.Tweening.Core.TweenerCore<Vector3, Vector3, DG.Tweening.Plugins.Options.VectorOptions>), typeof(DG.Tweening.TweenCallback), typeof(DG.Tweening.TweenExtensions), typeof(DG.Tweening.TweenSettingsExtensions), typeof(DG.Tweening.ShortcutExtensions), typeof(DG.Tweening.ShortcutExtensions43), typeof(DG.Tweening.ShortcutExtensions46), typeof(DG.Tweening.ShortcutExtensions50), //dotween pro 的功能 //typeof(DG.Tweening.DOTweenPath), //typeof(DG.Tweening.DOTweenVisualManager), }; }
xLua中调用Dotween#
在Lua中调用dotween的示例如下:
-- transform:DOMove(Vector3.zero, 3, false); --场景中绑定LuaBehaviour,执行Unity的默认函数 function start() print("lua start ."); local tween = self.transform:DOMoveX(10,3) --tween:OnComplete(){ -- print("move callback") --} end
作者:赵青青 一名在【网易游戏】做游戏开发的程序员,擅长Unity3D,游戏开发,.NET等领域。
本文版权归作者和博客园共有,欢迎转载,转载之后请务必在文章明显位置标出原文链接和作者,谢谢。
如果本文对您有帮助,请点击【推荐】您的赞赏将鼓励我继续创作!想跟我一起进步么?那就【关注】我吧。
本文版权归作者和博客园共有,欢迎转载,转载之后请务必在文章明显位置标出原文链接和作者,谢谢。
如果本文对您有帮助,请点击【推荐】您的赞赏将鼓励我继续创作!想跟我一起进步么?那就【关注】我吧。
分类:
Unity 技术积累
标签:
热更新
, u3d-framework
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· .NET Core 托管堆内存泄露/CPU异常的常见思路
· PostgreSQL 和 SQL Server 在统计信息维护中的关键差异
· C++代码改造为UTF-8编码问题的总结
· DeepSeek 解答了困扰我五年的技术问题
· 为什么说在企业级应用开发中,后端往往是效率杀手?
· 10亿数据,如何做迁移?
· 推荐几款开源且免费的 .NET MAUI 组件库
· 清华大学推出第四讲使用 DeepSeek + DeepResearch 让科研像聊天一样简单!
· 易语言 —— 开山篇
· Trae初体验
2016-04-23 VS设置程序集属性(文件的详细信息)