Advertisement
AndrewRosyaev

InstantiateDialog.cs

May 16th, 2016
909
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.03 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class InstantiateDialog : MonoBehaviour
  5. {
  6.     public TextAsset ta;
  7.     public Dialog dialog;
  8.     public int currentNode;
  9.     public bool ShowDialogue;
  10.  
  11.     public GUISkin skin;
  12.  
  13.     void Start ()
  14.     {
  15.         dialog = Dialog.Load (ta);
  16.         skin = Resources.Load ("Skin") as GUISkin;
  17.     }
  18.  
  19.     void Update () {
  20.  
  21.     }
  22.  
  23.     void OnGUI()
  24.     {
  25.         GUI.skin = skin;
  26.         if (ShowDialogue) {
  27.             GUI.Box (new Rect (Screen.width / 2 - 300, Screen.height - 300, 600, 250), "");
  28.             GUI.Label (new Rect (Screen.width / 2 - 250, Screen.height - 280, 500, 90), dialog.nodes [currentNode].NpcText);
  29.             for (int i = 0; i < dialog.nodes [currentNode].answers.Length; i++) {
  30.                 if (GUI.Button (new Rect (Screen.width / 2 - 250, Screen.height - 200 + 25 * i, 500, 25), dialog.nodes [currentNode].answers [i].text,skin.label)) {
  31.                     if (dialog.nodes [currentNode].answers [i].end == "true")
  32.                     {
  33.                         ShowDialogue = false;
  34.                     }
  35.                     currentNode = dialog.nodes [currentNode].answers [i].nextNode;
  36.                 }
  37.             }
  38.         }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement