Generic way to get and remove components

How can I remove all of the components on a gameObject through scripting?

1 Answer

1

var components = GetComponents(Component);
for (component in components) {
if (typeof(component) != Transform) {
Destroy(component);
}
}

Thanks!