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

My codes working correctly in game scene but when I try build I am getting some errors ?

Discussion in 'Scripting' started by eozdeveci, Nov 9, 2015.

  1. eozdeveci

    eozdeveci

    Joined:
    May 15, 2015
    Posts:
    8
    My codes working in game scene but when I try build (android and pc) I am getting errors. If I take the codes comment line, it is building. Where is my mistake?

    Code (CSharp):
    1.   if(GameObject.Find("EasyMode"))
    2.         {
    3.  
    4.             if(timer>=1800)
    5.             {
    6.                 var yesno = UnityEditor.EditorUtility.DisplayDialog("OYUN BİTTİ", "Yeniden başlamak ister misiniz? ", "Yes", "No");
    7.                 if(yesno == true)
    8.                 {
    9.                     Application.LoadLevel("StartMenu");
    10.                 }
    11.                 else
    12.                 {
    13.                     Application.Quit();
    14.                 }
    15.                 }
    16.             }
    17.         else if(GameObject.Find("NormalMode"))
    18.         {
    19.             if(timer>=1500)
    20.             {
    21.                 var yesno = UnityEditor.EditorUtility.DisplayDialog("OYUN BİTTİ", "Yeniden başlamak ister misiniz?", "Yes", "No");
    22.                 if(yesno == true)
    23.                 {
    24.                     Application.LoadLevel("StartMenu");
    25.                 }
    26.                 else
    27.                 {
    28.                     Application.Quit();
    29.                 }
    30.             }
    31.         }
    32.  
    33.         else if(GameObject.Find("HardMode"))
    34.         {
    35.  
    36.         if(timer>=5)
    37.         {
    38.             var yesno = UnityEditor.EditorUtility.DisplayDialog("OYUN BİTTİ", " Yeniden başlamak ister misiniz? ", "Yes", "No");
    39.             if(yesno == true)
    40.             {
    41.                 Application.LoadLevel("StartMenu");
    42.             }
    43.             else
    44.             {
    45.                 Application.Quit();
    46.             }
    47.         }
    48.         }
     
  2. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,199
    The UnityEditor namespace is only available in the editor. It's used for editor controls (making the game), and cannot be used in the gameplay.

    For game dialogue, either use the old GUI system, or learn the canvas system introduced more recently.
     
    Kiwasi likes this.
  3. eozdeveci

    eozdeveci

    Joined:
    May 15, 2015
    Posts:
    8
    Can you show me a little sample? how will I write gameplay dialog?
     
  4. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860