com.stansassets.foundation
com.stansassets.foundation copied to clipboard
TransformExtensions code review
https://github.com/StansAssets/com.stansassets.foundation/blob/b3332055c35bb65162e22570b14c06d59ff4155e/Runtime/Extensions/UnityEngine/TransformExtensions.cs#L53-L67
using GetComponent<Transform> is kinda inefficient. you can do this:
for(int i = transform.childCount-1; i >= 0; --i){
Object.DestroyImmediate(transform.GetChild(i));
}
https://github.com/StansAssets/com.stansassets.foundation/blob/b3332055c35bb65162e22570b14c06d59ff4155e/Runtime/Extensions/UnityEngine/TransformExtensions.cs#L80-L81
if you'd use part.SetParent(transform, false)
you could skip the part.Reset()
call.