AvatarCreationService 是一個支持開發者虛擬人偶創作者的服務,提供方法來支持體驗內的虛擬人偶創建提示。
概要
方法
取得資產必須遵守的規則來通過 UGC 驗證的數據。
一次獲得一個列表的虛擬人偶創建代幣詳情。
- PromptCreateAvatarAsync(tokenId : string,player : Player,humanoidDescription : HumanoidDescription):Tuple
提示 Player 從 HumanoidDescription 購買並創建一個虛擬人偶。
- ValidateUGCAccessoryAsync(player : Player,accessory : Instance,accessoryType : Enum.AccessoryType):Tuple
僅限工作室。對 Enum.AccessoryType 執行 UGC 驗證。
僅限工作室。對 Enum.BodyPart 執行 UGC 驗證。
僅限工作室。對全身體進行 UGC 驗證。
活動
- AvatarModerationCompleted(outfitId : number,moderationStatus : Enum.ModerationStatus):RBXScriptSignal
屬性
方法
GetValidationRules
取得資產必須遵守的規則來通過 UGC 驗證的數據。驗證是創建虛擬人偶之前的必要步驟,包括網格三角限制、紋理尺寸、身體部位尺寸限制、附件位置等各種檢查。
返回的驗證規則辭典以下形式:
{["MeshRules"] = {["BodyPartMaxTriangles"] = {Enum.AssetType.DynamicHead: number,Enum.AssetType.LeftArm: number,Enum.AssetType.RightArm: number,Enum.AssetType.Torso: number,Enum.AssetType.LeftLeg: number,Enum.AssetType.RightLeg: number,},["AccessoryMaxTriangles"]: number,["MeshVertColor"]: Color3,["CageMeshMaxDistanceFromRenderMesh"]: number,},["TextureRules"] = {["MaxTextureSize"]: number,},["BodyPartRules"] = {[Enum.AssetType.DynamicHead] = {["Bounds"] = {["Classic"] = {["MinSize"]: Vector3,["MaxSize"]: Vector3,},["ProportionsSlender"] = {["MinSize"]: Vector3,["MaxSize"]: Vector3,},["ProportionsNormal"] = {["MinSize"]: Vector3,["MaxSize"]: Vector3,},},["SubParts"] = {["Head"] = {["NeckRigAttachment"] = {["LowerBound"]: Vector3,["UpperBound"]: Vector3,},["FaceFrontAttachment"] = {["LowerBound"]: Vector3,["UpperBound"]: Vector3,},["HatAttachment"] = {["LowerBound"]: Vector3,["UpperBound"]: Vector3,},["HairAttachment"] = {["LowerBound"]: Vector3,["UpperBound"]: Vector3,},["FaceCenterAttachment"] = {["LowerBound"]: Vector3,["UpperBound"]: Vector3,},},},},[Enum.AssetType.LeftArm] = {["Bounds"] = {["Classic"] = {["MinSize"]: Vector3,["MaxSize"]: Vector3,},["ProportionsSlender"] = {["MinSize"]: Vector3,["MaxSize"]: Vector3,},["ProportionsNormal"] = {["MinSize"]: Vector3,["MaxSize"]: Vector3,},},["SubParts"] = {["LeftHand"] = {["LeftWristRigAttachment"] = {["LowerBound"]: Vector3,["UpperBound"]: Vector3,},["LeftGripAttachment"] = {["LowerBound"]: Vector3,["UpperBound"]: Vector3,},},["LeftUpperArm"] = {["LeftShoulderRigAttachment"] = {["LowerBound"]: Vector3,["UpperBound"]: Vector3,},["LeftShoulderAttachment"] = {["LowerBound"]: Vector3,["UpperBound"]: Vector3,},["LeftElbowRigAttachment"] = {["LowerBound"]: Vector3,["UpperBound"]: Vector3,},},["LeftLowerArm"] = {["LeftElbowRigAttachment"] = {["LowerBound"]: Vector3,["UpperBound"]: Vector3,},["LeftWristRigAttachment"] = {["LowerBound"]: Vector3,["UpperBound"]: Vector3,},},},},...},["AccessoryRules"] = {[Enum.AssetType.HairAccessory] = {["Attachments"] = {{["Size"]: Vector3,["Offset"]: Vector3,["Name"]: string,},},["RigidAllowed"]: boolean,},...}}
返回
驗證規則詞典如上述詳細。
GetBatchTokenDetailsAsync
一次獲得一個列表的虛擬人偶創建代幣詳情(代幣通過 虛擬人偶創建 過程生成)。返回一個集合的虛擬人偶創建代碼詳情;每個詳情都是指示在下面示例結果中的字典欄位:
{["Name"] = "string",["Description"] = "string",["UniverseId"] = 0,["CreatorId"] = 0,["CreatorType"] = Enum.CreatorType.User,["OnSale"] = true,["Price"] = 0,["OffSaleReasons"] = {"string",}}
參數
獲得詳情的虛擬人偶創作代幣ID列表。
返回
上述所述的虛擬人偶創建代碼詳情。
PromptCreateAvatarAsync
提示 Player 從 HumanoidDescription 購買並創建一個虛擬人偶。創作的價格由虛擬人偶創作代幣所附加的價格決定。此虛擬人偶創作代幣是購買和創建身體所需的,可以通過遵循 創作代幣生成過程 來生成。
對於虛擬人偶的創作品,HumanoidDescription 期望包含每個身體部位(Head、Torso、RightLeg、LeftLeg、RightArm、LeftArm)所需的新資產。可選擇地,還可以包括新的 Hair 飾品。
為了支持這一點,HumanoidDescription 應包含 6 個BodyPartDescription兒童(每個身體部位一個)。對於每個, 屬性參考包含所有的 例,構成身體部分,例如一個 文件夾,包含 、 和 。屬性 BodyPartDescription.BodyPart 也應該設為相關的 Enum.BodyPart 。
每個身體部位 MeshPart 也需要包括:
- An EditableImage .
- 一個 WrapDeformer 具有 EditableMesh 。
如果包含髮型配件,例如頭髮,那麼 HumanoidDescription 應該包含一個子 AccessoryDescription ,其中:
- AccessoryDescription.Instance 屬性參考 Accessory 實個體、實例。
最後, HumanoidDescription 應包括人形比例的 BodyTypeScale , HeadScale , HeightScale , WidthScale , 和 ProportionScale .請注意基礎身體所帶來的比例,以便它們與提供給 HumanoidDescription 的比例匹配。
參數
虛擬人偶創作代幣的ID。代幣必須有效,即方法呼叫的宇宙與代幣創建的宇宙相同。此外,代幣創建者必須維持ID驗證和Roblox Premium。要在此 API 中使用代幣,請遵循 代幣創建過程。
用於作品建的虛擬人偶的 HumanoidDescription。
返回
包含順序的 tuple:
一個 Enum.PromptCreateAvatarResult 指示創建提示的結果。
字串結果。在 Enum.PromptCreateAvatarResult.Success 的情況下,這會指示包裝 ID。在任何失敗枚列的情況下,這將指示結果的錯誤訊息。
一個可選的次要字串結果。在 Enum.PromptCreateAvatarResult.Success 的情況下,這會指示服裝ID。在任何失敗枚列的情況下,這將是 nil 。
範例程式碼
The following code populates a HumanoidDescription in the expected format, prompts for avatar creation, and responds to the result.
local AvatarCreationService = game:GetService("AvatarCreationService")
export type BodyPartInfo = {
bodyPart: Enum.BodyPart,
instance: Instance, --Folder with Created MeshParts
}
export type BodyPartList = { BodyPartInfo }
local function publishAvatar(bodyPartInstances: BodyPartList, player: Player, tokenId: string)
local humanoidDescription = Instance.new("HumanoidDescription")
for _, bodyPartInfo in bodyPartInstances do
local bodyPartDescription = Instance.new("BodyPartDescription")
bodyPartDescription.Instance = bodyPartInfo.instance
bodyPartDescription.BodyPart = bodyPartInfo.bodyPart
bodyPartDescription.Parent = humanoidDescription
end
local pcallSuccess, result, resultMessage = pcall(function()
return AvatarCreationService:PromptCreateAvatarAsync(tokenId, player, humanoidDescription)
end)
if pcallSuccess then
if result == Enum.PromptCreateAvatarResult.Success then
print("Successfully uploaded with BundleId: ", resultMessage)
else
print("Unsuccessfully uploaded with error message:", resultMessage)
end
else
print("Avatar failed to create.")
end
end
ValidateUGCAccessoryAsync
僅限工作室。提供 Player 和 Instance 給予 Enum.AccessoryType ,決定是否通過 UGC 驗證。
參數
實例驗證已運行。
Enum.AccessoryType 實例應該是。期望 Eyebrow , Eyelash 或 Hair 。
返回
包含順序的 tuple:
- 一個指示是否成功驗證飾品的 boolean 值。
- 可選的字串表。這包括失敗原因,如果驗證失敗;否則 nil 如果驗證成功。
ValidateUGCBodyPartAsync
僅限工作室。給予 Player 和 Instance 對於 Enum.BodyPart,判斷是否通過 UGC 驗證。在下列範例格式中,期望 參數作為 以相關 :
然而,如果預期的 bodyPart 是 Enum.BodyPart.Head ,則函數直接使用單數 Head``Class.MeshPart 。
參數
實例驗證已運行。
Enum.BodyPart 實例應該是。
返回
包含順序的 tuple:
- 一個指示是否成功驗證身體部分的 boolean 值。
- 可選的字串表。這包括失敗原因,如果驗證失敗;否則 nil 如果驗證成功。
ValidateUGCFullBodyAsync
僅限工作室。提供 Player 和 HumanoidDescription , 所有在 HumanoidDescription 中的實例都會被驗證。
期望 HumanoidDescription 包含在 BodyPartDescription 兒童上設置的實例,用於每個需要的 Enum.BodyPart 值。可選擇包含在 子女上設置的實例,用於 、 和 子女。
參數
HumanoidDescription 代表在驗證上運行的體。
返回
包含順序的 tuple:
- 一個指示是否成功驗證身體的 boolean 值。
- 可選的字串表。這包括失敗原因,如果驗證失敗;否則 nil 如果驗證成功。