Skip to content

DOTweenTMPAnimator .DOColorChar broken when camera size changing #695

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
d-ganieva opened this issue Sep 20, 2024 · 0 comments
Open

DOTweenTMPAnimator .DOColorChar broken when camera size changing #695

d-ganieva opened this issue Sep 20, 2024 · 0 comments

Comments

@d-ganieva
Copy link

d-ganieva commented Sep 20, 2024

Hello
I create an animation of typing text, and everything is fine, but when the camera starts moving at this time, the animation it breaks down. This is reproduced if the canvas on which the text animation takes place is screenspace-camera. if overlay is configured, then everything is fine, but this setting bothers me.
There was also a problem that I couldn't set the text transparency character-by-character in advance (ChangeSymbolsAlpha), changing the color completely for the component (ChangeTextMainColor) helped, so don't be surprised by this oddity :)
here I give an example of minimally reproducible code.

void Awake(){
textAnimator = new DOTweenTMPAnimator(m_text);
}

void Main(){
	m_text.text = _data.text;
	ChangeTextMainColor(0f);
	//ChangeSymbolsAlpha(0f); //not worked
	await scaleTween;
	ShowTextAsync();
}

protected async UniTask ShowTextAsync()
{
	await UniTask.Yield();
	if (fadeTween != null)
	{
		fadeTween.Kill();
	}

	textAnimator.Reset();
	fadeTween = DOTween.Sequence();
	
		for (int i = 0; i < textAnimator.textInfo.characterCount; ++i)
		{
			int num = i;
			if (!textAnimator.textInfo.characterInfo[num].isVisible) continue;
			var color = textAnimator.GetCharColor(num);
			color.a = 1f;
			fadeTween.Insert(charAnimDuration*i,textAnimator.DOColorChar(num, color, charAnimDuration));
		}

	await fadeTween;
	fadeTween = null;
        ChangeTextMainColor(1f);
}

void ChangeTextMainColor(float _alpha)
{
	Color textColor = m_text.color;
	textColor.a = _alpha;
	m_text.color = textColor;
}

void ChangeSymbolsAlpha(float _alpha)
{
	for (int i = 0; i < textAnimator.textInfo.characterCount; ++i)
	{
		if (!textAnimator.textInfo.characterInfo[i].isVisible) continue;
		var color = textAnimator.GetCharColor(i);
		color.a = _alpha;
		textAnimator.SetCharColor(i, color);
	}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant