Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Extremely poor Transform.SetParent performance

Discussion in 'Scripting' started by Bitcloud, Sep 15, 2016.

  1. Bitcloud

    Bitcloud

    Joined:
    Feb 25, 2014
    Posts:
    8
    Hi guys,

    I'm\finding I'm getting large CPU spikes when I use setParent or parent.

    I noticed this issue was mentioned here:
    re: http://forum.unity3d.com/threads/extremely-poor-transform-setparent-performance.406606/

    @Joachim_Ante mentioned that this was improved in b23. I just installed 5.4.1f1 however and the problem for me still exists. Does this version contain the fix?

    This occurs when I parent a large heirarchy to a small one, but not really when I parent a small one to a large one.

    My childHierarchy is about 5 layers deep with several children per layer. parentHeirarchy can be any size, so it seems that the problem occurs when reparenting a large heirarchy, rather than when reparenting INTO a heirarchy if that makes sense.

    Is there a "fix" for this? or perhaps another method? At the moment it's a showstopper for me.

    Thanks in advance
    Lachlan
     
  2. LeftyRighty

    LeftyRighty

    Joined:
    Nov 2, 2012
    Posts:
    5,148
    out of curiosity; having done the research, found a recent thread with active unity dev participation, you've opened a new thread... because?
     
  3. Bitcloud

    Bitcloud

    Joined:
    Feb 25, 2014
    Posts:
    8
    I'm unable to participate in any Beta threads. This issue exists in the latest final release, and according to fixes issued in 5.3b23, shouldn't.
     
  4. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,181
    5.4 beta forums are closed!
     
  5. LeftyRighty

    LeftyRighty

    Joined:
    Nov 2, 2012
    Posts:
    5,148
    ... well... good points all round... :oops::p

    fyi, you didn't tag the dev into this thread, you put an @ and then linked his profile into the thread (if you're typing you seem to have to give it a second to recognise what you're doing).

    @Joachim_Ante should ping a notification to the person :)
     
  6. Bitcloud

    Bitcloud

    Joined:
    Feb 25, 2014
    Posts:
    8
    nice, thanks! Hopefully he'll get a chance to respond here. Beetlejuice beetlejuice beetlejuice!
     
  7. Bitcloud

    Bitcloud

    Joined:
    Feb 25, 2014
    Posts:
    8
    OK so this is not a "solution" per se, but I was able to get better results by disabling the colliders prior to performing the parent.

    eg:

    Code (JavaScript):
    1. for (var c: Collider in obj.GetComponentsInChildren(Collider)) {
    2.      c.enabled = false;
    3. }
    I'd still consider this an issue because recursively disabling colliders like this introduces its own set of potential issues. Still open to other suggestions too!

    Cheers
    Lachlan