public void ActivateButton(TextSettings settings, Action <int> callback) { if (button != null) { button.enabled = true; button.gameObject.SetActive(true); button.onClick.AddListener(() => { callback?.Invoke(0); buttonSFX?.Play(); button.onClick = new Button.ButtonClickedEvent(); }); button.interactable = !settings.strikethrough; button.GetComponent <OnHoverCallback>().enabled = !settings.strikethrough; } }
private Sequence AnimatePerCharacter(StoryText text, Action <int> callback, string characterIndex = "") { textMeshPro.color = Color.clear; textMeshPro.text = text.ProcessText(); List <Color> ColorMapping = text.MapColor(attributesLookup); CharTweener _tweener = textMeshPro.GetCharTweener(); SetTextSettings(text); SoundEffectProfile textBlip = defaultTextTic; if (characterIndex != "") { textBlip = attributesLookup.GetCharacterAttributes(characterIndex).soundPing; } var sequence = DOTween.Sequence(); for (var i = 0; i < textMeshPro.text.Length; i++) { var timeOffset = Mathf.Lerp(0, 1, i / (float)(textMeshPro.text.Length + 1)); var charSequence = DOTween.Sequence(); if ((i % 2 == 0 && textMeshPro.text.Length < 20) || i % 4 == 0) { charSequence.AppendCallback(() => textBlip?.Play()); } charSequence.Join(_tweener.DOColor(i, ColorMapping[i], 0.01f)) .Join(_tweener.DOScale(i, 0, 0.01f).From()); if (i == textMeshPro.text.Length - 1) { charSequence.AppendInterval(0.1f) .AppendCallback(() => { ActivateButton(text.settings, callback); }); } sequence.Insert(timeOffset * text.settings.speed, charSequence); } return(sequence); }
private Sequence AnimatePerWord(StoryText text, Action <int> callback) { textMeshPro.text = text.ProcessText(); List <Color> ColorMapping = text.MapColor(attributesLookup); CharTweener _tweener = textMeshPro.GetCharTweener(); SoundEffectProfile textBlip = defaultTextTic; textMeshPro.color = Color.clear; var sequence = DOTween.Sequence(); sequence.AppendInterval(text.settings.speed); int i = 0; while (i < textMeshPro.text.Length) { int j = i; sequence.AppendCallback(() => textBlip?.Play()); while (j < textMeshPro.text.Length - 1 && textMeshPro.text[j] != ' ') { sequence.Join(_tweener.DOColor(j, ColorMapping[j], 0.01f)) .Join(_tweener.DOScale(j, 0, 0.01f).From()); j++; } sequence.AppendInterval(text.settings.speed); i = j; i++; } sequence.AppendInterval(0.1f) .AppendCallback(() => { ActivateButton(text.settings, callback); }); return(sequence); }