This doesn't make sense. GameObjects doesn't have a parent. GameObjects have a Transform component and these components create the hierarchy. The GameObjects are just containers.
You're right. I've edited the answer to take parent.transform instead. Thanks. My point was that he should instantiate a GameObject instead of a Transform. This is the way I do it so I know it works. According to the documentation, you can also instantiate a Transform but perhaps you can't change its parent then, I haven't tried.
No that doesn't make any difference. You can take any Component as source. Unity will always clone the whole GameObject with all components. It's just quite handy to use the component as source that you need after the instantiate. You can also use a customscript reference as source.
You should put that as a comment instead of an answer, otherwise it's hard to tell which answer you're referring to :-) Can you be more precise about what you're trying to do? Is @Bunny83 correct that you're actually writing an editor script and that go is actually a prefab?
execute this code in the editor (at edit time, not at tuntime)
and one of your two GameObjects are a prefab and not an instance
Since you instantiate the particle gameobject, i guess the Gameobject “go” is a prefab and not an instance.
If this is an editor script you should know that working with prefabs is a bit tricky. Prefabs are an editor only feature. Prefabs do not exist at runtime. Instantiate() will create a unconnected copy. If you want to instantiate a prefab like when you drag it into the scene you have to use PrefabUtility.InstantiatePrefab.
If you want to change the prefab (update it) you have to create a normal instance (Instantiate), do your changes and then use PrefabUtility.ReplacePrefab to copy the instance back to the prefab. After that you can delete your temp-instance.
This doesn't make sense. GameObjects doesn't have a parent. GameObjects have a Transform component and these components create the hierarchy. The GameObjects are just containers.
– Bunny83You're right. I've edited the answer to take parent.transform instead. Thanks. My point was that he should instantiate a GameObject instead of a Transform. This is the way I do it so I know it works. According to the documentation, you can also instantiate a Transform but perhaps you can't change its parent then, I haven't tried.
– clfischerNo that doesn't make any difference. You can take any Component as source. Unity will always clone the whole GameObject with all components. It's just quite handy to use the component as source that you need after the instantiate. You can also use a customscript reference as source.
– Bunny83OK. In that case, your answer is probably correct. I'm impressed that you managed to guess the missing parts of the question :-)
– clfischer