Search Unity

Do Hierarchy Transform updates propagate to siblings too?

Discussion in 'Editor & General Support' started by NEVER-SETTLE, Feb 11, 2019.

?

Do you optimize your Hierarchy?

  1. Nope

    2 vote(s)
    66.7%
  2. Yes

    1 vote(s)
    33.3%
  3. I didn't even know about this :/

    0 vote(s)
    0.0%
  1. NEVER-SETTLE

    NEVER-SETTLE

    Joined:
    Apr 22, 2018
    Posts:
    30
    According to Unity here "every parent and child of the GameObject needs to be informed".

    There's nothing specified about siblings tough. Can one safely conclude that this means that the propagation only goes vertically (to parents and children) and not horizontally too (to siblings)?

    Example:
    example.png
    if b1 changes, c and a get notified of the change, but does b2 also get notified? It would be great if anyone could point to some docs that explain this or if someone from Unity can comment on this.
    The usecase is that I would like to stick a lot of b's under a :D, not worried about a getting notified, but worried that the other b's also get notified.

    Thanks!
     
  2. MSplitz-PsychoK

    MSplitz-PsychoK

    Joined:
    May 16, 2015
    Posts:
    1,278
    https://unity3d.com/learn/tutorials/topics/performance-optimization/optimizing-scripts-unity-games

    According to the above tutorial, when a transform is changed, only children are notified. There's some other info in the short "Transform" section that I think you may find useful.


    What are you afraid will happen if the other "b's" get notified? Unless you've got an optimization issue, I don't think this type of detail is worth your attention. Even still, there are probably better areas to optimize.
     
  3. NEVER-SETTLE

    NEVER-SETTLE

    Joined:
    Apr 22, 2018
    Posts:
    30
    Great, that link only makes it more confusing now, since it doesn't mention the parent being notified, as in the link I posted.
    I don't have an optimization issue, I was just curious about this.
    Well, your own link answers this, and mine in even more detail.
    Nesting a lot of transforms IS an optimization issue in itself. The degree of the issue raises as you add more or as more transforms get notified.
     
  4. drcrck

    drcrck

    Joined:
    May 23, 2017
    Posts:
    328
    Only if your game is about nesting transforms and has nothing else except transforms
     
  5. MSplitz-PsychoK

    MSplitz-PsychoK

    Joined:
    May 16, 2015
    Posts:
    1,278
    That is a huge nit-pick.. I would not worry about that sort of little optimization unless you are trying to solve an issue. Holding yourself to keeping everything as optimized as possible will slow down your ability to make new things by too much for little details like this to be worth your time.


    If you absolutely must know how the messages are sent, try using the profiler to see the difference in performance between updating the different types of transforms that you're wondering about.

    For example, find out how long it takes to update a transform by itself (run this test many times to find the average time it takes). Then, find out how long it takes to update a transform with a parent, and compare the results. You can use
    Profiler.BeginSample("Sample Name")
    and
    Profiler.EndSample()
    so that you are only profiling the exact code you want to profile.
     
  6. And I intentionally will make it more confusing, just for you, just today. One time offer. Enjoy.