照片展位

*此內容是使用 AI(Beta 測試版)翻譯,可能含有錯誤。若要以英文檢視此頁面,請按一下這裡

拍照是一種完美的方式來紀念美好的經歷。照片攤的開發者模組是一個易於使用的照片擺拍工具,可以讓玩家用一個代表他們經驗的背景擊中獨特姿勢。

模組使用

安裝

要在體驗中使用 照片攤 模組:

  1. 視圖標籤開啟工具箱,然後選擇 創作者商店 標籤。

    Toolbox toggle button in Studio
  2. 確保 模型 排序已選擇,然後單擊 查看全部 按鈕以獲得 類別

  3. 找到並點擊 開發模組 磚塊。

  4. 尋找 照片攤位 模組,然後單擊它或拖放到 3D 視圖中。

  5. 檢索器 窗口中,將整個 相機攤位 模型移至 服務器腳本服務 。執行體驗時,模組會分配到各種服務並開始運行。

位置展位

模組包含一個 照片攤位 模型,您可以在 3D 世界中放置。這個模型是玩家會與之互動設置照片的。

  1. 在模組主目錄的 工作區 文件夾內尋找 照片攤位 網格。

  2. 將它移動到最高級 工作區 層次並將其放置在所需位置。

配置

模組預先配置以處理大多數使用案例,但可以通過 配置 功能簡單自訂。例如,要變更照片底部的預設訊息:

  1. 新手玩家腳本 中,創建一個新的 LocalScript 並將其重命名為 配置照片展位

  2. 將以下代碼貼到新腳本中。

    本地腳本 - 配置照片展位

    local ReplicatedStorage = game:GetService("ReplicatedStorage")
    local PhotoBooth = require(ReplicatedStorage:WaitForChild("PhotoBooth"))
    PhotoBooth.configure({
    frameMessage = "First Photo Booth Capture!",
    })

連接到事件

每次照片展示台向本地客戶顯示新畫面,對應的事件都會發生。這些事件可以在 LocalScript 中連接,以便您可以使用自己的自訂邏輯回應。

本地脚本

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local PhotoBooth = require(ReplicatedStorage:WaitForChild("PhotoBooth"))
PhotoBooth.countdownStarted:Connect(function()
print("The countdown has started")
end)
PhotoBooth.printoutShown:Connect(function()
print("The printout is showing")
end)
PhotoBooth.promptShown:Connect(function()
print("The camera prompt is showing")
end)

GUI可見度

預設情況下,照片攤隱藏所有的 ScreenGuisCoreGuis 當照片被演出時。如果您想覆蓋此自動隱藏行為並手動決定哪些使用者介面應保持可見,請包含 hideOtherGuisshowOtherGuis 回呼,並使用自己的自定義邏輯回應。

本地脚本

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local StarterGui = game:GetService("StarterGui")
local PhotoBooth = require(ReplicatedStorage:WaitForChild("PhotoBooth"))
local player = Players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")
local hiddenInstances = {}
-- 創建一個不會隱藏的屏幕GUI
local specialGuiInstance = Instance.new("ScreenGui")
-- 繪製照片攤位上方的螢幕GUI
specialGuiInstance.DisplayOrder = 1
specialGuiInstance.Parent = playerGui
-- 在屏幕GUI上設置特性以防隱藏
specialGuiInstance:SetAttribute("ShowInPhotoBooth", true)
-- 添加文字標籤到 GUI
local specialLabel = Instance.new("TextLabel")
specialLabel.Size = UDim2.fromScale(1, 0.1)
specialLabel.Text = "Remains visible when taking a photo"
specialLabel.Font = Enum.Font.GothamMedium
specialLabel.TextSize = 24
specialLabel.Parent = specialGuiInstance
PhotoBooth.hideOtherGuis(function()
-- 隱藏所有開發者定義的屏幕使用者介面,除了標有特徵的那些
local instances = playerGui:GetChildren()
for _, instance in instances do
if instance:IsA("ScreenGui") and not instance:GetAttribute("ShowInPhotoBooth") and instance.Enabled then
instance.Enabled = false
table.insert(hiddenInstances, instance)
end
end
-- 隱藏特定核心使用者介面
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList, false)
end)
PhotoBooth.showOtherGuis(function()
-- 顯示所有隱藏的開發者定義螢幕使用者介面
for _, instance in hiddenInstances do
instance.Enabled = true
end
hiddenInstances = {}
-- 顯示隱藏的特定核心使用者介面
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList, true)
end)

