Hi all,
I’m trying to make a subtitle system where:
- text is displayed
- for an amount of time
- after which, it disappears
- OR the player can click to make it disappear
- There can be a chain of text
The class for the text and time:
class SubtitleThread (MonoBehaviour):
public text as string
public timer as single = 5.0
The class to manage it:
class SubtitleSystem (MonoBehaviour):
public static showSubtitle as bool = false
public static subtitleText as string = ""
def PlaySubtitle (subtitleThreads as (SubtitleThread)) as System.Collections.IEnumerator:
for eachThread in subtitleThreads:
yield StartCoroutine("PlaySubtitleCR", eachThread)
showSubtitle = false
subtitleText = ""
def PlaySubtitleCR (oneThread as SubtitleThread) as System.Collections.IEnumerator:
subtitleText = oneThread.text
showSubtitle = true
yield WaitForSeconds(oneThread.timer)
def ClearSubtitle ():
StopCoroutine("PlaySubtitleCR")
Clicking while showSubtitle == true
will call ClearSubtitle()
.
However, this does not seem to work. PlaySubtitle will not run when called, and I’m not sure why. When I comment out the “yield” line, it will run - but without the time and “click to continue” functionality.
Any help would be greatly appreciated. Thank you.