Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: seahorsevn on February 17, 2014, 10:52:57 AM

Title: NGUI Interface disappear after call NGUITool.Destroy
Post by: seahorsevn on February 17, 2014, 10:52:57 AM
Hi,

I'm working on a game for Window Phone. I have HUD for whole game and one message box made by NGUI Widget and I put message box into prefab. When player active an event I show the message box and destroy it with NGUITools.Destroy, but all HUD elements disappear and only reappear when player touch on the button region. I don't want the HUD disappear, please help me! Thank you!

This is my code

  1. public void ShowMessageBox(string content)
  2.         {
  3.  
  4.                
  5.                         Transform anchor_center = transform.FindChild("anchor_center");
  6.                         NGUITools.AddChild(anchor_center.gameObject,prefabMessageBox);
  7.                         Transform dialog_frame = anchor_center.FindChild("prefab_msgbox(Clone)").FindChild("Panel");
  8.                         UILabel pDialogMessage = (UILabel)dialog_frame.FindChild("dialog_msg").GetComponent<UILabel>();
  9.                         pDialogMessage.text = content;
  10.                         cl_ActionButton acceptButton = (cl_ActionButton)anchor_center.GetComponentInChildren<cl_ActionButton>();
  11.                         acceptButton.ButtonOnClickEvent += new delegateButtonOnClick(m_pDropletManager.buttonOnClick);
  12.                        
  13.                
  14.         }
  15.         public void HideMessageBox()
  16.         {
  17.                 NGUITools.Destroy(transform.FindChild("anchor_center").FindChild("prefab_msgbox(Clone)").gameObject);
  18.         }
Title: Re: NGUI Interface disappear after call NGUITool.Destroy
Post by: ArenMook on February 17, 2014, 12:09:12 PM
What?

If you destroy something, it goes away. If you don't want it to go away, don't destroy it.

Also... finding stuff by name is a terrible practice that will bite you in the ass. Keep that in mind.