主要是Slua项目Dotween接口的导出
1、OnGetAssemblyToGenerateExtensionMethod里加上Dotween才会导出扩展函数
2、涉及到的泛型函数,需要全部指明类型添加到OnAddCustomClass中
public static void OnGetAssemblyToGenerateExtensionMethod(out List<string> list) {
list = new List<string> {
"Assembly-CSharp",
"DOTween",
};
}
public static void OnAddCustomClass(LuaCodeGen.ExportGenericDelegate add)
{
add(typeof(System.Func<int>), null);
add(typeof(System.Action<int, string>), null);
add(typeof(System.Action<int, Dictionary<int, object>>), null);
add(typeof(List<byte>), "ListByte");
add(typeof(List<int>), "ListInt");
add(typeof(List<long>), "ListLong");
//add(typeof(Dictionary<int, string>), "DictIntStr");
add(typeof(string), "String");
add(typeof(DG.Tweening.AutoPlay), "DG.Tweening.AutoPlay");
add(typeof(DG.Tweening.AxisConstraint), "DG.Tweening.AxisConstraint");
add(typeof(DG.Tweening.Ease), "DG.Tweening.Ease");
add(typeof(DG.Tweening.LogBehaviour), "DG.Tweening.LogBehaviour");
add(typeof(DG.Tweening.LoopType), "DG.Tweening.LoopType");
add(typeof(DG.Tweening.PathMode), "DG.Tweening.PathMode");
add(typeof(DG.Tweening.PathType), "DG.Tweening.PathType");
add(typeof(DG.Tweening.RotateMode), "DG.Tweening.RotateMode");
add(typeof(DG.Tweening.ScrambleMode), "DG.Tweening.ScrambleMode");
add(typeof(DG.Tweening.TweenType), "DG.Tweening.TweenType");
add(typeof(DG.Tweening.UpdateType), "DG.Tweening.UpdateType");
add(typeof(DG.Tweening.DOTween), "DG.Tweening.DOTween");
add(typeof(DG.Tweening.DOVirtual), "DG.Tweening.DOVirtual");
add(typeof(DG.Tweening.EaseFactory), "DG.Tweening.EaseFactory");
add(typeof(DG.Tweening.Tweener), "DG.Tweening.Tweener");
add(typeof(DG.Tweening.Tween), "DG.Tweening.Tween");
add(typeof(DG.Tweening.Sequence), "DG.Tweening.Sequence");
add(typeof(DG.Tweening.TweenParams), "DG.Tweening.TweenParams");
add(typeof(DG.Tweening.Core.ABSSequentiable), "DG.Tweening.Core.ABSSequentiable");
add(typeof(DG.Tweening.TweenCallback), "DG.Tweening.TweenCallback");
add(typeof(DG.Tweening.TweenExtensions), "DG.Tweening.TweenExtensions");
add(typeof(DG.Tweening.TweenSettingsExtensions), "DG.Tweening.TweenSettingsExtensions");
add(typeof(DG.Tweening.ShortcutExtensions), "DG.Tweening.ShortcutExtensions");
add(typeof(DG.Tweening.DOTweenModuleUI), "DG.Tweening.DOTweenModuleUI");
add(typeof(DG.Tweening.DOTweenModuleSprite), "DG.Tweening.DOTweenModuleSprite");
add(typeof(DG.Tweening.DOTweenModuleAudio), "DG.Tweening.DOTweenModuleAudio");
add(typeof(DG.Tweening.DOTweenModulePhysics), "DG.Tweening.DOTweenModulePhysics");
add(typeof(DG.Tweening.DOTweenModulePhysics2D), "DG.Tweening.DOTweenModulePhysics2D");
add(typeof(DG.Tweening.Core.TweenerCore<Vector3, Vector3, VectorOptions>), "DG.Tweening.TweenerCore.Vector3Options");
add(typeof(DG.Tweening.Core.TweenerCore<Vector2, Vector2, VectorOptions>), "DG.Tweening.TweenerCore.Vector2Options");
add(typeof(DG.Tweening.Core.TweenerCore<Rect, Rect, RectOptions>), "DG.Tweening.TweenerCore.RectOptions");
add(typeof(DG.Tweening.Core.TweenerCore<Color, Color, ColorOptions>), "DG.Tweening.TweenerCore.ColorOptions");
add(typeof(DG.Tweening.Core.TweenerCore<Quaternion, Vector3, QuaternionOptions>), "DG.Tweening.TweenerCore.ColorOptions");
add(typeof(DG.Tweening.Core.TweenerCore<Vector4, Vector4, VectorOptions>), "DG.Tweening.TweenerCore.Vector4Options");
add(typeof(DG.Tweening.Core.TweenerCore<float, float, FloatOptions>), "DG.Tweening.TweenerCore.FloatOptions");
add(typeof(DG.Tweening.Core.TweenerCore<double, double, NoOptions>), "DG.Tweening.TweenerCore.DoubleOptions");
add(typeof(DG.Tweening.Core.TweenerCore<int, int, NoOptions>), "DG.Tweening.TweenerCore.IntOptions");
add(typeof(DG.Tweening.Core.TweenerCore<uint, uint, UintOptions>), "DG.Tweening.TweenerCore.UintOptions");
add(typeof(DG.Tweening.Core.TweenerCore<string, string, StringOptions>), "DG.Tweening.TweenerCore.StringOptions");
add(typeof(DG.Tweening.Core.TweenerCore<long, long, NoOptions>), "DG.Tweening.TweenerCore.LongOptions");
add(typeof(DG.Tweening.Core.TweenerCore<ulong, ulong, NoOptions>), "DG.Tweening.TweenerCore.UlongOptions");
add(typeof(DG.Tweening.Core.TweenerCore<Vector3, Path, PathOptions>), "DG.Tweening.TweenerCore.PathOptions");
add(typeof(DG.Tweening.Core.TweenerCore<Quaternion, Quaternion, NoOptions>), "DG.Tweening.TweenerCore.QuaternionNoOptions");
}
使用示例
1、DOTween.To
function Test:DOTweenTo(params)
local startValue=params[1]
local endValue=params[2]
local getter = function()
return startValue
end
local setter = function(x)
Logger:logError(x)
end
local onComplete = function()
end
DG.Tweening.DOTween.To(getter, setter, endValue, 3):OnComplete(onComplete)
end
2、DOTween.Sequence
--1:Append(Tween tween) 在Sequence的最后添加一个tween。
--2:AppendCallback(TweenCallback callback) 在Sequence的最后添加一个回调函数。
--3:AppendInterval(float interval) 在Sequence的最后添加一段时间间隔。
--4:Insert(float atPosition, Tween tween) 在给定的时间位置上放置一个tween,可以实现同时播放多个tween的效果,而不是一个接着一个播放。
--5:InsertCallback(float atPosition, TweenCallback callback) 在给定的时间位置上放置一个回调函数。
--6:Join(Tween tween) 在Sequence的最后一个tween的开始处放置一个tween。
--7:Prepend(Tween tween) 在Sequence开始处插入一个tween,原先的内容根据时间往后移。
--8:PrependCallback(TweenCallback callback) 在Sequence开始处插入一个回调函数。
--9:PrependInterval(float interval) 在Sequence开始处插入一段时间间隔,原先的内容根据时间往后移。
function Test:DOTweenSequence()
local onComplete = function()
Logger:logError("__onComplete__")
end
self.seq=DG.Tweening.DOTween.Sequence()
self.seq:Join(self.testText:getTransform():DOLocalMove(Vector3(10,100,0),5,false):SetEase(DOTweenEase.Linear))
self.seq:Insert(0.5,self.testText:getTransform():DOScale(Vector3(0.5,0.5,0.5),4):SetEase(DOTweenEase.Linear))
self.seq:Append(self.testText:getTransform():DOScale(Vector3(1,1,1),5):SetEase(DOTweenEase.Linear))
self.seq:AppendCallback(onComplete)
end
3、DoLocalPath
function Test:DOLocalPath()
local path1={Vector3(-102,-193,0),Vector3(-102,193,0),Vector3(102,193,0),Vector3(102,-193,0),Vector3(-101,-193,0)}
self.testText:getTransform():DOLocalPath(path1,3,0,1,10,nil):SetLoops(-1, DOTweenLoopType.Restart):SetEase(DOTweenEase.Linear)
end
4、DOTween.Sequence Kill
function Test:DOTweenSequence()
self.seq:Kill(false) --true直接完成Sequence,false不再继续Sequence
end