AvatarEditorService

显示已弃用

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

无法创建
服务
未复制

AvatarEditorService 是支持开发者虚拟形象编辑器的服务。它提供方法来修改玩家的平台虚拟形象、查询用户的库存信息以及查询目录信息。

有关虚拟形象编辑器的更多信息,请参阅虚拟形象编辑器服务

限速

以下在 AvatarEditorService 上的端点有经验级别限制:

对于每个体验,这种限制可以让你每秒发送最多 100 个请求到这些 AvatarEditorService 端点,无论服务器数量或用户数量如何。超过这些限制会返回一个 429 Too Many Requests 错误。

如果您发现您的体验需要调整此限制,您可以提交功能请求

概要

方法

属性

方法

GetAccessoryType

参数

avatarAssetType: Enum.AvatarAssetType
默认值:""

返回

PromptAllowInventoryReadAccess

()

提示 Players.LocalPlayer 允许开发者阅读用户在库存和其他虚拟形象编辑器中的物品以及相关信息。提示需要由用户确认,以便开发者使用 AvatarEditorService:GetInventory()AvatarEditorService:GetOutfits()AvatarEditorService:GetFavorite()。权限在会话之间不会持续。


返回

()

PromptCreateOutfit

()

提示 Players.LocalPlayer 保存给定的 HumanoidDescription 为服装。不会产生。结果可以通过收听 AvatarEditorService.PromptCreateOutfitCompleted 事件来检索。

参数

玩家将被提示创建的 Outfit

默认值:""

玩家确认提示时将为服装创建的 Enum.RigType

默认值:""

返回

()

PromptDeleteOutfit

()

提示 Players.LocalPlayer 删除指定的服装。不会产生。结果可以通过收听 AvatarEditorService.PromptDeleteOutfitCompleted 事件来检索。

参数

outfitId: number

要删除的服装的 id。

默认值:""

返回

()

PromptRenameOutfit

()

提示 Players.LocalPlayer 重命名给定的服装。不会产生。结果可以通过听到 AvatarEditorService.PromptRenameOutfitCompleted 事件来检索。

参数

outfitId: number

服装的outfitId用于重命名服装。

默认值:""

返回

()

PromptSaveAvatar

()

这个函数提示 Players.LocalPlayer 更新他们的虚拟形象,基于给定的 HumanoidDescriptionEnum.RigType (R6 或 R15)。不会产生并且可以通过收听 PromptSaveAvatarCompleted 事件来获得结果。这与其他提示,例如提示购买,的工作方式相似。

参数

humanoidDescription: HumanoidDescription

给出的 HumanoidDescription 被要求保存。

默认值:""

如果玩家确认提示,虚拟形象将被保存的 Enum.RigType

默认值:""

返回

()

PromptSetFavorite

()

该函数提示 Players.LocalPlayer 将指定的资产或套装添加到收藏或取消收藏。

参数

itemId: number

被要求收设为“最爱”的物品的 ItemId。

默认值:""

被要求收设为“最爱”的物品类型。

默认值:""
shouldFavorite: boolean
默认值:""

返回

()

PromptUpdateOutfit

()

提示 Players.LocalPlayer 更新给定的服装,使其具有给定的人形描述。

参数

outfitId: number

要更新的服装的 id。

默认值:""
updatedOutfit: HumanoidDescription

一个代表新服装数据的人形描述。

默认值:""

HumanoidRigType用于更新服装。

默认值:""

返回

()

CheckApplyDefaultClothing

暂停

返回一个新的 HumanoidDescription ,包括更新的衬衫和裤子属性,如果需要的话。返回 nil 如果默认服装不需要。

如果 HumanoidDescription 目前没有配备衬衫和裤子,身体颜色太相似,默认服装是必需的。

参数

humanoidDescription: HumanoidDescription

用于检查是否需要默认服装的 HumanoidDescription。

默认值:""

返回

