Search Unity

Setting Text Via Animation clip

Discussion in 'UGUI & TextMesh Pro' started by lulitd, Jun 23, 2017.

  1. lulitd

    lulitd

    Joined:
    Feb 20, 2016
    Posts:
    13
    Hey everyone,

    I'm currently working a cutscene which requires some text changes.

    The entire cutscene is keyed via an animation clip. I would like to also set the text changes via the animation clip.

    As I've discovered I can not add keyframes for strings.

    I suppose one way to do things is to use animation events to trigger the text changes, which works depending on how much text you have.

    Currently, my workflow is:

    1. Store all the text in an array
    2. Use a float for the array's index.(as ints do not show up as a property in an animation clip)
    3. Set the index via the animation clip.
    4. Then in Update set the text (using TextMeshPro)

    For what I'm doing it works well enough, though it does feel a bit hackish. I would love to hear some suggestions on how to improve this workflow.