// Update is called once per frame void Update() { if (on) { subtitle.gameObject.SetActive(true); if (subtitle_clip != null) { subtitle_clip.StartClip(); if (subtitle_clip.IsClipDone()) { on = false; } } } else { if (subtitle_clip != null) { subtitle_clip.Reset(); } subtitle.gameObject.SetActive(false); } }
//Set the dialog clip. // give it the audio clip, the AudioSource to play the clip, the name of the animation clip, and the Animator component public void SetDialogClip(AudioClip aclip, AudioSource source, string animationClip, string animatedCharacterName) { if (aclip == null) { Debug.LogWarning("A dialog clip entered was null!"); return; } else if (source == null) { Debug.LogError("Source is null!"); return; } if (dialog_clip == null) { dialog_clip = new DialogClip(aclip, source, animationClip, animatedCharacterName); } else { dialog_clip.Reset(); dialog_clip.clip = aclip; dialog_clip.animationClip = animationClip; dialog_clip.animatedCharacterName = animatedCharacterName; } }