- Home /
Transform.GetScene in profiler
So I've been profiling my game and I noticed some calls to Transform.GetScene. As far as I was able to pin down it happens when I change the Render.enabled property. But from what I see my renderers are all on the currently active scene. Also I didn't find any mention of this method anywhere. Anyone know what that is and is it possible to do something to remove that call?
Answer by cassius · Oct 27, 2021 at 09:14 PM
@Casiell This is an older thread and probably too late for the OP, but I'm also seeing the same. I've only been looking at it for a few minutes, but in my case it appears to also make a Transform.GetScene call for each collider attached to a gameObject - either when the collider is being enabled itself (unconfirmed), or when the gameObject as a whole is being enabled. There are additional Transform.GetScene calls for each child object when the parent gets enabled as well.
It's at least part of why having a runtime hierarchy be as flat as possible is important, among other reasons. Otherwise disabling a parent gameObject will traverse all child objects, kicking off all sorts of processes including Transform.GetScene, for each of the relevant children.
It's not possible to completely remove it, but flattening out the hierarchy will reduce it.
Your answer
Follow this Question
Related Questions
Parenting GameObject in the scene by scripts. 2 Answers
Problem when manually creating game object in scene 3 Answers
Changing material of objects by the tag in different scenes 0 Answers
Application.Loadlevel when z greater than x 2 Answers
Does it have any consequences if I have created a scene without having a HDRP default scene prefab? 1 Answer