如果默认服装是必要的,返回 HumanoidDescription;否则返回 nil

ConformToAvatarRules

暂停

参数

humanoidDescription: HumanoidDescription
默认值:""

返回

GetAvatarRules

暂停

该函数返回平台虚拟形象规则,例如缩放、默认衬衫和裤子、可穿戴资产数量等。

返回的表包括以下字段:


{
"PlayerAvatarTypes": [
"R6"
],
"Scales": {},
"WearableAssetTypes": [
{
"MaxNumber": 0,
"Id": 0,
"Name": "string"
}
],
"BodyColorsPalette": [
{
"BrickColorId": 0,
"NexColor": "string",
"Name": "string"
}
],
"BasicBodyColorsPalette": [
{
"BrickColorId": 0,
"HexColor": "string",
"Name": "string"
}
],
"MinimumDeltaEBodyColorDifference": 0,
"ProportionsAndBodyTypeEnabledForUser": true,
"DefaultClothingAssetLists": {
"DefaultShirtAssetIds": [
0
],
"DefaultPantAssetIds": [
0
]
},
"BundlesEnabledForUser": true,
"EmotesEnabledForUser": true
}

返回

包含平台虚拟形象规则的词典,例如缩放、默认衬衫和裤子、可穿戴资产数量等。请参阅上面的主要描述中的示例返回。

GetBatchItemDetails

暂停

一次获取列表中的物品的详细信息。比 AvatarEditorService:GetItemDetails 更高效,如果你需要获取列表中所有物品的详细信息。

参数

itemIds: Array

获取详细信息的物品ID列表。

默认值:""

提供的物品ID类型。

默认值:""

返回

返回一个包含以下字段的物品详细信息阵列:


{
"AssetType" = "string",
"CreatorName" = "string",
"CreatorTargetId" = 0,
"CreatorType" = "string",
"Description" = "string",
"FavoriteCount" = 0,
"Genres" = [
"All"
],
"Id" = 0,
"ItemRestrictions" = [
"Limited"
],
"ItemStatus": [
"New"
],
"ItemType" = "string",
"LowestPrice" = 0,
"Name" = "string",
"Price" = 0,
"ProductId" = 0
}

.

GetFavorite

暂停

此函数返回是否 Players.LocalPlayer 收到了指定的包或素材的偏好。

参数

itemId: number

指定资产或套装的 ID。

默认值:""

指定资产或套装的 Enum.AvatarItemType

默认值:""

返回

无论 LocalPlayer 是否收藏了给定的包或素材。

GetInventory

暂停

返回一个 InventoryPages 对象,其中包含用户库存中拥有的物品信息,用给定的 AvatarAssetTypes

返回的表包括以下字段:


[
{
"AssetId": 0,
"AssetType" : "string",
"Created": "string",
"Name": "string",
}
]

参数

assetTypes: Array

可以在玩家的道具中检查的 Enum.AvatarAssetType

默认值:""

返回

GetItemDetails

暂停

该函数返回给定项目的物品详情。它接受两个参数 - 第一个表示正在检索的项目ID,第二个表示其Enum.ItemType

数据返回到格式:


{
"IsForRent": true,
"ExpectedSellerId": 0,
"Owned": true,
"IsPurchasable": true,
"Id": 0,
"ItemType": "Asset",
"AssetType": "Image",
"BundleType": "BodyParts",
"Name": "string",
"Description": "string",
"ProductId": 0,
"Genres": [
"All"
],
"BundledItems": [
{
"Owned": true,
"Id": 0,
"Name": "string",
"Type": "string"
}
],
"ItemStatus": [
"New"
],
"ItemRestrictions": [
"ThirteenPlus"
],
"CreatorType": "User",
"CreatorTargetId": 0,
"CreatorName": "string",
"Price": 0,
"PremiumPricing": {
"PremiumDiscountPercentage": 0,
"PremiumPriceInRobux": 0
},
"LowestPrice": 0,
"PriceStatus": "string",
"UnitsAvailableForConsumption": 0,
"PurchaseCount": 0,
"FavoriteCount": 0
}

