コード例 #1
0
    // Begins an auto play starting w/ a stanza
    private IEnumerator StartAutoPlay(StanzaObject startingStanza, GTinkerText startingTinkerText)
    {
        Debug.Log("autoplay started");

        // If we aren't starting from the beginning, read the audio progress from the startingTinkerText
        GetComponent <AudioSource>().time = startingTinkerText.GetStartTime();
        // Start playing the full stanza audio
        GetComponent <AudioSource>().Play();

        int startingStanzaIndex = stanzas.IndexOf(startingStanza);

        for (int i = startingStanzaIndex; i < stanzas.Count; i++)
        {
            if (i == startingStanzaIndex)
            {
                yield return(StartCoroutine(stanzas[i].AutoPlay(startingTinkerText)));
            }
            else
            {
                yield return(StartCoroutine(stanzas[i].AutoPlay()));
            }

            // Abort early?
            if (CancelAutoPlay())
            {
                autoPlaying = false;
                GetComponent <AudioSource>().Stop();
                yield break;
            }
        }

        autoPlaying = false;
        yield break;
    }