Unity Dialog system voice problem C#

Durum
Üzgünüz bu konu cevaplar için kapatılmıştır...
Onaylı Üye
Katılım
10 Mar 2020
Mesajlar
91
Tepki puanı
5
Ödüller
5
6 HİZMET YILI
[CODE title="Dialogscript"]using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;

public class Dialog : MonoBehaviour
{
public TextMeshProUGUI textDisplay;
public string[] sentences;
private int index;
public float typingspeed;
public GameObject continueButton;
public AudioClip[] sesarray;
public AudioSource ses;
public GameObject audiocontroller;

void Start()
{
StartCoroutine(Type());
}

IEnumerator Type()
{
foreach (char letter in sentences[index].ToCharArray())
{
textDisplay.text += letter;
yield return new WaitForSeconds(typingspeed);
}
}

public void NextSentence()
{

continueButton.SetActive(false);
if (index < sentences.Length - 1)
{
index++;
textDisplay.text = "";
StartCoroutine(Type());
}
else
{
textDisplay.text = "";
continueButton.SetActive(false);
}

}

// Update is called once per frame
void Update()
{
if (textDisplay.text == sentences[0])
{
Debug.Log("1.cumle");
ses.clip = sesarray[0];
if (ses.isPlaying == false)
ses.Play();

}
if (textDisplay.text == sentences[1])
{
Debug.Log("2.cumle");
ses.clip = sesarray[1];
if (ses.isPlaying == false)
ses.Play();
}
if (textDisplay.text == sentences[2])
{
Debug.Log("3.cumle");
ses.clip = sesarray[2];
if (ses.isPlaying == false)
ses.Play();
}


if (textDisplay.text == sentences[index])
{
continueButton.SetActive(true);
}

}
}
[/CODE]

Array düzeni içerisindeki cümleleri buttonla ilerlettikçe sesler çalıyor atıyorum 2. cümle ekrana geldiğinde 2.ses de ekrana geliyor ancak 2. ses bitince tekrar başlıyor bir loop döngüsü içerisinde audio manager içerisindeki loop tiki kapalı. Bu loopu durdurmanın yolunu bulamadım.
 
Durum
Üzgünüz bu konu cevaplar için kapatılmıştır...
Üst