This plugin is very good! I already use this plugin in my own project.
But I think it will more convenience if you add TFunction callback to this plugin, so we can receive callback for any class we implement.
I already implement this by myself:
UCLASS()
class AiTweenEvent : public AActor
{
…
public:
typedef TFunction<void(AiTweenEvent*, UObject*)> FOnTweenCallbackFunction;
void SetTweenStartCallback(const FOnTweenCallbackFunction& callback) {
OnTweenStartFunction = callback;
};
void SetTweenUpdateCallback(const FOnTweenCallbackFunction& callback) {
OnTweenUpdateFunction = callback;
};
void SetTweenLoopCallback(const FOnTweenCallbackFunction& callback) {
OnTweenLoopFunction = callback;
};
void SetTweenCompleteCallback(const FOnTweenCallbackFunction& callback) {
OnTweenCompleteFunction = callback;
};
…
};
void AiTweenEvent::RunCallbackInterface(UObject* target, FString type) {
if (target)
{
if (type == "start")
{
if (OnTweenStartFunction.IsSet()) {
OnTweenStartFunction.GetValue()(this, target);
}
}
else if (type == "update")
{
if (OnTweenUpdateFunction.IsSet()) {
OnTweenUpdateFunction.GetValue()(this, target);
}
}
else if (type == "loop")
{
if (OnTweenLoopFunction.IsSet()) {
OnTweenLoopFunction.GetValue()(this, target);
}
}
else if (type == "complete")
{
if (OnTweenCompleteFunction.IsSet()) {
OnTweenCompleteFunction.GetValue()(this, target);
}
}
}
}
And add following to each callback phase:
RunCallbackInterface(onTweenCompleteTarget, “complete”);
RunCallbackInterface(onTweenStartTarget, “start”);
RunCallbackInterface(onTweenLoopTarget, “loop”);
RunCallbackInterface(onTweenUpdateTarget, “update”);
Then we can use plugin like this way:
AiTweenEvent* pEvent = UiTween::UMGRTMoveFromToSimple(tweenName, pWidget, fromVec, toVec, actionParam.Duration, EEaseType::linear, “”);
pEvent->SetTweenStartCallback([this](AiTweenEvent* pEvent, UObject* pTarget) {
OnTweenStartImplement(pEvent, pTarget);
});
pEvent->SetTweenUpdateCallback([this](AiTweenEvent* pEvent, UObject* pTarget) {
OnTweenStartImplement(pEvent, pTarget);
});
pEvent->SetTweenLoopCallback([this](AiTweenEvent* pEvent, UObject* pTarget) {
OnTweenStartImplement(pEvent, pTarget);
});
pEvent->SetTweenCompleteCallback([this](AiTweenEvent* pEvent, UObject* pTarget) {
OnTweenStartImplement(pEvent, pTarget);
});