前言

在xlua的lua脚本中使用dotween,官方的文档中有提到可以导出,但未介绍详细的步骤,相信比较多的朋友有需要,刚好项目中也在使用xlua和dotween,所以做个笔记。

基础知识:

xLua:https://github.com/Tencent/xLua

dotween:http://dotween.demigiant.com/

关于dotween的使用,可以参考我之前的文章

DOTween文档

DoTween(HOTween V2) 教程

我的测试环境:

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

最新文章

  1. adb工具获取appPackage和appActivity
  2. Objective-C三方库: ZXEasyCoding
  3. IOS学习笔记 O1
  4. js 编码、解码与asp.net 编码、解码
  5. 命令查看java的class字节码文件、verbose、synchronize、javac、javap
  6. 转:php park、unpark、ord 函数使用方法(二进制流接口应用实例)
  7. Windows服务的基本配置和安装
  8. log4e插件的安装和使用
  9. io-nio 区别示意图
  10. [poj1185]炮兵阵地_状压dp
  11. Oracle 中DATE类型的计算
  12. MySQL事务笔记
  13. 使用第三方工具Xtrabackup进行MySQL备份
  14. AtCoder Beginner Contest 069 ABCD题
  15. mysql concat_ws 与 concat 多字段模糊匹配应用
  16. spring-mvc---Controller参数绑定的类型
  17. Linux下安装配置 Jdk1.6+Tomcat6+Apache2.2.x+jk_mod1.2 详解
  18. 在linux本地下载ftp中的文件
  19. collections 模块常用方法学习
  20. CSS3的新属性

热门文章

  1. Repcached实现memcached复制
  2. 1232: [Usaco2008Nov]安慰奶牛cheer
  3. protected private public 的区别
  4. HBase架构
  5. vpn的实现原理
  6. 解决MVC模型验证在IE 6 7下不起作用或者报错
  7. FDG内存分配器笔记
  8. pip --upgrade批量更新过期的python库
  9. git pull错误记录及解决
  10. jQuery插件之validation插件