Skip to content

Commit a23c881

Browse files
committed
Using pool version
1 parent ad8f303 commit a23c881

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

Explorer/Assets/DCL/AvatarRendering/Loading/Assets/AttachmentAssetUtility.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,12 @@ public static CachedAttachment InstantiateWearable(this IAttachmentsAssetsCache
2323
{
2424
var instantiatedWearable = Object.Instantiate(originalAsset.MainAsset, parent);
2525

26+
using PoolExtensions.Scope<List<MeshRenderer>> meshRenderers = instantiatedWearable.GetComponentsInChildrenIntoPooledList<MeshRenderer>(true);
27+
2628
//A wearable cannot have a MeshRenderer, only SkinnedMeshRenderer.
27-
//We need to destroy it if thats the case
28-
foreach (MeshRenderer? mr in instantiatedWearable.GetComponentsInChildren<MeshRenderer>(includeInactive: true))
29-
Object.DestroyImmediate(mr.gameObject);
29+
//We need to destroy it form the source wearable
30+
for (var i = 0; i < meshRenderers.Value.Count; i++)
31+
Object.DestroyImmediate(meshRenderers.Value[i].gameObject);
3032

3133
instantiatedWearable.name = originalAsset.GetInstanceName();
3234
cachedWearable = new CachedAttachment(originalAsset, instantiatedWearable, outlineCompatible);

0 commit comments

Comments
 (0)