com.stansassets.foundation icon indicating copy to clipboard operation
com.stansassets.foundation copied to clipboard

TransformExtensions code review

Open soraphis opened this issue 1 year ago • 0 comments

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.

soraphis avatar Aug 12 '22 22:08 soraphis