- Home /
Possibly to create a game object inside of another game object?
Whenever I create a blank game object it always appears on the outer most level of the hierarchy. I would like to be able to create a new blank game object inside of the object I currently have selected. Is that possible?
Answer by rgowen · May 17, 2014 at 05:25 AM
All you have to do is create the empty GameObject. Then in the Hierarchy, drag and drop it onto the GameObject you want to add it to.
But that's exactly what I don't want to do. The part I don't like is that if I'm creating lots of game objects and have lots of objects in my project it gets tedious dragging every new game object into the object I want to be under.
Did some quick Googling and found this:
That looks exactly like what I want! I'll see if I can get it working, I didn't know Unity let you override how it works.
Yeah, I haven't gotten into Editor extensions too much yet, but from what I've seen they can be extremely powerful.
Answer by Noob_Vulcan · May 17, 2014 at 07:20 AM
GameObject obj = Instantiate (Bubble, transform.localPosition, Quaternion.identity)) as GameObject;
obj.transform.parent = other_obj.transform;
This will make "obj" child of "other_obj"
That's not what I was trying to do, but it's good to know how to do it in scripting. Thanks!
Your answer
Follow this Question
Related Questions
Any way to create a gamobject only if there is an empty space? 1 Answer
Adding local created rigedbody to gameobject 1 Answer
Parent everything to gameobject 2 Answers
How could I create a prefab from an exsisting gameobject at runtime? 2 Answers
GameObject.find("name") doesn't work if executed in the same loop of... 1 Answer