要查询有限或无限资产,请使用以下 itemRestrictions 值:

| itemRestrictions | 有限或无限 | | :--------------: | :-------------------: | | empty | 无限制 | | Collectible | 限于 UGC 有限 | | Limited | Roblox 限制唯一 | | LimitedUnique | Roblox 限制无限 |

参数

itemId: number

被检索的物品的ID。

默认值:""

指示正在获取详情的物品类型的枚值。

默认值:""

返回

包含回收的物品目信息的表。请参阅上面的示例表。

GetOutfitDetails

暂停

该函数返回给定服装的服装详情。它接受一个参数:服装ID。

数据返回以下格式:


{
"Assets": [
{
"AssetType": {
"Id": 31,
"Name": "RightLeg"
}
"CurrentVersionId": 16447385805,
"Id": 11584239464,
"Name": "Anime Female - Right Leg"
}
],
"BodyColors": {
"HeadColor": Color3(204, 142, 105),
"LeftArmColor": Color3(204, 142, 105),
"LeftLegColor": Color3(204, 142, 105),
"RightArmColor": Color3(204, 142, 105),
"RightLegColor": Color3(204, 142, 105),
"TorsoColor": Color3(204, 142, 105)
},
"Id": 14703770624,
"IsEditable": true,
"Name": "Your Costume",
"OutfitType": "Avatar",
"PlayerAvatarType": "R15",
"Scale": {
"BodyType": 0,
"Depth": 1,
"Head": 1,
"Height": 1,
"Proportion": 0,
"Width": 1
},
}

参数

outfitId: number

被检索的服装详情的ID。

默认值:""

返回

包含回收的服装信息的表。请参阅上面的示例表。

GetOutfits

暂停

此函数返回服装数据给 Players.LocalPlayer。这将与 Players:GetHumanoidDescriptionFromOutfitId() 一起用于更新玩家角色到服装。访问此功能还取决于用户接受了 AvatarEditorService:PromptAllowInventoryReadAccess()

返回的表包括以下字段:


[
{
"Id": 0,
"Name": "string",
"IsEditable": true
}
]

<th>类输入</th>
<th>描述</th>
</tr>
</thead>
<tbody>
<tr>
<td>id</td><td>int</td>
<td />
</tr>
<tr>
<td>名称</td><td>字符串</td>
<td />
</tr>
<tr>
<td>可编辑</td><td>boolean</td>
<td />
</tr>
</tbody>
名称

参数

outfitSource: Enum.OutfitSource
默认值:"All"
outfitType: Enum.OutfitType
默认值:"All"

返回

GetRecommendedAssets

暂停

返回一个列表推荐的资产,基于给定的 Enum.AssetType 和资产ID。使用此来收集与提供的资产类似的资产列表。查看下面的代码示例以获取有关此函数的可能用途的更多信息。

数据以下格式:


[
{
"Item": {
"AssetId": 0,
"Name": "string",
"Price": 0,
"PremiumPrice": 0,
},
"Creator": {
"CreatorId": 0,
"CreatorType": "string",
"Name": "string",
},
"Product": {
"Id": 0,
"PriceInRobux": 0,
"IsForSale": true,
"IsResellable": true,
"IsLimited": true,
"IsLimitedUnique": true,
"TotalPrivateSales": 0,
"OffsaleDeadline": "string",
"IsFree": true
}
}
]

参数

要检索建议的资产类型。仅影响响应,当项目基于推荐不存在给定的 contextAssetId 时。

默认值:""
contextAssetId: number

具有与提供的资产类型匹配的资产ID的资产,用于在检索建议时的上下文。

默认值:0

返回

基于给定的 Enum.AssetType 的建议列表。

代码示例

