Lua 调用 dotween

这里必须要把value传过去,貌似lua的闭包不会传到外边

using DG.Tweening;
using UnityEngine;
using UnityEngine.UI;

public static class DoTweenUtils
{
    
    
    public static Tween DoVector2(Vector2 start, Vector2 end, float duration, TweenCallback<Vector2> action)
    {
    
    
        return DOTween.To(() => start, value =>
        {
    
    
            start = value;
            action(value); 
        }, end, duration);
    }

    public static void SetEase(Tween tween, Ease ease)
    {
    
    
        tween.SetEase(ease);
    }

    public static void SetCompleteAction(Tween tween, TweenCallback action)
    {
    
    
        tween.onComplete = action;
    }
}

lua

-- 移动插值相机
local startPos = Vector2(mapMgr.mapFocus.worldX, mapMgr.mapFocus.worldY);
local endPos = Vector2(worldX, worldY);
DoTweenUtils.DoVector2(startPos, endPos,2,function(value)
	mapMgr:MoveTo(value.x, value.y)
end)

lua 回调各种骚操作

 DoTweenUtils.SetCompleteAction(tween, function()    self:CameraMoveFinish(vec2Pos)  end)

猜你喜欢

转载自blog.csdn.net/A13155283231/article/details/118678566