AvatarEditorService 是一個支援開發者虛擬角色編輯器的服務。它提供了修改玩家平台虛擬角色的方法,請求有關用戶的庫存資訊,以及請求有關目錄的資訊。
有關虛擬角色編輯器的更多資訊,請參閱 虛擬角色編輯器服務。
限制
以下 AvatarEditorService 的端點有體驗級別的限制:
對於每個體驗,此限制允許您每秒向這些 AvatarEditorService 端點發送最多 100 個請求,而不管服務器數量或用戶數量。超過這些限制將返回 429 請求過多 錯誤。
概要
方法
用於在必要時將預設服裝應用到 HumanoidDescription。
返回平台虛擬角色的規則,例如縮放、預設衫和褲子、可穿戴資產的數量等。
同時獲取多個項目的詳細資訊。
返回 Players.LocalPlayer 是否已將給定的包或資產加入最愛。
返回一個 InventoryPages 對象,提供有關用戶庫存中擁有的項目的資訊,並基於給定的 AvatarAssetTypes 進行查詢。
返回給定項目的詳細資訊。
返回給定服裝的服裝詳情。
返回 Players.LocalPlayer 的服裝數據。
返回基於給定 Enum.AssetType 和資產 ID 的推薦資產列表。
返回給定包 ID 的推薦包列表。
提示 Players.LocalPlayer 允許開發者閱讀用戶在庫存中的項目和其他與虛擬角色編輯器相關的資訊。
提示 Players.LocalPlayer 將給定的 HumanoidDescription 保存為服裝。
提示 Players.LocalPlayer 刪除給定的服裝。
提示 Players.LocalPlayer 重命名給定的服裝。
提示 Players.LocalPlayer 根據給定的 HumanoidDescription 和 R6 或 R15 的 Enum.RigType 更新其虛擬角色。
提示 Players.LocalPlayer 將給定的資產或包加入最愛或取消最愛。
- PromptUpdateOutfit(outfitId : number,updatedOutfit : HumanoidDescription,rigType : Enum.HumanoidRigType):()
提示 Players.LocalPlayer 更新給定的服裝。
返回包含給定搜索結果的 CatalogPages 對象。
活動
當用戶回應 AvatarEditorService:PromptAllowInventoryReadAccess() 提示時觸發。
當 PromptSaveOutfit 操作完成時觸發。
當 PromptDeleteOutfit 操作完成時觸發。
當 PromptRenameOutfit 操作完成時觸發。
- PromptSaveAvatarCompleted(result : Enum.AvatarPromptResult,humanoidDescription : HumanoidDescription):RBXScriptSignal
當 AvatarEditorService:PromptSaveAvatar() 操作完成時觸發。
當 AvatarEditorService:PromptSetFavorite() 操作完成時觸發。
當 AvatarEditorService:PromptUpdateOutfit() 操作完成時觸發。
屬性
方法
CheckApplyDefaultClothing
返回一個更新了衫和褲子屬性的新的 HumanoidDescription(如果需要)。如果不需要預設服裝,則返回 nil。
如果 HumanoidDescription 當前沒有配備衫和褲子且身體顏色太過相似,則需要預設服裝。
參數
要檢查是否需要預設服裝的 HumanoidDescription。
返回
如果需要預設服裝,則返回 HumanoidDescription。否則返回 nil。
ConformToAvatarRules
參數
返回
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 更高效。
參數
要獲取詳情的項目 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 是否已將給定的包或資產加入最愛。
參數
指定資產或包的 ID。
指定資產或包的 Enum.AvatarItemType。
返回
本地玩家是否已將給定的包或資產加入最愛。
GetInventory
返回一個 InventoryPages 對象,提供有關用戶庫存中擁有的項目的訊息,並基於給定的 AvatarAssetTypes 進行查詢。
返回的表格包括以下字段:
[{"AssetId": 0,"AssetType" : "string","Created": "string","Name": "string",}]
參數
玩家庫存中將要檢查的 Enum.AvatarAssetType。
返回
GetItemDetails
此函數返回給定項目的詳細資訊。它接受兩個參數 - 第一個表示要檢索的項目的 ID,第二個表示其 Enum.AvatarItemType。
返回的數據格式為:
{"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 有限獨特 |
參數
構建中檢索詳細資訊的項目 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},}
參數
構建中檢索詳細資訊的服裝 ID。
返回
包含已檢索服裝信息的表格。請參閱上面的示例表格。
GetOutfits
此函數返回 Players.LocalPlayer 的服裝數據。 這將與 Players:GetHumanoidDescriptionFromOutfitId() 用於更新玩家的 角色到這套服裝。訪問這將取決於 AvatarEditorService:PromptAllowInventoryReadAccess() 是否被用戶接受。
返回的表格包括以下字段:
[{"Id": 0,"Name": "string","IsEditable": true}]
名稱 | 類型 | 描述 |
---|---|---|
id | int | |
name | string | |
isEditable | boolean |
參數
返回
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 不存在基於項目的建議時影響響應。
具有與所提供的 assetType 匹配的類型的資產 ID,在檢索建議時用作上下文。
返回
基於給定的 Enum.AssetType 的推薦列表。
範例程式碼
這將返回一個類似帽子的列表,就像在網站的目錄頁面上查看類似資產時展示的那樣。contextAssetId 是可選的,如果未提供,將返回該類別的一些熱門商品。
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}}}]
參數
一個推薦包的列表。
返回
將返回的推薦包的包 ID。
PromptAllowInventoryReadAccess
提示 Players.LocalPlayer 允許開發者閱讀用戶在庫存中的項目和其他與虛擬角色編輯器相關的資訊。用戶需要確認提示,開發者才能使用 AvatarEditorService:GetInventory(), AvatarEditorService:GetOutfits() 和 AvatarEditorService:GetFavorite()。權限不會在會話之間持續。
返回
PromptCreateOutfit
提示 Players.LocalPlayer 將給定的 HumanoidDescription 保存為服裝。此操作不會暫停。可以通過監聽 AvatarEditorService.PromptCreateOutfitCompleted 事件來檢索結果。
參數
玩家將被提示創建的服裝。
如果玩家確認提示,則將為服裝創建的 Enum.RigType。
返回
PromptDeleteOutfit
提示 Players.LocalPlayer 刪除給定的服裝。此操作不會暫停。可以通過監聽 AvatarEditorService.PromptDeleteOutfitCompleted 事件來檢索結果。
參數
要刪除的服裝 ID。
返回
PromptRenameOutfit
提示 Players.LocalPlayer 重命名給定的服裝。此操作不會暫停。可以通過監聽 AvatarEditorService.PromptRenameOutfitCompleted 事件來檢索結果。
參數
要重命名的服裝 ID。
返回
PromptSaveAvatar
此函數提示 Players.LocalPlayer 根據給定的 HumanoidDescription 和 Enum.RigType (R6 或 R15) 更新其虛擬角色。此操作不會暫停,可以通過監聽 PromptSaveAvatarCompleted 事件來獲取結果。這類似於其他提示,例如 PromptPurchase 的工作方式。
參數
要提示保存的 HumanoidDescription。
如果玩家確認提示,則將為虛擬角色保存的 Enum.RigType。
返回
PromptUpdateOutfit
提示 Players.LocalPlayer 使用給定的 HumanoidDescription 更新給定的服裝。
參數
要更新的服裝 ID。
代表新服裝數據的 HumanoidDescription。
要更新到的 HumanoidRigType。
返回
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}]
參數
一個對象,包含用於搜索的參數。
返回
活動
PromptAllowInventoryReadAccessCompleted
此事件在用戶回應 AvatarEditorService:PromptAllowInventoryReadAccess() 提示時觸發。它僅能返回 Success 或 PermissionDenied enum 狀態,因為它不會執行任何可能失敗的網路請求。
參數
提示的結果。
PromptCreateOutfitCompleted
此事件在 PromptSaveOutfit 操作完成時觸發。它給出了 enum 狀態,指示提示是否成功、失敗或用戶未授予權限。
參數
提示的結果。
PromptSaveAvatarCompleted
此事件在 AvatarEditorService:PromptSaveAvatar() 操作完成時觸發。給出了 enum 狀態,指示提示是否成功、失敗或用戶未授予權限。
參數
提示的結果。
PromptSetFavoriteCompleted
當 AvatarEditorService:PromptSetFavorite() 操作完成時觸發。它給出了 enum 狀態,指示提示是否成功、失敗或用戶未授予權限。
參數
提示的結果。
PromptUpdateOutfitCompleted
當 AvatarEditorService:PromptUpdateOutfit() 操作完成時觸發。它給出了 enum 狀態,指示提示是否成功、失敗或用戶未授予權限。
參數
提示的結果。