Search Unity

WindowSwitch true ,false

Discussion in 'Scripting' started by ping20, Jan 23, 2014.

  1. ping20

    ping20

    Joined:
    Jan 20, 2014
    Posts:
    8
    Hello,

    I am coding a video game under Unity 3D and using c#

    I have a problem: I am opening a window into my game and when the player clicks on a rectangle into the window, that closes the window
    here is my code :
    Code (csharp):
    1.     // Converted from UnityScript to C# at http://www.M2H.nl/files/js_to_c.php - by Mike Hergaarden
    2. // Do test the code! You usually need to change a few small bits.
    3.  
    4. using UnityEngine;
    5. using System;
    6. using System.Data;
    7. using MySql.Data.MySqlClient;  
    8. using System.Collections.Generic;
    9.  
    10.  
    11. public class Enn : MonoBehaviour {
    12.     static Boolean WindowSwitch = false;
    13.  
    14.     void  Start (){
    15.     WindowSwitch=true;
    16.        
    17.     }
    18.    
    19.        void  Update (){
    20.        
    21.     }
    22.    
    23.     void  OnGUI ()
    24.        
    25.     {
    26.         if(WindowSwitch ==  true) {
    27.        
    28.        
    29.             Rect windowRect = new Rect(150,150,1000,300);
    30.            
    31.              windowRect = GUI.Window (1, windowRect, setWindow, "Question");  
    32.            
    33.             }
    34.     }
    35.    
    36.    
    37.     void  setWindow ( int windowID  ){
    38.        
    39.         if(windowID==1){
    40.        
    41.             if(GUI.Label(new Rect(15,250,100,400), "moi"));
    42.             {
    43.                 WindowSwitch=false;
    44.  
    45.             }
    46.            
    47.     }
    48.     }
    49.     }
    50.  
    My windowSwitch== true works but when I click on "moi", the window is not closing

    Could you help me please?
    Thanks in advance
     
    Last edited: Jan 23, 2014