- Home /
Remove a prefab from all scenes at build
Guys,
I have a gameobject 'Cheater' helping me testing of my game. I put Cheater in some of the scenes so that I am able to test the scenes individually. However, when I want to take a build, I do not want to deal with opening all scenes one by one and remove Cheaters from them. I want a way to remove all Cheaters from all scenes via one button. Is it possible to manipulate scenes from outside?
Answer by Hellium · Jan 29, 2018 at 01:38 PM
It should be possible, but I don't really know how exactly.
However, here is what I suggest you: Tag your Cheater
object with the EditorOnly
tag. This tag is special and lets Unity know the gameobject must not be included in the scene when your game is being built.
Actually, it is the same for the editor tests. However, because I have given a very specific example and you came up with the most specific and correct answer, I am closing this question with your answer :)
I was expecting the code behind that EditorOnly executes so that I can use that "remove, ignore" behaviour in my unity plugin, like with a button press discard all the gameobject of a class from all the scenes.
Answer by kennenwe · Jan 29, 2018 at 07:08 PM
Just copy the prefab delete/cut it and unity will remove it from all scenes and then paste it back
Answer by Sabre-Runner · Jan 29, 2018 at 07:55 PM
How about including a script on all Cheater objects that destroys the object. But it only works if it's NOT in debug mode?