Author Topic: Update to most recent version slows Unity  (Read 9618 times)

Shemamforash

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 30
    • View Profile
Update to most recent version slows Unity
« on: August 19, 2014, 09:13:18 AM »
So I updated to 3.7.0 today from 3.6.2. Initially I had a load of 'GameObject does not contain a definition for 'GetComponentInParent' so I edited those references in the NGUI code to be someObject.transform.parent.GetComponent<blahdeblah>. The code would then compile but Unity became very slow. I thought it may have been an issue with the NGUI version so I reverted to 3.6.2 in the hope that it would fix the issue but Unity remained very sluggish (5-10 minutes to start up). I tried updating Unity to the newest version, and tried both NGUI versions with it, and finally did a fresh installation of Unity, but the issue hasn't gone away. I assume the issue is an NGUI issue since the sluggishness started immediately after I updated. Has anyone else experienced this, and can anyone offer any ideas for how to resolve it? Thanks!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Update to most recent version slows Unity
« Reply #1 on: August 19, 2014, 01:48:58 PM »
You said yourself you revered back to 3.6.2 and the issue persisted, so that rules out the update. And in any case nothing in NGUI would ever cause Unity to take 5 to 10 minutes to start up. NGUI's code doesn't even run unless you have an NGUI widget in the scene -- which at best happens after Unity has finished loading your scene.

Check what else is running on your PC. Something is likely eating all your CPU.

Chaosgod_Espér

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 28
    • View Profile
Re: Update to most recent version slows Unity
« Reply #2 on: August 19, 2014, 03:51:51 PM »
Same issue here..

changing the GetComponentInparent<>() to .transform.parent.GetComponent<>()

Slows the whole Editor down as hell..
The question is, why is NGUI generating all those Errors about GetComponentInParent?
And why aren´t there more People with that problem?

I updated like before ..
Deleting NGUI Folder,
Import updated NGUI..

EDIT - IMPORTANT
For all that haven´t allready recognized it..  The new NGUI version needs a Unity Update to 4.5.2
But this info is only visible, if you take a look at the Asset Store NGUI page.. if you just update via your Asset Table, you won´t get it..

And i need to say - That´s so fucking bad! I´m not a fan of updating the whole engine, while i´m in the middle of creating a game.. That´s the main reason of fatal errors, that can destroy the complete work..
So..  PLEASE.. no more update forcing, just for NGUI updates ._.
« Last Edit: August 19, 2014, 04:06:57 PM by Chaosgod_Espér »

Shemamforash

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 30
    • View Profile
Re: Update to most recent version slows Unity
« Reply #3 on: August 20, 2014, 04:13:27 AM »
Hi Aren. I am 100% sure that the issue is from NGUI. Believe me I have checked and double checked all the other 3rd party software I am using, and checked the usage of all the other programs I am running. Unity started to lag horribly the moment the NGUI update finished installing, it also doubles my RAM usage (used to be around 2GB, now its slightly above 4GB).

Thanks for the tip Chaosgod, I'm gonna go try fix it now.

EDIT: Nope, changing the GetComponentInChildren did not help me. Also to add to that. If I make a load an empty scene with no NGUI assets in it, Unity runs at it's usual speed. FYI I am using Unity 4.5.3.

EDIT 2: I fixed the issue by reverting to the 4.3.1 version of Unity and NGUI version 3.5.6.
« Last Edit: August 20, 2014, 05:20:58 AM by Shemamforash »

will_brett

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 40
    • View Profile
Re: Update to most recent version slows Unity
« Reply #4 on: August 20, 2014, 07:14:57 AM »
Im having the same issues too. kept getting an error with getcomponent in parent and changed to .transform.parent.GetComponent which removed the errors but now my editor chugs like mad. This must be NGUI related as it only happened when I updated

will_brett

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 40
    • View Profile
Re: Update to most recent version slows Unity
« Reply #5 on: August 20, 2014, 07:56:34 AM »
Also just upgraded to latest Unity and still having major lag issues. Removed NGUI from the project and it went back to running fine no lag

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Update to most recent version slows Unity
« Reply #6 on: August 20, 2014, 05:35:23 PM »
I'm a bit confused by this thread as there are multiple things going on.

1. GetComponentInParent() is a Unity 4.5 feature that NGUI uses inside NGUITools.FindInParents(). NGUI 3.7.0's UICamera won't compile in 4.3 unless you replace GetComponentInParent with NGUITools.FindInParents in 3 places.

2. What does GetComponentInChildren() have to do with any of this? It's used in a few places in NGUI, but in Start() functions and such. I also haven't done anything related to GetComponentInChildren() in the last few months that I can think of.

3. What are the symptoms of the slowdown? Any errors in the console log? Is it only on Unity 4.5.3? I'm on 4.5.2 myself (Windows), but have also tried 4.6 and 5.0 and didn't notice anything wrong.

4. If you replace NGUITools.FindInParents with the version from before, does it fix the issue?
  1.         static public T FindInParents<T> (GameObject go) where T : Component
  2.         {
  3.                 if (go == null) return null;
  4.  #if UNITY_FLASH
  5.                 object comp = go.GetComponent<T>();
  6.  #else
  7.                 T comp = go.GetComponent<T>();
  8.  #endif
  9.                 if (comp == null)
  10.                 {
  11.                         Transform t = go.transform.parent;
  12.  
  13.                         while (t != null && comp == null)
  14.                         {
  15.                                 comp = t.gameObject.GetComponent<T>();
  16.                                 t = t.parent;
  17.                         }
  18.                 }
  19.  #if UNITY_FLASH
  20.                 return (T)comp;
  21.  #else
  22.                 return comp;
  23.  #endif
  24.         }

I need some more details here...

Shemamforash

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 30
    • View Profile
Re: Update to most recent version slows Unity
« Reply #7 on: August 21, 2014, 09:15:09 AM »
Hi Aren

1. This one is easy since I immediately worked out to change the GetComponentInParent() for the earlier Unity version. The issue is that in the later Unity version (4.5.3) GetComponentInParent also appears to be causing Unity to lag.

2. That was a typo- I meant to write GetComponentInParent().

3. There are no errors in the console for me. The entire editor slows down when it is used- selecting items in the hierarchy, resizing windows, selecting assets- all take a long time to perform. The issue started when I tried to use 3.7 with Unity 4.3 with GetComponentInParent replaced. I tried multiple combinations of different versions of NGUI and Unity afterwards, but the only thing that solved the problem was a complete reinstall of Unity 4.3 with the earlier NGUI version. I am hesitant to attempt to get it working again since it took over a day to sort the problem out.

4. Haven't tried it for above reasons.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Update to most recent version slows Unity
« Reply #8 on: August 22, 2014, 03:41:27 AM »
Curious. Well, I'll disable it for the next version just in case.

Shemamforash

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 30
    • View Profile
Re: Update to most recent version slows Unity
« Reply #9 on: August 22, 2014, 07:59:32 AM »
Thanks! Sorry I couldn't help with the specifics, but I don't want to break my project again :S

Maxii

  • Jr. Member
  • **
  • Thank You
  • -Given: 4
  • -Receive: 0
  • Posts: 55
    • View Profile
    • Strategic Forge
Re: Update to most recent version slows Unity
« Reply #10 on: November 28, 2014, 04:58:32 PM »
Did anyone ever find a real problem with Unity4.5's GetComponentInParent() and/or interaction/slowdown with Ngui?

I'd like to change over to using it and replace my own version if this turned out to be a non-issue.
I'm looking for an artist partner to complement my programming skill in developing a space-based Civilization-like empire building game, ala GalCiv2 or Distant Worlds based on Unity3D.

BeShifty

  • Jr. Member
  • **
  • Thank You
  • -Given: 5
  • -Receive: 7
  • Posts: 52
    • View Profile
Re: Update to most recent version slows Unity
« Reply #11 on: November 28, 2014, 06:53:41 PM »
There is no issue. This was a false alarm due to people thinking that GetComponentInParent<T> is equivalent to transform.parent.GetComponent<T>. It's not! go.GetComponentInParent<T> is equivalent to:
  1. Transform trans = go.transform;
  2. while( trans != null ) {
  3.    T comp = trans.GetComponent<T>();
  4.    if( comp != null )
  5.       return comp;
  6.    else
  7.       trans = trans.parent;
  8. }

which checks all ancestors of the GameObject that you're calling it on (and the GO itself). The slowdown itself was due to the fact that NGUI often uses lazy initialization (not a bad thing), and since transform.parent.GetComponent<T> wouldn't find the component it's looking for on the first frame it tries, it would keep trying every frame. Essentially that poor hack caused NGUI to enter a state of perpetual initialization.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Update to most recent version slows Unity
« Reply #12 on: November 30, 2014, 05:24:37 AM »
NGUI's function does the same thing in the while loop.

forrestuv

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Re: Update to most recent version slows Unity
« Reply #13 on: July 19, 2016, 06:18:14 AM »
Hi!
While it works correctly on PC/PS4/ANDROID, it seems that this function makes XboxOne going in Stack Overflow.
Any workaround/solution ?

Unity 5.3.5f1, latest NGUI

thx

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Update to most recent version slows Unity
« Reply #14 on: July 20, 2016, 03:19:18 AM »
What does? GetComponentInParents? Sounds like an important bug you should immediately report to Unity for them to fix.