How to add Components to some individuals parts of a prefab
Hey guys, I have a question for you because I've no idea how can I solve it. I have a prefab with a entire 3D scene inside, and I would like to make a script in C# which will allow me initialize some 3D models of that prefab with a rigidbody and colliders.
How you can see in this picture the hole scene it's my prefab and I would like to add to this tables a box collider and to some tools are on that tables some mesh colliders and rigidbodys also. And that I wanna be possible via script, not manual from Unity interface.
So if anyone of you have any idea how can I solve this problem please help me and... give me some advice.
Thanks
Answer by Cuttlas-U · Apr 07, 2017 at 01:54 PM
hi with " AddComponent " u can add anything via script like here ;
gameObject.AddComponent<BoxCollider>();
or u can find and add ;
GameObject.Find("Table").AddComponent<MeshCollider>();
Your answer
Follow this Question
Related Questions
Is it better to split a script into different scripts? 1 Answer
Having problem with scoring system., 0 Answers
Best Way to Dynamically Create Objects with DB info? 0 Answers
Why are my keys being registered multiple times? 1 Answer
Solved how to get half the collider of a box2d or capsulecollider2D 0 Answers