Search Unity

Unity NGUI

Discussion in 'Scripting' started by Deleted User, Jul 24, 2013.

  1. Deleted User

    Deleted User

    Guest

    Hello Guys,

    I downloaded Unity 4.20 yesterday and started a new project with NGUI free version downloaded from www.tasharen.com and faced few problems.

    $MainMenu.jpg $Challenges.jpg

    Challenges Button Code

    Code (csharp):
    1.  
    2.  
    3. using UnityEngine;
    4. using System.Collections;
    5.  
    6. public class ChallengesButton : UIButtonSound {
    7.  
    8.     void Start ()
    9.     {
    10.    
    11.     }
    12.    
    13.     void Update ()
    14.     {
    15.    
    16.     }
    17.    
    18.     void OnClick ()
    19.     {
    20.         if (enabled  trigger == Trigger.OnClick)
    21.         {
    22.             Destroy((Object)GameObject.Find("MainMenuScreen"));
    23.             Application.LoadLevel("ChallengesScreen");
    24.         }
    25.     }
    26. }
    27.  
    28.  
    $BackToMainMenu.jpg

    Challenges Screen Menu Button

    Code (csharp):
    1.  
    2.  
    3. using UnityEngine;
    4. using System.Collections;
    5.  
    6. public class ChallengesMenuButton : UIButtonSound {
    7.  
    8.     void Start ()
    9.     {
    10.    
    11.     }
    12.    
    13.     void Update ()
    14.     {
    15.        
    16.     }
    17.    
    18.     void OnClick ()
    19.     {
    20.         if (enabled  trigger == Trigger.OnClick)
    21.         {
    22.             Application.LoadLevel("MainMenuScreen");
    23.             Destroy((Object)GameObject.Find("ChallengesScreen"));  
    24.         }
    25.     }
    26. }
    27.  
    28.  
    Note : I apologize for the odd spaces but I do not know how to remove them as I even tried with small png images

    I even tried putting Destroy() before LoadLevel() but still it didn't work. Funny thing is, the same code worked for all the buttons on the main menu screen but for the Menu button of Challenges, Options, Customize Training screens, the code doesn't destroy the previous scene. Please help!!!
     
  2. fffMalzbier

    fffMalzbier

    Joined:
    Jun 14, 2011
    Posts:
    3,276
    1. For NGUI questions you should post them into the NGUI forum.

    2:
    Maybe thats the problem , a 1 Jear old tool is probably incompatible to Unity 4.2.
     
  3. Deleted User

    Deleted User

    Guest

    Ya I guess you are right. Thanks
     
  4. tonyd

    tonyd

    Joined:
    Jun 2, 2009
    Posts:
    1,224