using Febucci.UI.Core; using Febucci.UI.Effects; using UnityEngine; namespace Febucci.UI.Examples { [AddComponentMenu("")] public class DefaultEffectsExample : MonoBehaviour { public TypewriterCore typewriter; TextAnimatorSettings settings; private void Awake() { UnityEngine.Assertions.Assert.IsNotNull(typewriter, $"Text Animator Player component is null in {gameObject.name}"); settings = TextAnimatorSettings.Instance; UnityEngine.Assertions.Assert.IsNotNull(settings, $"Text Animator Settings is null."); } string AddEffect(TextAnimatorSettings.Category category, string tag) where T: ScriptableObject { return $"{category.openingSymbol}{tag}{category.closingSymbol}{tag}{category.openingSymbol}/{category.closingSymbol}, "; } private void Start() { const char quote = '"'; //builds the text with all the default tags string builtText = "You can add effects by using rich text tags." + $"\nExample: writing {quote}I'm cold{quote} will result in {quote}I'm cold{quote}." + $"\n\n Effects that animate through time are called {quote}Behaviors{quote}, and the default tags are: "; foreach (var effect in typewriter.TextAnimator.DatabaseBehaviors.Data) { if(!effect) continue; builtText += AddEffect(settings.behaviors, effect.TagID); } builtText += $"\n\nEffects that animate letters while they appear on screen are called {quote}Appearances{quote} and the default tags are: "; foreach (var effect in typewriter.TextAnimator.DatabaseAppearances.Data) { if(!effect) continue; builtText += AddEffect(settings.appearances, effect.TagID); } //shows the text dynamically (typewriter like) typewriter.ShowText(builtText); } } }