Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

dialog unity using gui

Discussion in 'Scripting' started by ganixx, Nov 3, 2015.

  1. ganixx

    ganixx

    Joined:
    Feb 2, 2015
    Posts:
    29
    hi
    i have the next code to make the dialog sistem of my game, but it doesn´t work, i don´t know why because unity not show errors, pls help

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class dialogo : MonoBehaviour {
    5.  
    6.     public string [] botones;
    7.     public string [] respuestas;
    8.     public bool displaydialog=true;
    9.     public int quest=0;
    10.     // Use this for initialization
    11.     void Start () {
    12.    
    13.     }
    14.    
    15.     // Update is called once per frame
    16.     void Update () {
    17.    
    18.     }
    19.  
    20.     void OnGui()
    21.     {
    22.         GUILayout.BeginArea (new Rect (700, 600, 400, 400));
    23.         if (displaydialog && quest == 0)
    24.             {
    25.             GUILayout.Label(respuestas[0]);
    26.             GUILayout.Label(respuestas[1]);
    27.  
    28.             if(GUILayout.Button(botones[0]))
    29.                         {
    30.                 quest=1;displaydialog=false;
    31.                         }
    32.  
    33.  
    34.         if (GUILayout.Button (botones [1])) {
    35.  
    36.  
    37.             displaydialog=false;
    38.  
    39.             }
    40.         }
    41.  
    42.         if (displaydialog && quest == 0)
    43.         {
    44.             GUILayout.Label(respuestas[2]);
    45.             if(GUILayout.Button(botones[2]))displaydialog=false;
    46.  
    47.             }
    48.         GUILayout.EndArea ();
    49.     }
    50.  
    51.     void OnTriggerEnter()
    52.     { displaydialog=true;
    53.  
    54.     }
    55.     void OnTriggerExit()
    56.     { displaydialog=false;
    57.        
    58.     }
    59.  
    60. }
    61.  
     
  2. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    You probably want to switch to the new UI tools.
     
  3. ganixx

    ganixx

    Joined:
    Feb 2, 2015
    Posts:
    29
    maybe,but i need a tutorial using gui tool apply to make a dilogue sistem.

    do you have idea where i can found one?
     
  4. kuschi85

    kuschi85

    Joined:
    Nov 1, 2015
    Posts:
    2
  5. ganixx

    ganixx

    Joined:
    Feb 2, 2015
    Posts:
    29
    i dowload the video and practicse that... i think it will take time to do a dialog , tks if i have any other questios i say in this post
     
  6. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    This may be a useful starting point

     
  7. ganixx

    ganixx

    Joined:
    Feb 2, 2015
    Posts:
    29
    ok i dowloadn and try to do it and no hit my head whit the pc jeje, thakns