Trabla: Unity3D: delete child objects in gameobject
Solving:
using UnityEngine;
using System.Collections;
using System;
using System.Collections.Generic;
using UnityEngine.UI;
public class DeleteChildObjectsExample: MonoBehaviour
{
public GameObject objectsContainer;
void DeleteChildObjects( GameObject container ){
if( container != null ){
if( container.transform.childCount > 0 ){
foreach ( Transform child in container.transform ) {
Destroy ( child.gameObject );
}
}
}
}
void Start(){
this.DeleteChildObjects( objectsContainer );
}
void Update(){
}
}
No comments:
Post a Comment