AvatarCreationService

显示已弃用

*此内容使用人工智能(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

暂停

提示 Player 从一个 HumanoidDescription 购买并创建虚拟形象。创建的价格由虚拟形象创建代币的价格决定。这个虚拟形象创建代币是购买和创建身体所需的,可以通过遵循 创建代币生成过程 来生成。

对于虚拟形象作品,HumanoidDescription 期望包含为每个身体部位创建的新资产(HeadTorsoRightLegLeftLegRightArmLeftArm)。可选地,它还可以包括新的 Hair 饰品。

为了支持这一点, HumanoidDescription 应包含 6 个 BodyPartDescription 孩子(每个身体部分一个)。对于每个, 属性引用一个 包含所有构成身体部分的 实例,例如一个 文件夹,包含 , ,和 。BodyPartDescription.BodyPart 属性也应设置为相关的Enum.BodyPart

每个身体部分 MeshPart 也需要包括:

如果包含头发等配件,那么 HumanoidDescription 应包含一个子 AccessoryDescription ,其中:

最后, HumanoidDescription 应包含 BodyTypeScale , HeadScale , HeightScale , WidthScaleProportionScale 的人形尺寸。注意导入基础体的尺寸,使其与提供给 HumanoidDescription 的尺寸匹配。

参数

tokenId: string

虚拟形象创建代币的ID。代币必须有效,即方法调用的宇宙与代币创建的宇宙相同。此外,代币创建者必须维护ID验证和Roblox Premium。要创建一个在此 API 中使用的代币,请遵循 代币创建 过程。

默认值:""
player: Player

The 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 , Eyelash , 或 Hair .

默认值:""

返回

包含以下顺序的 tuple:

  • 一个用于指示是否验证成功的 boolean 值,用于饰品。
  • 可选的字符串表。这包括验证失败的原因,如果验证成功,则 nil 如果验证成功。

ValidateUGCBodyPartAsync

暂停

仅限工作室。给出一个 PlayerInstance 对于一个 Enum.BodyPart ,决定是否通过 UGC 验证。在下列示例格式中,期望 instance 参数作为 Folder 以相关 MeshParts

然而,如果期望的 bodyPartEnum.BodyPart.Head , 函数直接接受单数 Head``Class.MeshPart

参数

player: Player

验证 Player 已完成。

默认值:""
instance: Instance

实例验证已运行。

默认值:""
bodyPart: Enum.BodyPart

Enum.BodyPart 实例应该是。

默认值:""

返回

包含以下顺序的 tuple:

  • 一个指示是否验证成功的 boolean 值,用于身体部分。
  • 可选的字符串表。这包括验证失败的原因,如果验证成功,则 nil 如果验证成功。

ValidateUGCFullBodyAsync

暂停

仅限工作室。给予 PlayerHumanoidDescription , 所有在 HumanoidDescription 中的实例都将被验证。

HumanoidDescription 期望包含在每个需要的 BodyPartDescription 值上设置的实例,用于 6 个必需的 Enum.BodyPart 值。可选地,它可以包括在 AccessoryDescription 子上设置的实例为 Eyebrow , Eyelash , 和 Hair AccessoryTypes

参数

player: Player

验证 Player 已完成。

默认值:""
humanoidDescription: HumanoidDescription

HumanoidDescription 代表在验证运行时使用的身体。

默认值:""

返回

包含以下顺序的 tuple:

  • 一个指示是否验证成功的 boolean 值,用于身体。
  • 可选的字符串表。这包括验证失败的原因,如果验证成功,则 nil 如果验证成功。

活动

AvatarModerationCompleted

参数

outfitId: number
moderationStatus: Enum.ModerationStatus