I have a Canvas GameObject with a panel inside it and a default button on the default button.
When I drag the button from my resource folder to the Canvas in the hierarchy, it is placed in the panel where I expect it.
However when I installed it as below:
GameObject button = Instance (Resources.Load ("UI / Dialogue / Button"), New Vector3 (0, 0, 0), Quaternion.identity, MyCanvas.transform) as GameObject;
it is placed in the center of the screen due to the second parameter. However, I can not configure it as a child of the parent because that does not happen until the last parameter. It also does not feel good to figure out the exact Vector3 to plug it in so that it looks like the top of the panel.
Is there a way to create an instance of the button in the panel in the code, since it works by dragging it from the resource folder to the canvas in the hierarchy?