@@ -22,8 +22,15 @@ local INFO = script:GetCustomProperty("Info"):WaitForObject()
2222--- @type UIButton
2323local REFRESH_BUTTON = script :GetCustomProperty (" RefreshButton" ):WaitForObject ()
2424
25+ --- @type UIContainer
26+ local UICONTAINER = script :GetCustomProperty (" UIContainer" ):WaitForObject ()
27+
28+ --- @type UIButton
29+ local HIDE_UI = script :GetCustomProperty (" HideUI" ):WaitForObject ()
30+
2531local is_loading = true
2632local loading_image = NFT_IMAGE :GetImage ()
33+ local showing = true
2734
2835REFRESH_BUTTON .isInteractable = false
2936
4047UI .SetCanCursorInteractWithUI (true )
4148UI .SetCursorVisible (true )
4249
50+ HIDE_UI .text = " Hide UI [" .. Input .GetActionInputLabel (" Show/Hide UI" ) .. " ]"
51+
4352local function fetch_nft ()
4453 local token , status , err = Blockchain .GetToken (CONTRACT_ADDRESS , TOKEN_ID )
4554
@@ -53,7 +62,7 @@ local function fetch_nft()
5362
5463 for index , attribute in ipairs (attributes ) do
5564 local txt = INFO :FindDescendantByName (" Attribute - " .. attribute .name )
56-
65+
5766 if (txt ~= nil ) then
5867 txt .text = attribute :GetValue ()
5968 end
@@ -70,7 +79,7 @@ local function refresh()
7079 NFT_IMAGE :FindChildByName (" Frame" ).visibility = Visibility .FORCE_OFF
7180 NFT_IMAGE :SetImage (loading_image )
7281 TOKEN_ID = tostring (math.random (TOTAL_TOKENS ))
73-
82+
7483 local children = INFO :FindDescendantsByType (" UIText" )
7584
7685 for index , child in ipairs (children ) do
@@ -83,6 +92,28 @@ local function refresh()
8392 fetch_nft ()
8493end
8594
95+ local function hide_show ()
96+ if (showing ) then
97+ UICONTAINER .visibility = Visibility .FORCE_OFF
98+ showing = false
99+
100+ UI .SetCanCursorInteractWithUI (false )
101+ UI .SetCursorVisible (false )
102+ else
103+ UICONTAINER .visibility = Visibility .FORCE_ON
104+ showing = true
105+
106+ UI .SetCanCursorInteractWithUI (true )
107+ UI .SetCursorVisible (true )
108+ end
109+ end
110+
111+ local function on_action_pressed (player , action )
112+ if (action == " Show/Hide UI" ) then
113+ hide_show ()
114+ end
115+ end
116+
86117function Tick (dt )
87118 if (is_loading ) then
88119 NFT_IMAGE .rotationAngle = NFT_IMAGE .rotationAngle + (dt * 200 )
91122
92123Task .Spawn (fetch_nft )
93124
94- REFRESH_BUTTON .pressedEvent :Connect (refresh )
125+ REFRESH_BUTTON .pressedEvent :Connect (refresh )
126+ Input .actionPressedEvent :Connect (on_action_pressed )
127+ HIDE_UI .pressedEvent :Connect (hide_show )
0 commit comments