1

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.

user3071284
  • 6,955
  • 6
  • 43
  • 57
Justasmig
  • 67
  • 8
  • So! Whats the big deal? Select all and add collider component. Is it what you want to achieve? – Umair M Jul 12 '15 at 00:41
  • @Umair M I know I can do that, but I want to change into prefab so in future it would be easier. – Justasmig Jul 12 '15 at 06:37
  • Well I think you can write your own custom script to change any of the property you like for all the wall objects. Scripts can also work in edit mode so you can reach all of the game objects with their name or a tag and once you reach the all game objects you need, you can change any property. And also you can replace these objects with a prefab by using similar script if this is what exactly you need. – ali.turan Jul 12 '15 at 19:58

1 Answers1

0

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 !

mayo
  • 3,845
  • 1
  • 32
  • 42
  • I know how to make prefabs and I though about making map from come by generating it. Altough I think this will help other so I will choose as an answer. – Justasmig Jul 13 '15 at 20:52
  • Thnks ! Took me a while to really understand and convince myself to use prefabs to work with repeated elements. But at the end is the best approach. – mayo Jul 13 '15 at 21:00