AvatarCreationService

顯示已棄用項目

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

無法建立
服務

AvatarCreationService 是一個支持開發者虛擬人偶創作者的服務,提供方法來支持體驗內的虛擬人偶創建提示。

概要

方法

屬性

方法

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,
},
...
}
}

返回

驗證規則詞典如上述詳細。

GenerateAvatar2DPreviewAsync

暫停

參數

avatarGeneration2dPreviewParams: Dictionary
預設值:""

返回

GetBatchTokenDetailsAsync

暫停

一次獲得一個列表的虛擬人偶創建代幣詳情(代幣通過 虛擬人偶創建 過程生成)。返回一個集合的虛擬人偶創建代碼詳情;每個詳情都是指示在下面示例結果中的字典欄位:


{
["Name"] = "string",
["Description"] = "string",
["UniverseId"] = 0,
["CreatorId"] = 0,
["CreatorType"] = Enum.CreatorType.User,
["OnSale"] = true,
["Price"] = 0,
["OffSaleReasons"] = {
"string",
}
}

參數

tokenIds: Array

獲得詳情的虛擬人偶創作代幣ID列表。

預設值:""

返回

上述所述的虛擬人偶創建代碼詳情。

LoadAvatar2DPreviewAsync

暫停

參數

previewId: string
預設值:""

返回

LoadGeneratedAvatarAsync

暫停

參數

generationId: string
預設值:""

返回

PrepareAvatarForPreviewAsync

()
暫停

參數

humanoidModel: Model
預設值:""

返回

()

PromptCreateAvatarAsync

暫停

提示 PlayerHumanoidDescription 購買並創建一個虛擬人偶。創作的價格由虛擬人偶創作代幣所附加的價格決定。此虛擬人偶創作代幣是購買和創建身體所需的,可以通過遵循 創作代幣生成過程 來生成。

對於虛擬人偶的創作品,HumanoidDescription 期望包含每個身體部位(HeadTorsoRightLegLeftLegRightArmLeftArm)所需的新資產。可選擇地,還可以包括新的 Hair 飾品。

為了支持這一點,HumanoidDescription 應包含 6 個BodyPartDescription兒童(每個身體部位一個)。對於每個, 屬性參考包含所有的 例,構成身體部分,例如一個 文件夾,包含 、 和 。屬性 BodyPartDescription.BodyPart 也應該設為相關的 Enum.BodyPart

每個身體部位 MeshPart 也需要包括:

如果包含髮型配件,例如頭髮,那麼 HumanoidDescription 應該包含一個子 AccessoryDescription ,其中:

最後, HumanoidDescription 應包括人形比例的 BodyTypeScale , HeadScale , HeightScale , WidthScale , 和 ProportionScale .請注意基礎身體所帶來的比例,以便它們與提供給 HumanoidDescription 的比例匹配。

參數

tokenId: string

虛擬人偶創作代幣的ID。代幣必須有效,即方法呼叫的宇宙與代幣創建的宇宙相同。此外,代幣創建者必須維持ID驗證和Roblox Premium。要在此 API 中使用代幣,請遵循 代幣創建過程

預設值:""
player: Player

意圖使用創建提示來呈現的 Player

預設值:""
humanoidDescription: HumanoidDescription

用於作品建的虛擬人偶的 HumanoidDescription

預設值:""

返回

包含順序的 tuple:

範例程式碼

The following code populates a HumanoidDescription in the expected format, prompts for avatar creation, and responds to the result.

PromptCreateAvatarAsync

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

暫停

僅限工作室。提供 PlayerInstance 給予 Enum.AccessoryType ,決定是否通過 UGC 驗證。

參數

player: Player

驗證 Player 已完成。

預設值:""
accessory: Instance

實例驗證已運行。

預設值:""
accessoryType: Enum.AccessoryType

Enum.AccessoryType 實例應該是。期望 Eyebrow , EyelashHair

預設值:""

返回

包含順序的 tuple:

  • 一個指示是否成功驗證飾品的 boolean 值。
  • 可選的字串表。這包括失敗原因,如果驗證失敗;否則 nil 如果驗證成功。

ValidateUGCBodyPartAsync

暫停

僅限工作室。給予 PlayerInstance 對於 Enum.BodyPart,判斷是否通過 UGC 驗證。在下列範例格式中,期望 參數作為 以相關 :

然而,如果預期的 bodyPartEnum.BodyPart.Head ,則函數直接使用單數 Head``Class.MeshPart

參數

player: Player

驗證 Player 已完成。

預設值:""
instance: Instance

實例驗證已運行。

預設值:""
bodyPart: Enum.BodyPart

Enum.BodyPart 實例應該是。

預設值:""

返回

包含順序的 tuple:

  • 一個指示是否成功驗證身體部分的 boolean 值。
  • 可選的字串表。這包括失敗原因,如果驗證失敗;否則 nil 如果驗證成功。

ValidateUGCFullBodyAsync

暫停

僅限工作室。提供 PlayerHumanoidDescription , 所有在 HumanoidDescription 中的實例都會被驗證。

期望 HumanoidDescription 包含在 BodyPartDescription 兒童上設置的實例,用於每個需要的 Enum.BodyPart 值。可選擇包含在 子女上設置的實例,用於 、 和 子女。

參數

player: Player

驗證 Player 已完成。

預設值:""
humanoidDescription: HumanoidDescription

HumanoidDescription 代表在驗證上運行的體。

預設值:""

返回

包含順序的 tuple:

  • 一個指示是否成功驗證身體的 boolean 值。
  • 可選的字串表。這包括失敗原因,如果驗證失敗;否則 nil 如果驗證成功。

活動

AvatarModerationCompleted

參數

outfitId: number
moderationStatus: Enum.ModerationStatus