This will return a list of similar hats much like how similar assets are displayed when viewing the catalog page on the website. The contextAssetId is optional and if not provided it will return some popular items from that category.

Getting a Hat Recommendation

local AvatarEditorService = game:GetService("AvatarEditorService")
local assets = AvatarEditorService:GetRecommendedAssets(Enum.AvatarAssetType.Hat, 9255093)
for _, asset in ipairs(assets) do
print(asset.Item.Name)
end

GetRecommendedBundles

暂停

该函数返回给定包 ID 的推荐包列表。

数据以下格式:


[
{
"Id": 0,
"Name": "string",
"Description": "string",
"BundleType": "string",
"Items": [
{
"Owned": true,
"Id": 0,
"Name": "string",
"Type": "string"
}
],
"Creator": {
"Id": 0,
"Name": "string",
"Type": "string"
},
"Product": {
"Id": 0,
"Type": "string",
"IsPublicDomain": true,
"IsForSale": true,
"PriceInRobux": 0,
"PremiumPricing": {
"PremiumDiscountPercentage": 0,
"PremiumPriceInRobux": 0
}
}
}
]

参数

bundleId: number

一列推荐的包裹列表。

默认值:""

返回

建议的包将返回的包 ID。

SearchCatalog

暂停

该函数返回包含给定搜索结果的 CatalogPages 对象。

返回的数据有格式:


[
{
"Id": 0,
"ItemType": "Asset",
"AssetType": "Image",
"BundleType": "BodyParts",
"Name": "string",
"Description": "string",
"ProductId": 0,
"Genres": [
"All"
],
"BundledItems": [
{
"Owned": true,
"Id": 0,
"Name": "string",
"Type": "string"
}
],
"ItemStatus": [
"New"
],
"ItemRestrictions": [
"ThirteenPlus"
],
"CreatorType": "User",
"CreatorTargetId": 0,
"CreatorName": "string",
"Price": 0,
"PremiumPricing": {
"PremiumDiscountPercentage": 0,
"PremiumPriceInRobux": 0
},
"LowestPrice": 0,
"PriceStatus": "string",
"UnitsAvailableForConsumption": 0,
"PurchaseCount": 0,
"FavoriteCount": 0
}
]

参数

searchParameters: CatalogSearchParams

包含搜索使用的参数的对象。

默认值:""

返回

活动

PromptAllowInventoryReadAccessCompleted

当用户回应 AvatarEditorService:PromptAllowInventoryReadAccess() 提示时,此事件发生。它只能返回成功或拒绝权限enum状态,因为它不会执行任何可能失败的网络请求。

参数

提示的结果。


PromptCreateOutfitCompleted

此事件在提示保存服装操作完成时发生。它提供一个状态 enum 指示用户是否成功、失败或未获得权限。

参数

提示的结果。

failureType: Variant

PromptDeleteOutfitCompleted

当提示删除服装操作完成时发生火灾。它提供一个状态 enum 指示用户是否成功、失败或未获得权限。

参数

提示的结果。


PromptRenameOutfitCompleted

当提示重命名服装操作完成时发生火灾。它提供一个状态 enum 指示用户是否成功、失败或未获得权限。

参数

提示的结果。


PromptSaveAvatarCompleted

此事件在 AvatarEditorService:PromptSaveAvatar() 操作完成时触发。它提供一个状态 enum ,表示提示是否成功、失败或用户没有授予权限。

参数

提示的结果。

humanoidDescription: HumanoidDescription

PromptSetFavoriteCompleted

AvatarEditorService:PromptSetFavorite() 操作完成时发生火灾。它提供一个状态 enum ,表示提示是否成功、失败或用户没有授予权限。

参数

提示的结果。


PromptUpdateOutfitCompleted

AvatarEditorService:PromptUpdateOutfit() 操作完成时发生火灾。它提供一个状态 enum ,表示提示是否成功、失败或用户没有授予权限。

参数

提示的结果。