- Home /
GameObject permanent destruction from "Resources" in EditorWindow
Hi all! I tried hard to find the answer to my question but I failed. I was wondering if anybody could help me here. My issue is:
I have a specific Asset folder, say "RawResources" where I keep all prefabs. Before I make a build for a target platform, I need to copy prefabs from "RawResources" to actuall "Resources" folder. This behaviour depends on whether I need a client build or a server build. The main difference for me between the client build and the server build is that I don't need all visual specific Components attached to gameobjects in prefabs for the server build (Mesh Renderer, Camera, Animator and so on).
Logically what I'm doing is:
Copy all prefabs from "RawResources" to "Resources";
Refresh Asset DB;
If it's the server build;
Delete all useless components from all parent-child prefab hierarchy in "Resources";
If at that point the current gameObject have only Transform component and it has a parent;
Remove it permanently from parent-child prefab hierarchy and therefore from "Resources" folder as well.
I succesfully accomplished this task by using my own class inherited from EditorWindow.
Everything seems to be fine, however I get strange behaviour when this process is finished.
https://monosnap.com/image/ZlWHB7NM0MFOG9X4ZtdXYAgJgexM4X - as you can see here there is a child gameobject totally empty(it's ok I don't need it at all), but I don't understand why it wasn't totally destroyed without appearing at all. It's not even a predefined empty gameobject (because I believe they have at least Transform component attached).
https://monosnap.com/image/avKIx8maTC2pDBsa9VAKaKnzVOUexZ- I'm even not able to delete it from the context menu.
It's not a critical behaviour but it breaks the logical structure for the server build and consumes memory a little.
P.S. this is the code of my class responsible for this functionality: http://pastebin.com/WCmQBqQD
See CopyRawResources(bool) first if you want to help me:)
Thanks for any help in advance!
Sincerely Rita.