Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: Disastercake on November 18, 2014, 08:15:19 PM

Title: UIProgressBar no longer has a cachedGameObject
Post by: Disastercake on November 18, 2014, 08:15:19 PM
UIProgressBar no longer has a cachedGameObject, and so no other components that derive from it do either (like  scrollbars).  Is this by design?  It would be very useful if it remained in there.
Title: Re: UIProgressBar no longer has a cachedGameObject
Post by: ArenMook on November 19, 2014, 03:36:28 PM
cachedGameObject is on the UIRect, and only on the UIRect. It was never on the progress bar as far as I remember.
Title: Re: UIProgressBar no longer has a cachedGameObject
Post by: Disastercake on November 20, 2014, 03:59:36 AM
That's weird because I had code pointing to that variable previously.  Perhaps I had hacked it in myself and forgot about it.  Is it possible to add it in or are you wanting to avoid that?  It's pretty useful to be able to toggle any NGUI component on and off for different menu items in the same panel (and know that it is automatically being cached).
Title: Re: UIProgressBar no longer has a cachedGameObject
Post by: ArenMook on November 20, 2014, 06:45:31 PM
What for? Just replace it with .gameObject.
Title: Re: UIProgressBar no longer has a cachedGameObject
Post by: Disastercake on January 09, 2015, 08:30:47 PM
I read that .gameObject has a lot of overhead to it, which is why people cache the game object (like NGUI does).  Is that no longer the case?
Title: Re: UIProgressBar no longer has a cachedGameObject
Post by: ArenMook on January 10, 2015, 12:48:33 PM
Its certainly faster to cache it if you access it every frame. Are you accessing it every frame? If so, why do you need it on the progress bar? NGUI doesn't.
Title: Re: UIProgressBar no longer has a cachedGameObject
Post by: Nicki on January 10, 2015, 05:51:06 PM
.gameObject doesn't have much of an overhead. At worst, the first time it's used, it counts as a GetComponent<GameObject>() and on later uses there's some form of internal caching which makes it faster. Not as fast as doing your own local reference, but almost. So, no real biggie unless it's in an update loop, in which case, make your own cached version.