xLua中导出Dotween
2024-10-06 20:14:38
前言
在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(,)
--tween:OnComplete(){
-- print("move callback")
--}
end
最新文章
- adb工具获取appPackage和appActivity
- Objective-C三方库: ZXEasyCoding
- IOS学习笔记 O1
- js 编码、解码与asp.net 编码、解码
- 命令查看java的class字节码文件、verbose、synchronize、javac、javap
- 转:php park、unpark、ord 函数使用方法(二进制流接口应用实例)
- Windows服务的基本配置和安装
- log4e插件的安装和使用
- io-nio 区别示意图
- [poj1185]炮兵阵地_状压dp
- Oracle 中DATE类型的计算
- MySQL事务笔记
- 使用第三方工具Xtrabackup进行MySQL备份
- AtCoder Beginner Contest 069 ABCD题
- mysql concat_ws 与 concat 多字段模糊匹配应用
- spring-mvc---Controller参数绑定的类型
- Linux下安装配置 Jdk1.6+Tomcat6+Apache2.2.x+jk_mod1.2 详解
- 在linux本地下载ftp中的文件
- collections 模块常用方法学习
- CSS3的新属性