概要
方法
活动
PromptCreateOutfitCompleted(result: Enum.AvatarPromptResult,failureType: Variant):RBXScriptSignal |
PromptSaveAvatarCompleted(result: Enum.AvatarPromptResult,humanoidDescription: HumanoidDescription):RBXScriptSignal |
API 参考
方法
CheckApplyDefaultClothing
CheckApplyDefaultClothingAsync
AvatarEditorService:CheckApplyDefaultClothingAsync(humanoidDescription:HumanoidDescription):HumanoidDescription
参数
ConformToAvatarRules
ConformToAvatarRulesAsync
AvatarEditorService:ConformToAvatarRulesAsync(humanoidDescription:HumanoidDescription):HumanoidDescription
参数
GetAccessoryType
参数
GetAvatarRules
GetBatchItemDetails
GetBatchItemDetailsAsync
参数
返回
GetBundlesByAssetIdAsync
GetFavorite
GetFavoriteAsync
参数
返回
GetHeadShapesAsync
返回
代码示例
获取拥有的头型
测试
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
endGetInventory
GetInventoryAsync
参数
代码示例
查找即将过期的物品
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
endGetItemDetails
GetItemDetailsAsync
参数
代码示例
检查物品过期
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
endGetOutfitDetails
GetOutfitDetailsAsync
GetOutfits
GetOutfitsAsync
AvatarEditorService:GetOutfitsAsync(
参数
| 默认值:"All" |
| 默认值:"All" |
GetRecommendedAssets
GetRecommendedAssetsAsync
AvatarEditorService:GetRecommendedAssetsAsync(
参数
| 默认值:0 |
返回
代码示例
获取帽子推荐
local AvatarEditorService = game:GetService("AvatarEditorService")
local assets = AvatarEditorService:GetRecommendedAssetsAsync(Enum.AvatarAssetType.Hat, 9255093)
for _, asset in ipairs(assets) do
print(asset.Item.Name)
endGetRecommendedBundles
GetRecommendedBundlesAsync
PromptAllowInventoryReadAccess
AvatarEditorService:PromptAllowInventoryReadAccess():()
返回
()
PromptCreateOutfit
AvatarEditorService:PromptCreateOutfit(
outfit:HumanoidDescription, rigType:Enum.HumanoidRigType, outfitOptions:Dictionary, outfitType:Variant
):()
参数
| 默认值:"nil" |
outfitType:Variant |
返回
()
PromptSaveAvatar
AvatarEditorService:PromptSaveAvatar(
):()
参数
返回
()
PromptSetFavorite
AvatarEditorService:PromptSetFavorite(
):()
参数
返回
()
PromptUpdateOutfit
AvatarEditorService:PromptUpdateOutfit(
):()
参数
返回
()
SearchCatalog
SearchCatalogAsync
参数
代码示例
搜索带有定时选项的物品
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活动
PromptAllowInventoryReadAccessCompleted
AvatarEditorService.PromptAllowInventoryReadAccessCompleted(result:Enum.AvatarPromptResult):RBXScriptSignal
参数
PromptCreateOutfitCompleted
AvatarEditorService.PromptCreateOutfitCompleted(
参数
failureType:Variant |
PromptDeleteOutfitCompleted
参数
PromptRenameOutfitCompleted
参数
PromptSaveAvatarCompleted
AvatarEditorService.PromptSaveAvatarCompleted(
参数
PromptSetFavoriteCompleted
参数
PromptUpdateOutfitCompleted
参数