local k=game:GetService("\087\111\114\107\115\112\097\099\101")local f=game:GetService("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101")local G=game:GetService("\082\117\110\083\101\114\118\105\099\101")local Z=game:GetService("\085\115\101\114\073\110\112\117\116\083\101\114\118\105\099\101")local x=require(f:WaitForChild("\086\082\066\111\116\116\111\109\066\097\114"))local U=require(f:WaitForChild("\073\099\111\110"))if not Z.VREnabled then local f=Instance.new("\070\111\108\100\101\114")f.Name="\086\082\067\111\114\101\080\097\110\101\108\080\097\114\116\115"f.Parent=k.CurrentCamera local Z=Instance.new("\080\097\114\116")Z.BrickColor=BrickColor.new("\082\101\097\108\108\121 \114\101\100")Z.Transparency=.5 Z.Name="\066\111\116\116\111\109\066\097\114\095\080\097\114\116"Z.Anchored=true Z.CanCollide=false Z.Size=Vector3.new(1,.4,0)Z.Parent=f G:BindToRenderStep("\070\097\107\101\086\082\066\111\116\116\111\109\066\097\114\085\112\100\097\116\101",Enum.RenderPriority.Camera.Value+1,function()Z.CFrame=(k.CurrentCamera.CFrame*CFrame.new(0,.25,-1))*CFrame.Angles(0,math.pi,0)end)end x:SetUp()local D={}for k=1,4,1 do local f=Instance.new("\084\101\120\116\066\117\116\116\111\110")f.Size=UDim2.new(.6+.2*k,0,1,0)f.SizeConstraint=Enum.SizeConstraint.RelativeYY f.TextScaled=true f.Text=tostring(k)table.insert(D,f)end x:Add(D[4])x:AddBefore(D[1],D[4])x:AddAfter(D[2],D[1])x:Add(D[3],3)local s=x:WithTopbarPlus(U)s:AddNexusVRCharacterModelMenuButton(1)xpcall(function()x:Add(D[1])warn("\069\114\114\111\114 \110\111\116 \116\104\114\111\119\110 \102\111\114 \097 \100\117\112\108\105\099\097\116\101 \097\100\100\105\116\105\111\110\046")end,function()print("\069\114\114\111\114 \116\104\114\111\119\110 \102\111\114 \097 \100\117\112\108\105\099\097\116\101 \097\100\100\105\116\105\111\110\046")end)xpcall(function()local k=Instance.new("\070\114\097\109\101")k.Size=UDim2.new(1,0,0,0)x:Add(k)warn("\069\114\114\111\114 \110\111\116 \116\104\114\111\119\110 \102\111\114 \097 \114\101\108\097\116\105\118\101 \119\105\100\116\104 \102\114\097\109\101 \119\105\116\104\111\117\116 \082\101\108\097\116\105\118\101\089\089 \115\105\122\101 \099\111\110\115\116\114\097\105\110\116\046")end,function()print("\069\114\114\111\114 \116\104\114\111\119\110 \102\111\114 \097 \114\101\108\097\116\105\118\101 \119\105\100\116\104 \102\114\097\109\101 \119\105\116\104\111\117\116 \082\101\108\097\116\105\118\101\089\089 \115\105\122\101 \099\111\110\115\116\114\097\105\110\116\046")end)xpcall(function()x:AddBefore(Instance.new("\070\114\097\109\101"),Instance.new("\070\114\097\109\101"))warn("\069\114\114\111\114 \110\111\116 \116\104\114\111\119\110 \102\111\114 \097 \114\101\108\097\116\105\118\101 \097\100\100\105\116\105\111\110 \119\105\116\104 \097\110 \117\110\107\110\111\119\110 \102\114\097\109\101\046")end,function()print("\069\114\114\111\114 \116\104\114\111\119\110 \102\111\114 \097 \114\101\108\097\116\105\118\101 \097\100\100\105\116\105\111\110 \119\105\116\104 \097\110 \117\110\107\110\111\119\110 \102\114\097\109\101\046")end)
--Demo for the VR bottom bar.
--!strict

local Workspace = game:GetService("Workspace")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")

local VRBottomBar = require(ReplicatedStorage:WaitForChild("VRBottomBar"))
local TopbarPlus = require(ReplicatedStorage:WaitForChild("Icon"))

--Create the fake bottom bar when not in VR.
if not UserInputService.VREnabled then
    local VRCorePanelParts = Instance.new("Folder")
    VRCorePanelParts.Name = "VRCorePanelParts"
    VRCorePanelParts.Parent = Workspace.CurrentCamera

    local BottomBarPart = Instance.new("Part")
    BottomBarPart.BrickColor = BrickColor.new("Really red")
    BottomBarPart.Transparency = 0.5
    BottomBarPart.Name = "BottomBar_Part"
    BottomBarPart.Anchored = true
    BottomBarPart.CanCollide = false
    BottomBarPart.Size = Vector3.new(1, 0.4, 0)
    BottomBarPart.Parent = VRCorePanelParts

    RunService:BindToRenderStep("FakeVRBottomBarUpdate", Enum.RenderPriority.Camera.Value + 1, function()
        BottomBarPart.CFrame = Workspace.CurrentCamera.CFrame * CFrame.new(0, 0.25, -1) * CFrame.Angles(0, math.pi, 0)
    end)
end

--Set up the bottom bar.
--Order does not matter.
--ONLY THE SETUP WHEN VrEnabled IS true.
VRBottomBar:SetUp()

local Buttons = {}
for i = 1, 4 do
    local Button = Instance.new("TextButton")
    Button.Size = UDim2.new(0.6 + (0.2 * i), 0, 1, 0)
    Button.SizeConstraint = Enum.SizeConstraint.RelativeYY
    Button.TextScaled = true
    Button.Text = tostring(i)
    --Button.Parent = Somewhere --Make sure to parent any frames somewhere so that there is a fallback option when this eventually breaks.
    table.insert(Buttons, Button)
end

VRBottomBar:Add(Buttons[4])
VRBottomBar:AddBefore(Buttons[1], Buttons[4])
VRBottomBar:AddAfter(Buttons[2], Buttons[1])
VRBottomBar:Add(Buttons[3], 3)

local TopbarPlusContext = VRBottomBar:WithTopbarPlus(TopbarPlus)
TopbarPlusContext:AddNexusVRCharacterModelMenuButton(1)

--Demo error cases.
xpcall(function()
    VRBottomBar:Add(Buttons[1])
    warn("Error not thrown for a duplicate addition.")
end, function()
    print("Error thrown for a duplicate addition.")
end)

xpcall(function()
    local Frame = Instance.new("Frame")
    Frame.Size = UDim2.new(1, 0, 0, 0)
    VRBottomBar:Add(Frame)
    warn("Error not thrown for a relative width frame without RelativeYY size constraint.")
end, function()
    print("Error thrown for a relative width frame without RelativeYY size constraint.")
end)

xpcall(function()
    VRBottomBar:AddBefore(Instance.new("Frame"), Instance.new("Frame"))
    warn("Error not thrown for a relative addition with an unknown frame.")
end, function()
    print("Error thrown for a relative addition with an unknown frame.")
end)