Author Topic: NGUI and Unity 5.0 Upgradable APIs  (Read 7449 times)

N3uRo

  • Guest
NGUI and Unity 5.0 Upgradable APIs
« on: October 27, 2014, 02:27:43 PM »
Aren can you fix this? I mean change all the "shortcuts" of Monobehaviour to "GetComponent<T>()".

And you can get rid of mTrans because they say that internally they cache transform component.

Thanks!!

http://unity3d.com/unity/beta/5.0

Meltdown

  • Jr. Member
  • **
  • Thank You
  • -Given: 10
  • -Receive: 0
  • Posts: 56
    • View Profile
Re: NGUI and Unity 5.0 Upgradable APIs
« Reply #1 on: October 27, 2014, 06:39:18 PM »
+1, would love to see this in the next update.

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: NGUI and Unity 5.0 Upgradable APIs
« Reply #2 on: October 27, 2014, 08:14:06 PM »
Changing whatever shortcuts are used should be a simple change, but removing cachedTransform will likely slow things down for everything but 5.0 where it doesn't cache properly and performs a getcomponent every time.

bdominguez

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 38
    • View Profile
Re: NGUI and Unity 5.0 Upgradable APIs
« Reply #3 on: October 28, 2014, 10:00:35 AM »
Changing whatever shortcuts are used should be a simple change, but removing cachedTransform will likely slow things down for everything but 5.0 where it doesn't cache properly and performs a getcomponent every time.

In "SCRIPTING FEATURES"

"“transform” is now cached on the C# side, no more need to cache it yourself."

http://unity3d.com/unity/beta/5.0/release-notes

bac9

  • Full Member
  • ***
  • Thank You
  • -Given: 2
  • -Receive: 4
  • Posts: 113
    • View Profile
Re: NGUI and Unity 5.0 Upgradable APIs
« Reply #4 on: October 28, 2014, 11:01:35 AM »
In "SCRIPTING FEATURES"

"“transform” is now cached on the C# side, no more need to cache it yourself."

http://unity3d.com/unity/beta/5.0/release-notes

That's exactly his point, performance for everyone but 5.0 users will degrade if that change will be done right now.

BeShifty

  • Jr. Member
  • **
  • Thank You
  • -Given: 5
  • -Receive: 7
  • Posts: 52
    • View Profile
Re: NGUI and Unity 5.0 Upgradable APIs
« Reply #5 on: October 28, 2014, 01:26:10 PM »
Unity 5 will automatically rewrite references to .particleSystem, .collider, etc to the GetComponent<T> version when you upgrade your project. That won't help when you need to update to a new version of NGUI though (if NGUI is still using .collider). I would say Aren should run his NGUI project through a Unity 5 upgrade now (since GetComponent<Collider>() is no worse than .collider) but leave the caching of transforms until Unity 5.1 or a time when the majority of users are on Unity 5.

Wisteso

  • Full Member
  • ***
  • Thank You
  • -Given: 21
  • -Receive: 3
  • Posts: 103
    • View Profile
Re: NGUI and Unity 5.0 Upgradable APIs
« Reply #6 on: October 28, 2014, 11:33:53 PM »
Why not just use both approaches and wrap the code with platform dependent compilation macros like... #if UNITY_5_0

It will be a little ugly but it should work.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: NGUI and Unity 5.0 Upgradable APIs
« Reply #7 on: October 29, 2014, 05:24:09 AM »
After you import the NGUI's update, Unity 5 will automatically auto-upgrade everything for you. I've made NGUI Unity 5 compatible more than a month ago.

bdominguez

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 38
    • View Profile
Re: NGUI and Unity 5.0 Upgradable APIs
« Reply #8 on: October 29, 2014, 06:44:18 AM »
After you import the NGUI's update, Unity 5 will automatically auto-upgrade everything for you. I've made NGUI Unity 5 compatible more than a month ago.

And everytime we want to start a new project we have to import NGUI and "auto upgrade"?? That doesn't make any sense.

There could be places in NGUI where you use some "shortcut" in Update/LateUpdate/FixedUpdate and it's going to replace it to "GetComponent<T>()" and it's not being cached with "mComponent = GetComponent<T>()" in Awake/Start