Prefabifying Button

Hi, can we prefab a button so that i don't change the text style and everything every time i create a button?

Right now if i prefab a button, then create another button from that prefab it won't show in the scene.

Are you putting the button on a Canvas?

Make sure you're putting the button on a canvas and not just into your scene. This shows what happens when you don't: http://gyazo.com/190612bd59de20469969b99b31d26ece

Thanks that works!

Edit: And it's really awesome!

I'm currently trying the same thing, but mine are not showing up, as if not added to a Canvas. I simply Instantiate() the prefab, and then set its transform's parent to my Canvas'. What am I missing?

How do you set the parent? because aparently panels don't have the regular transform.

Ooh, good point! I used "btn.transform.parent" though, and appearantly btn.transform automagically refers to the object's RectTransform. =) It's also in the correct place in the hierarchy; right besides its already-existing brothers and sisters.

1 Like