Author Topic: UIProgressBar no longer has a cachedGameObject  (Read 9600 times)

Disastercake

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 87
  • www.disastercake.com
    • View Profile
    • Disastercake
UIProgressBar no longer has a cachedGameObject
« 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.
Creator of Soul Saga.
http://www.disastercake.com

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIProgressBar no longer has a cachedGameObject
« Reply #1 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.

Disastercake

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 87
  • www.disastercake.com
    • View Profile
    • Disastercake
Re: UIProgressBar no longer has a cachedGameObject
« Reply #2 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).
Creator of Soul Saga.
http://www.disastercake.com

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIProgressBar no longer has a cachedGameObject
« Reply #3 on: November 20, 2014, 06:45:31 PM »
What for? Just replace it with .gameObject.

Disastercake

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 87
  • www.disastercake.com
    • View Profile
    • Disastercake
Re: UIProgressBar no longer has a cachedGameObject
« Reply #4 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?
Creator of Soul Saga.
http://www.disastercake.com

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIProgressBar no longer has a cachedGameObject
« Reply #5 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.

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: UIProgressBar no longer has a cachedGameObject
« Reply #6 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.