unity-game-enginereplace2dunity3d-editorunity-components

unity3d replacing objects with prefabs in scene during editing


I was developing a 2d game. I have 8 maps. Maps are made from "wall" gameObject (I duplicated or copied them, yeah that was bad idea, and it's my first big, normal project). Now I need to change all of these "wall" component settings. I though I could make a prefab, so it would be easier later. Picture how my hierarchy looks like and what I need to change.

enter image description here

What I really want to do is to add 3DCollider to 2D "walls" so my particles would collide. Any help appreciated.


Solution

  • To make a prefab you have to drag your GameObject (wall) to your "Project" view.

    Here is a tutorial.

    https://www.youtube.com/watch?v=wa3MCkxf2U0

    Sadly you cannot link this new prefab with the other wallxx objects. So, you will have to do that for your own.

    My recommendation is write a kind of map file. Then from the code create the structure to instantiate the wall objects on each position/orientation given by the file info. Could sounds a little bit complicated but at the end will save you a lot of time !