Advertisement
Guest User

TestDialog.cs

a guest
Apr 22nd, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.99 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class TestDialog : MonoBehaviour {
  6.  
  7.     DialogSystem dialog;
  8.     // Use this for initialization
  9.     void Start () {
  10.         dialog = DialogSystem.instance;
  11.     }
  12.  
  13.     public string[] s = new string[]
  14.     {
  15.         "vi tester:Hele gruppen",
  16.         "gdsfgdfhm",
  17.         "smodlhdt"
  18.     };
  19.  
  20.     int index = 0;
  21.    
  22.     // Update is called once per frame
  23.     void Update () {
  24.         if (Input.GetKeyDown(KeyCode.Space))
  25.         {
  26.             if(!dialog.isSpeaking || dialog.isWaitingForUserInput)
  27.             {
  28.                 if(index >=s.Length)
  29.                 {
  30.                     return;
  31.                 }
  32.                 Say(s[index]);
  33.                 index++;
  34.             }
  35.         }
  36.     }
  37.     void Say (string s)
  38.     {
  39.         string[] parts = s.Split(':');
  40.         string speech = parts[0];
  41.         string speaker = (parts.Length >= 2) ? parts[1] : "";
  42.  
  43.         dialog.Say(speech, speaker);
  44.     }
  45.  
  46.  
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement