照片展位

*此内容使用人工智能(Beta)翻译,可能包含错误。若要查看英文页面,请点按 此处

拍照是纪念伟大经体验的完美方式。照片展位 开发者模块 是一种易于使用的照片展示工具,可以让玩家用具有代表他们体验的背景进行独特姿势。

模块使用

安装

要在体验中使用 照片展位 模块:

  1. 视图选项卡打开工具箱并选择 创建者商店 选项卡。

    Toolbox toggle button in Studio
  2. 确保 模型 排序已选择,然后单击 查看全部 按钮以获取 类别

  3. 找到并单击 开发模块 瓦片。

  4. 找到 照片展位 模块并单击它,或拖放到3D视查看中。

  5. 浏览器 窗口中,将整个 照片摇杆 模型移至 ServerScriptService 。在运行体验时,模块将分配到各种服务并开始运行。

位置展台

模块带有一个 照片展位 模型,您可以在 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)

图形用户界面可见性

默认情况下,照片展位会隐藏所有的 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 = {}
-- 创建一个不会被隐藏的屏幕图形用户界面
local specialGuiInstance = Instance.new("ScreenGui")
-- 绘制照片展位上方的屏幕图形用户界面
specialGuiInstance.DisplayOrder = 1
specialGuiInstance.Parent = playerGui
-- 在屏幕图形用户界面上设置属性以防隐藏
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 中连接。

本地脚本' hightlight='5-7

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

打印出现

在用户显示输出时发生火灾。该事件只能在 LocalScript 中连接。

本地脚本' hightlight='5-7

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

快速显示

当打印关闭且相机按钮再次显示时发生火灾。此事件只能在 LocalScript 中连接。

本地脚本' hightlight='5-7

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

回调

隐藏其他用户界面

隐藏其他图形用回调界面(callback: function )

此回调在打印输出显示之前立即运行,让你在打印输出显示之前禁用整个 ScreenGuis 或其中的元素。照片展位使用的图形用户界面有属性 在照片展位中显示 设置为 true 。请参阅图形用户界面可见性获取详细信息和示例验证码。

显示其他图形界面

显示其他图形用户界面(回调: function )

此回调在打印关闭后运行,让你重新启用整个ScreenGuis或其中的元素。照片展位使用的图形用户界面有属性 在照片展位中显示 设置为 true 。请参阅图形用户界面可见性获取详细信息和示例验证码。