I want to destroy any graphic component on a gameobject , example is image,raw image, sprite , ect .But i don't have the list of all graphic component so i don't know how to loop through it . The reason is because i want to replace the component with the same type , for example i want to add Text component , but i can't add it if there is already graphic component attached in the gameobject because there can only be one graphic component in a gameobject , so i need to destroy the graphic component first , how do i do it ?
I personally prefer the answer on c# but any programming language is accepted !