Avatar Editor Service
摘要
方法
活动
PromptCreateOutfitCompleted(result: Enum.AvatarPromptResult,failureType: Variant):RBXScriptSignal |
PromptSaveAvatarCompleted(result: Enum.AvatarPromptResult,humanoidDescription: HumanoidDescription):RBXScriptSignal |
API 参考
方法
Check Apply Default Clothing
Check Apply Default Clothing Async
Avatar Editor Service: Check Apply Default Clothing Async(humanoid Description:HumanoidDescription):HumanoidDescription
参数
Conform To Avatar Rules
Conform To Avatar Rules Async
Avatar Editor Service: Conform To Avatar Rules Async(humanoid Description:HumanoidDescription):HumanoidDescription
参数
Get Accessory Type
参数
Get Avatar Rules
Get Batch Item Details
Get Batch Item Details Async
参数
返回
Get Bundles By Asset Id Async
Get Favorite
Get Favorite Async
参数
返回
Get Head Shapes Async
返回
代码示例
获取拥有的头型
local AvatarEditorService = game:GetService("AvatarEditorService")
-- 提示允许读取库存访问
AvatarEditorService:PromptAllowInventoryReadAccess()
local result = AvatarEditorService.PromptAllowInventoryReadAccessCompleted:Wait()
if result == Enum.AvatarPromptResult.Success then
-- 获取头部形状
local shapes = AvatarEditorService:GetHeadShapesAsync()
for i, shape in ipairs(shapes) do
print(i, shape)
end
endGet Inventory
Get Inventory Async
参数
代码示例
查找即将过期的物品
local AvatarEditorService = game:GetService("AvatarEditorService")
local pages = AvatarEditorService:GetInventoryAsync({ Enum.AvatarAssetType.Hat })
local currentPage = pages:GetCurrentPage()
for _, item in currentPage do
if item.ExpirationTime then
local secondsLeft = item.ExpirationTime.UnixTimestamp - DateTime.now().UnixTimestamp
local hoursLeft = math.floor(secondsLeft / 3600)
if hoursLeft < 24 then
warn(string.format("%s 在 %d 小时内过期", item.Name, hoursLeft))
end
end
endGet Item Details
Get Item Details Async
参数
代码示例
检查物品过期
local AvatarEditorService = game:GetService("AvatarEditorService")
local details = AvatarEditorService:GetItemDetailsAsync(105589844216517, Enum.AvatarItemType.Asset)
if details.ExpirationTime then
local secondsLeft = details.ExpirationTime.UnixTimestamp - DateTime.now().UnixTimestamp
local hoursLeft = math.floor(secondsLeft / 3600)
if hoursLeft < 24 then
warn(details.Name .. " 在24小时内过期!")
end
endGet Outfit Details
Get Outfit Details Async
Get Outfits
Get Outfits Async
Avatar Editor Service: Get Outfits Async(
参数
| 默认值:All |
| 默认值:All |
Get Recommended Assets
Get Recommended Assets Async
Avatar Editor Service: Get Recommended Assets Async(
参数
| 默认值:0 |
返回
代码示例
获取帽子推荐
local AvatarEditorService = game:GetService("AvatarEditorService")
local assets = AvatarEditorService:GetRecommendedAssetsAsync(Enum.AvatarAssetType.Hat, 9255093)
for _, asset in ipairs(assets) do
print(asset.Item.Name)
endGet Recommended Bundles
Get Recommended Bundles Async
Prompt Allow Inventory Read Access
Avatar Editor Service: Prompt Allow Inventory Read Access():()
返回
()
Prompt Create Outfit
Avatar Editor Service: Prompt Create Outfit(
outfit:HumanoidDescription, rig Type:Enum.HumanoidRigType, outfit Options:Dictionary, outfit Type:Variant
):()
参数
| 默认值:nil |
outfitType:Variant |
返回
()
Prompt Save Avatar
Avatar Editor Service: Prompt Save Avatar(
):()
参数
返回
()
Prompt Set Favorite
Avatar Editor Service: Prompt Set Favorite(
):()
参数
返回
()
Prompt Update Outfit
Avatar Editor Service: Prompt Update Outfit(
):()
参数
返回
()
Search Catalog
Search Catalog Async
参数
代码示例
搜索带有定时选项的物品
local AvatarEditorService = game:GetService("AvatarEditorService")
local params = CatalogSearchParams.new()
params.SalesTypeFilter = Enum.SalesTypeFilter.TimedOptions
params.Limit = 10
local pages = AvatarEditorService:SearchCatalogAsync(params)
local results = pages:GetCurrentPage()
for _, item in results do
if item.TimedOptions then
for _, option in item.TimedOptions do
local days = option.Duration / 86400
print(string.format("%s: %d 天, %d R$", item.Name, days, option.Price))
end
end
end活动
Prompt Allow Inventory Read Access Completed
Avatar Editor Service. Prompt Allow Inventory Read Access Completed(result:Enum.AvatarPromptResult):RBXScriptSignal
参数
Prompt Create Outfit Completed
Avatar Editor Service. Prompt Create Outfit Completed(
参数
failureType:Variant |
代码示例
处理服装创建结果
local AvatarEditorService = game:GetService("AvatarEditorService")
AvatarEditorService.PromptCreateOutfitCompleted:Connect(function(result, failureType)
if result == Enum.AvatarPromptResult.Success then
-- 服装已创建
elseif result == Enum.AvatarPromptResult.PermissionDenied then
-- 用户拒绝了提示;忽略 failureType
else -- Enum.AvatarPromptResult.Failed
if failureType == Enum.CreateOutfitFailure.OutfitLimitReached then
-- 告诉用户他们达到了服装上限
elseif failureType == Enum.CreateOutfitFailure.InvalidName then
-- 告诉用户选择一个不同的名称
else -- Enum.CreateOutfitFailure.Other
-- 通用失败;重试或显示通用错误
end
end
end)Prompt Delete Outfit Completed
参数
Prompt Rename Outfit Completed
参数
Prompt Save Avatar Completed
Avatar Editor Service. Prompt Save Avatar Completed(
参数
Prompt Set Favorite Completed
参数
Prompt Update Outfit Completed
参数