API 參考

功能

配置

配置(config: table )

通過以下鍵/值在 config 表中覆蓋預設配置選項的默認選項。此功能只能從 LocalScript 中呼叫。

關鍵說明預設
frameMessage照片底部顯示的消息。其持續時間可以透過 fadeUiDelay 屬性控制。「使用您的裝置截圖並分享!」
fadeUiDelay在框消失之前顯示框訊息的時間(秒)。設為負數以永遠不消失。3
closeButtonImage用於關閉照片按鈕的圖像,放置在 closeButtonBackgroundImage 圖像上方。「rbxassetid://7027440823」
closeButtonBackgroundImage用於關閉照片按鈕的背景圖像。「rbxassetid://7027440891」
cameraLandscapePosition在景觀模式下拍照時,照片攤位的相機與角色前方和向上的距離(Vector2)。(5, 2)
cameraPortraitPosition在拍攝肖像模式照片時,從角色前方和向上移動攝影機的距離(Vector2)。(10, 1)
countdownFont用於倒數計時的字體( Enum.Font )。GothamBlack
countdownTextColor倒數計時中的數字顏色( Color3 )。[255, 255, 255]
printoutCharacterPosition當列印輸出顯示時,角色在畫面上的位置(UDim2)。(0.5, 0, 0.5, 0)
printoutCharacterSize角色在打印輸出中佔用的屏幕空間(UDim2)。(1, 0, 1, 0)
characterAnimation角色在照片中接受的動畫資產ID,暫停在其開始框架。「rbxassetid://6899663224」
filterImage圖像用於應用於照片作為過濾器。如果 nil,將使用黑暗圖像邊緣的預設過濾器。nil
本地腳本 - 配置照片展位

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local PhotoBooth = require(ReplicatedStorage:WaitForChild("PhotoBooth"))
PhotoBooth.configure({
frameMessage = "What a cool pose!",
fadeUiDelay = 5,
maxActivationDistance = 5,
printoutCharacterSize = UDim2.fromScale(1.5, 1.5),
})

設置背景

設置背景(背景: table )

覆蓋照片攤提供的預設背景。背景圖像應為 16:9 比率 (1024×768),以獲得最佳體驗,其資產ID應包含在背景數組中。可提供 1–4 背景(包括在內)。

本地脚本

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local PhotoBooth = require(ReplicatedStorage:WaitForChild("PhotoBooth"))
PhotoBooth.setBackgrounds({
"rbxassetid://7018713114",
"rbxassetid://950538356",
})

事件

倒數開始

在倒數開始時發生火災。此事件只能在 LocalScript 中連接。

本地脚本

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local PhotoBooth = require(ReplicatedStorage:WaitForChild("PhotoBooth"))
PhotoBooth.countdownStarted:Connect(function()
print("The countdown has started")
end)

列印已顯示

當印出物顯示給使用者時發生火災。此事件只能在 LocalScript 中連接。

本地脚本

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local PhotoBooth = require(ReplicatedStorage:WaitForChild("PhotoBooth"))
PhotoBooth.printoutShown:Connect(function()
print("The printout is showing")
end)

快速顯示

當列印關閉且攝影機按鈕再次顯示時發生火災。此事件只能在 LocalScript 中連接。

本地脚本

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local PhotoBooth = require(ReplicatedStorage:WaitForChild("PhotoBooth"))
PhotoBooth.promptShown:Connect(function()
print("The camera prompt is showing")
end)

呼叫回來

隱藏其他GUI

隐藏其他GUI(回调:function )

此回呼在打印輸出顯示之前立即執行,讓您在打印輸出顯示之前禁用整個 ScreenGuis 或其中的元素。照片攤使用的GUI有屬性 在照片攤中顯示 設為 真實 。請參閱GUI可見性以獲得詳情和樣本代碼。

顯示其他GUI

顯示其他GUI(回叫:function)

此回呼在列印關閉後執行,讓您重新啟用整個 ScreenGuis 或其中的元素。照片攤使用的GUI有屬性 在照片攤中顯示 設為 真實 。請參閱GUI可見性以獲得詳情和樣本代碼。