- Home /
Problem is not reproducible or outdated
Can't destroy an ui element
When I am trying to destroy an rect transform with a button component, event trigger and some graphics in children components. My script shares a list of these gameobjects. I am destroying all the objects in the list, but when I do this I will get gameobjects with name "removed gameobject". These objects can not be opened in the inspector, event triggers or buttons are not responding but the graphics are still visible. This doesn't make any sense to me. What's the problem?
Answer by malkere · May 20, 2015 at 01:04 PM
graphics and gameobjects generally are separate entities from lists and dictionaries, etc. Make sure you GameObject.Destroy(myListofObjects[0]) before you myListofObjects.RemoveAt(0). Othewise you will lose your easy reference to it.
You may already be doing this, but your question doesn't actually say so. The actual line of code would help formulate better answers.
Follow this Question
Related Questions
Wraping text to fit in a gui box 1 Answer
How do I effect click-and-hold to a child Button of list-item in a ListView? 0 Answers
How Do I Lock the Cursor to the Center of the Screen? 1 Answer
How to drag objects from UI into scen 3 Answers
How to change the Top and Bottom (rect.yMin and yMax) properties of a rectTransform, in a script? 2 Answers