DarkRewar / BaseTool

A big library of basic tools that you might need in your Unity projects.
MIT License
41 stars 6 forks source link

Add Clear() extensions #40 #68

Closed DarkRewar closed 5 months ago

DarkRewar commented 5 months ago

Transform Extensions

Clear() and Clear(float time)

Destroy every children of a transform, using delay or not.

using BaseTool;
using UnityEngine;

Transform scrollView; // let's admit it's initialized
scrollView.Clear();

foreach(int i in 0..5) 
    Instantiate(prefab, scrollView);

ClearImmediate()

Destroy every children of a transform, using the Object.DestroyImmediate() method.

using BaseTool;
using UnityEngine;

Transform scrollView; // let's admit it's initialized
scrollView.ClearImmediate();

foreach(int i in 0..5) 
    Instantiate(prefab, scrollView);