Closed Donovand4 closed 3 years ago
Ahoy! I just tested both method (sequence callback and tween OnComplete) by adding a log to OnComplete/AppendCallback and both work (and those should be pretty failsafe). What "_uiAnimationSpeed" are you using? Maybe the problem is there?
Hi, its a float of 0.2f which works and the UI fades out or in depending of the method but the blocking of raycasts or anything within that method is not called.
Ok I think I have more info. My version of Unity is 2020.2.0f1 and the DOTween Version is 1.2.420.
If I create the sequence before using it by using the below my oncomplete, onkill and appendcallback fails to call the method.
[SerializeField] private float _uiAnimationSpeed = 0.2f;
private CanvasGroup canvasGroup;
Sequence OptionUISequence;
private void Start()
{
canvasGroup = GetComponent<CanvasGroup>();
OptionUISequence = DOTween.Sequence();
}
private void InitializeUI()
{
OptionUISequence.Append(canvasGroup.DOFade(1, _uiAnimationSpeed)).OnComplete(EnableCanvas);
}
private void EnableCanvas()
{
canvasGroup.blocksRaycasts = true;
}
But when I create it like this then it works. I'm trying to cache the sequence so that I don't need to reinitialize it every time the event is triggered. Is it possible to do it that way?
private void InitializeUI() { Sequence OptionUISequence = DOTween.Sequence(); OptionUISequence.Append(canvasGroup.DOFade(1, _uiAnimationSpeed)).OnComplete(EnableCanvas); }
Hi, not official here, but i'd like to help if i can. I understood that:
What do you mean by "it" - could you restate your last question?
Hi, not official here, but i'd like to help if i can. I understood that:
- the second code example you posted works correctly for you, and
- you are asking if "it is possible to do it that way"
What do you mean by "it" - could you restate your last question?
What I was actually trying to do is to declare the sequence then append the sequence further down in the script. This is an example of what does not work.
Sequence OptionUISequence;
private void Start()
{
OptionUISequence = DOTween.Sequence();
}
private void InitializeUI()
{
OptionUISequence.Append(canvasGroup.DOFade(1, _uiAnimationSpeed)).OnComplete(EnableCanvas);
}
private void EnableCanvas()
{
canvasGroup.blocksRaycasts = true;
}
The below is an example of what does work but recreates the sequence everytime it runs which might not be efficient.
private void InitializeUI() { Sequence OptionUISequence = DOTween.Sequence(); OptionUISequence.Append(canvasGroup.DOFade(1, _uiAnimationSpeed)).OnComplete(EnableCanvas); }
So if I understand you correctly, then
Note that I am by no means not an expert on GC issues. I don't know, how frequently your sequence would be created/run, and whether it would actually lead to GC issues. Still, my general advice is to never pre-optimize code for performance: always prioritize readability over hypothetical performance gains that are not really understood and manually verified by testing / profiling.
However, take a look at what the documentation has to say with respect to "recycling": http://dotween.demigiant.com/documentation.php?api=SetRecyclable
From my understanding, the implementation does object pooling, if recycling is enabled - so if you enable it, no new object is created.
I will have a read through the article. Thanks will close.
Hi All, I found that the OnComplete() or appendcallback is not triggered when running the below. Its triggered from an event and in the UI, I dont see the canvasgroup raycaster being modified. The fade (which is also on the same canvasgroup) works perfectly but the callback or oncomplete seems to be skipped. I added a debug.log to the disablecanvas but that was not executed. Anything I am doing wrong? If move the "canvasGroup.blocksRaycasts = false;" to above the tween it runs so it cannot be the code. I have also confirmed that I am using the latest version.
this is another version that uses a sequence and its has the same problem.
OptionUISequence.Append(canvasGroup.DOFade(0, _uiAnimationSpeed)).AppendCallback(DisableCanvas);