Now, let's make it so we can open up the shop. With this in mind, let's create a button to do just that:
Canvas
object, select GameObject | UI | Button and then rename the object to ShopOpenButton
. Change the Width to 300
and Height to 60
. From there, extend the Text
object by selecting it and then from the Inspector tab under the Text component, change the Text to Open Shop
and change the Font Size to 40
.ShopOpenButton
object once again and then from the Anchor Presets window, hold down Alt and Shift and then click on top-left. Then, change Pos X to 20
and Pos Y to -20
. Scroll down to the Button component, and from the On Click () section, click on the + button. Connect the ShopWindow object and then from the dropdown, select GameObject | Set Active. Then, click on the checkmark to enable the shop. Click on + again and drag and drop the ShopOpenButton
object to the list with an unchecked SetActive (so it'll turn itself off once pressed):ShopOpenButton
(select from the Hierarchy tab and then press Ctrl+D) and rename the new one ShopCloseButton
. Change the text of the close button to Close Shop
, and from the object's Button component, add a + button to turn off the OpenCloseButton
button (unchecked SetActive). Then, go to the ShopOpenButton
and turn the ShopCloseButton
object on (checked SetActive).What we are doing here is so when one button is pressed, it will turn the shop on or off and then turn itself off and on:
Now when we open the shop, we will see the shop and be able to close it.