IEnumerator Printing() { int colindex = texs[cnt].IndexOf(":"); // ":"의 인덱스를 가져온다. string name = texs[cnt].Substring(0, colindex); //가져온 인덱스 이전까지의 문자열을 받는다. Debug.Log(name); TalkNameChange.NameChange(name); //받은 문자열로 TalkNameChange의 메소드 실행 for (int j = colindex + 1; j < texs[cnt].Length; j++) // ":"의 인덱스 다음 부분부터 스크립트의 마지막부분까지 for문 실행 { tex.text += texs[cnt][j]; //현재 문자열에 해당 index의 문자를 추가한다. //if (!au.isPlaying) au.PlayOneShot(typingsound, 0.1f);//효과음이 미재생인 상태에서 타이핑되는경우 타이핑 효과음 출력 yield return(new WaitForSeconds(0.01f)); //다음 글자 출력까지 0.1초 동안 대기 } yield return(new WaitForSeconds(1f)); //효과음 delay를 위해 1초동안 대기 //au.Stop();//효과음 정지 StopCoroutine("Printing"); //코루틴 정지. 이 상태에서 enter가 들어올때까지 문자열은 변하지 않는다. }
IEnumerator Printing() { script.text = ""; //다음 스크립트 출력 이전에 기존에 있던 내용을 지움. int colindex = scripts[cnt].IndexOf(":"); // ":"의 인덱스를 가져온다. string name = scripts[cnt].Substring(0, colindex); //NameChanger.Name = name; TalkNameChange.NameChange(name); for (int j = colindex + 1; j < scripts[cnt].Length; j++) // ":"의 인덱스 다음 부분부터 스크립트의 마지막부분까지 for문 실행 { script.text += scripts[cnt][j]; //현재 문자열에 해당 index의 문자를 추가한다. //if (!au.isPlaying) au.PlayOneShot(typingsound, 0.1f);//효과음이 미재생인 상태에서 타이핑되는경우 타이핑 효과음 출력 yield return(new WaitForSeconds(0.1f)); //다음 글자 출력까지 0.1초 동안 대기 } yield return(new WaitForSeconds(1f)); //효과음 delay를 위해 1초동안 대기 //au.Stop();//효과음 정지 StopCoroutine("Printing"); //코루틴 정지. 이 상태에서 enter가 들어올때까지 문자열은 변하지 않는다. }