博客
关于我
在xlua中使用DoTween动画插件
阅读量:456 次
发布时间:2019-03-06

本文共 1905 字,大约阅读时间需要 6 分钟。

在使用XLua编程热更新项目时,如果需要使用DoTween动画插件,可以按照以下步骤进行设置:

步骤一:创建自定义静态类

在项目中创建一个新的C#脚本文件,命名为DoTweenCallXLua

public static class DoTweenCallXLua{    [LuaCallCSharp]    [ReflectionUse]    public static List
luaCallCsharpList = new List
() { 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.ABSSequential), typeof(DG.Tweening.Core.TweenerCore<, , 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), };}

步骤二:生成代码

在Unity编辑器中,使用XLua的生成工具将上述脚本文件处理。XLua会识别[LuaCallCSharp][ReflectionUse]特性,并为这些类型生成相应的C#代码,使它们可以在Lua脚本中被调用。

步骤三:在XLua中调用相关方法

在你的XLua脚本中,通过访问DoTweenCallXLua.luaCallCsharpList来获取这些类型。例如:

-- 在XLua脚本中使用这些类型local type = DoTweenCallXLua.luaCallCsharpList[name]

注意事项

  • 方法名称正确性:确保DoTween的方法名称准确无误,方法名大多为大写,如DO系列方法。如果名称错误,可能导致调用失败。

  • XLua配置:确保XLua的生成工具正确识别并处理了自定义类中的特性。如果有问题,参考XLua的官方文档或示例项目。

  • 代码生成验证:在生成代码后,测试调用这些类型是否成功,从而避免在实际项目中出现运行错误。

  • 通过以上步骤,你可以在XLua项目中使用DoTween插件,充分发挥其动画功能,同时保持代码的可维护性和灵活性。

    转载地址:http://zlhyz.baihongyu.com/

    你可能感兴趣的文章
    poj 1258 Agri-Net
    查看>>
    quagga 和 zebos
    查看>>
    poj 1286 Necklace of Beads
    查看>>
    POJ 1321 棋盘问题
    查看>>
    poj 1321(回溯)
    查看>>
    Qt高级——Qt元对象系统源码解析
    查看>>
    qt调用vs2008编写的dll动态库(隐式调用)
    查看>>
    Qt读取注册表默认值
    查看>>
    poj 1679 判断MST是不是唯一的 (次小生成树)
    查看>>
    POJ 1703 Find them, Catch them
    查看>>
    POJ 1703 Find them, Catch them 并查集
    查看>>
    POJ 1738 An old Stone Game(石子合并)
    查看>>
    POJ 1740 A New Stone Game(博弈)题解
    查看>>
    Qt网络编程之实例二POST方式
    查看>>
    POJ 1765 November Rain
    查看>>
    poj 1860 Currency Exchange
    查看>>
    POJ 1961 Period
    查看>>
    POJ 2019 Cornfields (二维RMQ)
    查看>>
    poj 2057 The Lost House 贪心思想在动态规划上的应用
    查看>>
    poj 2057 树形DP,数学期望
    查看>>