Skip to content

Commit 9f046b4

Browse files
committed
Close and open UI now possible
1 parent cdd7057 commit 9f046b4

File tree

11 files changed

+329
-2068
lines changed

11 files changed

+329
-2068
lines changed

Data/BindingSets/Default Bindings.pbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Assets {
22
Id: 736360303936294653
33
Name: "Default Bindings"
44
PlatformAssetType: 29
5-
SerializationVersion: 118
5+
SerializationVersion: 119
66
BindingSetAsset {
77
Bindings {
88
BindingType {
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
Assets {
2+
Id: 11223120893904553678
3+
Name: "NFT Display Attributes"
4+
PlatformAssetType: 29
5+
SerializationVersion: 119
6+
BindingSetAsset {
7+
Bindings {
8+
BindingType {
9+
Value: "mc:ebindingtype:basic"
10+
}
11+
BasicBindingData {
12+
BasicInputs {
13+
KeyboardPrimary {
14+
Value: "mc:ebindingkeyboard:r"
15+
}
16+
KeyboardSecondary {
17+
Value: "mc:ebindingkeyboard:none"
18+
}
19+
Controller {
20+
Value: "mc:ebindinggamepad:none"
21+
}
22+
}
23+
}
24+
Action: "Show/Hide UI"
25+
CoreBehavior {
26+
Value: "mc:ecorebehavior:none"
27+
}
28+
IsEnabledOnStart: true
29+
}
30+
}
31+
}

Data/Scenes/Main/Gameplay Settings/Tree.pbt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,14 @@ Objects {
321321
HighDistance: 9000
322322
}
323323
}
324+
RelevanceSettings {
325+
key: "light"
326+
value {
327+
LowDistance: 4500
328+
MediumDistance: 7000
329+
HighDistance: 9000
330+
}
331+
}
324332
RelevanceSettings {
325333
key: "mergedmesh"
326334
value {

Data/Scenes/Main/Tree.pbt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ Objects {
4545
}
4646
}
4747
ParentId: 4781671109827199097
48+
Collidable_v2 {
49+
Value: "mc:ecollisionsetting:inheritfromparent"
50+
}
51+
Visible_v2 {
52+
Value: "mc:evisibilitysetting:inheritfromparent"
53+
}
4854
TemplateInstance {
4955
ParameterOverrideMap {
5056
key: 16309517152617765365
@@ -53,6 +59,16 @@ Objects {
5359
Name: "Name"
5460
String: "NFT Display Attributes"
5561
}
62+
Overrides {
63+
Name: "Position"
64+
Vector {
65+
}
66+
}
67+
Overrides {
68+
Name: "Rotation"
69+
Rotator {
70+
}
71+
}
5672
}
5773
}
5874
TemplateAsset {

Data/Scripts/NFT_Display_Attributes_Client.asset.pbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ Assets {
66
CustomParameters {
77
}
88
}
9-
SerializationVersion: 118
9+
SerializationVersion: 119
1010
VirtualFolderPath: "NFT Display Attributes"
1111
}

Data/Scripts/NFT_Display_Attributes_Client.lua

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,15 @@ local INFO = script:GetCustomProperty("Info"):WaitForObject()
2222
---@type UIButton
2323
local 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+
2531
local is_loading = true
2632
local loading_image = NFT_IMAGE:GetImage()
33+
local showing = true
2734

2835
REFRESH_BUTTON.isInteractable = false
2936

@@ -40,6 +47,8 @@ end
4047
UI.SetCanCursorInteractWithUI(true)
4148
UI.SetCursorVisible(true)
4249

50+
HIDE_UI.text = "Hide UI [" .. Input.GetActionInputLabel("Show/Hide UI") .. "]"
51+
4352
local 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()
8493
end
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+
86117
function Tick(dt)
87118
if(is_loading) then
88119
NFT_IMAGE.rotationAngle = NFT_IMAGE.rotationAngle + (dt * 200)
@@ -91,4 +122,6 @@ end
91122

92123
Task.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)

Data/Scripts/README.asset.pbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ Assets {
66
CustomParameters {
77
}
88
}
9-
SerializationVersion: 118
9+
SerializationVersion: 119
1010
VirtualFolderPath: "NFT Display Attributes"
1111
}

0 commit comments

Comments
 (0)