Unparents all children.
transform.DetachChildren(); Destroy(gameObject);
using UnityEngine; using System.Collections; public class Example : MonoBehaviour { void Example() { transform.DetachChildren(); Destroy(gameObject); } }
import UnityEngine import System.Collections public class Example(MonoBehaviour): def Example() as void: transform.DetachChildren() Destroy(gameObject)