Skip to content

Avoid using Object.Instantiate without “Transform Parent” parameter and using SetParent later

Vladimir edited this page Dec 7, 2018 · 2 revisions

Invocation of Object.Instantiate is ineffective when parent parameter is not passes and set later via Transform.SetParent or update parent property of Transform component.

Using method overload with parent parameter avoids creating a new transform hierarchy and then moving it and instead quickly inserts it into the existing transform hierarchy.

This inspection will mark the Object.Instantiate invocation when it is called without parent parameter and parent is set later via Transform.SetParent or update parent property of Transform component. It will also add Alt+Enter quick fix, which will pass parent into invocation and remove Transform.SetParent invocation or parent modification for Transform component

Clone this wiki locally