Author Topic: Making UIButton Invisible  (Read 14665 times)

JRoch

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 140
    • View Profile
Re: Making UIButton Invisible
« Reply #15 on: November 02, 2012, 11:29:50 AM »
Philip has it right.  If you look at the two functions that allow you to add and retrieve items from the tracker, they are always expected to be of type GameObject.

You can, of course, write your own classes that have a different expected type for the hashtable.  It would be inadvisable to try to implement a hashtable tracker that stores any type, which you then cast on retrieval... mostly because as a human you'd end up forgetting details and be forever mis-using return values and troubleshooting the resulting bugs.

Divya Talluri

  • Guest
Re: Making UIButton Invisible
« Reply #16 on: November 03, 2012, 03:39:58 AM »
I am accessing like MyBtn.gameobject in the script.Everything is fine when I am in the same Scene, but when moved from this scene to another scene,comes back to this scene getting that error.
As when moved to another scene instances are destroyed(may be this is the reason).I have used DontDestroyOnLoad() method on this gameobject, still it is giving the same errors

1.MyBtn Cannot add item to GlobalGameObjectTracker hashtable.

2.MissingReferenceException: The object of type 'GameObject' has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.
NGUITools.SetActive (UnityEngine.GameObject go, Boolean state) (at Assets/NGUI/Scripts/Internal/NGUITools.cs:540)