AvatarCreationService

Mostrar obsoleto

*Pronto este contenido estará disponible en tu idioma seleccionado.

No creable
Servicio

AvatarCreationService is a service that supports developer avatar creators, providing methods that support the prompting of avatar creation from within experiences.

Resumen

Métodos

Propiedades

Métodos

GetValidationRules

Gets data regarding rules that assets must abide by to pass UGC validation. Validation is an essential step before creating avatars and there are various checks that occur, including mesh triangle limits, texture sizes, body part size limits, attachment positions, and more.

The returned dictionary of validation rules takes the following form:


{
["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,
},
...
}
}

Devuelve

Dictionary of validation rules as detailed above.

GetBatchTokenDetailsAsync

Proporciona

Gets the avatar creation token details for a list of avatar creation tokens at once. Returns an array of avatar creation token details; each token detail is a dictionary with the fields indicated in the example result below:


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

Parámetros

tokenIds: Array

The list of avatar creation token IDs to get details of.


Devuelve

Array of avatar creation token details as outlined above.

PromptCreateAvatarAsync

Proporciona

Prompts a Player to purchase and create an avatar from a HumanoidDescription. The price of the creation is dictated by the price attributed to the avatar creation token.

For avatar creation, the HumanoidDescription is expected to include new assets to be created for each of the 6 body parts (Head, Torso, RightLeg, LeftLeg, RightArm, LeftArm). Optionally, it can also include a new Hair accessory.

To support this, the HumanoidDescription should include 6 BodyPartDescription children (one for each body part). For each, the BodyPartDescription.Instance property references a Folder which includes all of the MeshPart instances which make up the body part, for example a LeftArm folder which has LeftHand, LeftUpperArm, and LeftLowerArm MeshParts. The BodyPartDescription.BodyPart property should also be set to the relevant Enum.BodyPart.

Each body part MeshPart will also need to include:

If including an accessory such as hair, the HumanoidDescription should include a child AccessoryDescription where:

Finally, the HumanoidDescription should include the humanoid scales of BodyTypeScale, HeadScale, HeightScale, WidthScale, and ProportionScale. Be mindful of the scales that a base body is imported with so that they match the scales provided to the HumanoidDescription.

Parámetros

tokenId: string

The ID of an avatar creation token. The token must be valid in that the universe the method is called from is the same universe the token was created for. Furthermore, the token creator must maintain ID verification and Roblox Premium.

player: Player

The Player intended to be presented with the creation prompt.

humanoidDescription: HumanoidDescription

The HumanoidDescription of the avatar intended for creation.


Devuelve

A tuple containing, in order:

Muestras de código

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

PromptSelectAvatarGenerationImageAsync

Proporciona

Parámetros

player: Player

Devuelve

ValidateUGCAccessoryAsync

Proporciona

Studio only. Given a Player and Instance for an Enum.AccessoryType, determines if UGC validation passes.

Parámetros

player: Player

The Player validation is completed for.

accessory: Instance

The instance validation is run on.

accessoryType: Enum.AccessoryType

Enum.AccessoryType the instance is expected to be. Expects Eyebrow, Eyelash, or Hair.


Devuelve

A tuple containing, in order:

  • A boolean indicating if validation was successful for the accessory.
  • An optional table of strings. This includes failure reasons if validation was unsuccessful; otherwise nil if validation was successful.

ValidateUGCBodyPartAsync

Proporciona

Studio only. Given a Player and Instance for an Enum.BodyPart, determines if UGC validation passes. The instance parameter is expected as a Folder in the following example format with relevant MeshParts:

However, if the expected bodyPart is Enum.BodyPart.Head, the function takes a singular Head MeshPart directly.

Parámetros

player: Player

The Player validation is completed for.

instance: Instance

The instance validation is run on.

bodyPart: Enum.BodyPart

Enum.BodyPart the instance is expected to be.


Devuelve

A tuple containing, in order:

  • A boolean indicating if validation was successful for the body part.
  • An optional table of strings. This includes failure reasons if validation was unsuccessful; otherwise nil if validation was successful.

ValidateUGCFullBodyAsync

Proporciona

Studio only. Given a Player and HumanoidDescription, all instances in the HumanoidDescription will be validated.

The HumanoidDescription is expected to include instances set on BodyPartDescription children for each of the 6 required Enum.BodyPart values. Optionally, it can include instances set on AccessoryDescription children for Eyebrow, Eyelash, and Hair AccessoryTypes.

Parámetros

player: Player

The Player validation is completed for.

humanoidDescription: HumanoidDescription

HumanoidDescription representing the body that validation is run on.


Devuelve

A tuple containing, in order:

  • A boolean indicating if validation was successful for the body.
  • An optional table of strings. This includes failure reasons if validation was unsuccessful; otherwise nil if validation was successful.

Eventos