N
N
Nikola_y2015-05-25 08:57:34
C++ / C#
Nikola_y, 2015-05-25 08:57:34

Instantiate and Canvas's Unity?

How to implement object inheritance, for GUI
So that when Instantiate(Prefab), Image(Button) is added to the Canvas

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Espleth, 2015-05-25
@Nikola_y

First you need to get the Canvas transform. There are two ways to do this (actually more, but here are the main ones): 1) Hang a tag on the Canvas, and then use FindGameObjectWithTag. 2) Make it in the class where the Instantiate Transform field for Canvas will be called, and either do it in the first way at startup, or manually drag the Canvas in Unity into this field.
Then after Instantiate the created object (let's call it go) do go.transform.SetParent(*transform of our canvas*)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question