Asset Service
요약
메서드
상속된 멤버
API 참조
속성
메서드
Compose Decal Async
반환
()
코드 샘플
데칼 만들기
local AssetService = game:GetService("AssetService")
-- 두 개의 데칼 인스턴스를 생성합니다
local decalA = Instance.new("Decal")
local decalB = Instance.new("Decal")
-- 복합 정보 테이블을 만듭니다
local compositeInfo = {
{
ColorMap = decalA.ColorMapContent,
RoughnessMap = decalA.RoughnessMapContent,
MetalnessMap = decalA.MetalnessMapContent,
NormalMap = decalA.NormalMapContent,
},
{
ColorMap = Content.fromAssetId(123456),
RoughnessMap = decalB.RoughnessMapContent,
MetalnessMap = decalB.MetalnessMapContent,
NormalMap = decalB.NormalMapContent,
}
}
-- 조합할 데칼을 생성합니다
local compositeDecal = Instance.new("Decal")
-- AssetService를 사용하여 기존 데칼을 조합합니다
local success, errorMessage = pcall(function()
AssetService:ComposeDecalAsync(compositeDecal, compositeInfo)
end)
if success then
print("데칼 조합이 성공적으로 완료되었습니다!")
-- 데칼을 표시/사용하는 로직이 여기에 들어갑니다
else
warn("데칼 조합에 실패했습니다:", errorMessage)
endCreate Asset Async
Asset Service: Create Asset Async(
매개 변수
| 기본값: nil |
반환
코드 샘플
AssetService:CreateAssetAsync
local AssetService = game:GetService("AssetService")
local editableMesh = AssetService:CreateEditableMesh()
-- 메시에 정점, 면, UV 추가
local requestParameters = {
CreatorId = 123,
CreatorType = Enum.AssetCreatorType.User,
Name = "내 자산",
Description = "좋은 자산",
}
local ok, result, idOrUploadErr = pcall(function()
return AssetService:CreateAssetAsync(editableMesh, Enum.AssetType.Mesh, requestParameters)
end)
if not ok then
warn(`CreateAssetAsync 호출 중 오류: {result}`)
elseif result == Enum.CreateAssetResult.Success then
print(`성공, 새로운 자산 ID: {idOrUploadErr}`)
else
warn(`CreateAssetAsync에서 업로드 오류: {result}, {idOrUploadErr}`)
endCreate Asset Version Async
Asset Service: Create Asset Version Async(
매개 변수
| 기본값: nil |
반환
코드 샘플
AssetService:CreateAssetVersionAsync
local AssetService = game:GetService("AssetService")
local assetIdToUpdate = 321
local model = Instance.new("Model")
local requestParameters = {
CreatorId = 123,
CreatorType = Enum.AssetCreatorType.User,
}
local ok, result, versionOrUploadErr = pcall(function()
return AssetService:CreateAssetVersionAsync(model, Enum.AssetType.Model, assetIdToUpdate, requestParameters)
end)
if not ok then
warn(`CreateAssetVersionAsync 호출 중 오류 발생: {result}`)
elseif result == Enum.CreateAssetResult.Success then
print(`성공, 새로운 자산 버전: {versionOrUploadErr}`)
else
warn(`CreateAssetVersionAsync에서 업로드 오류 발생: {result}, {versionOrUploadErr}`)
endCreate Data Model Content Async
매개 변수
반환
Create Decal Async
Create Editable Image
매개 변수
Create Editable Image Async
Asset Service: Create Editable Image Async(
매개 변수
Create Editable Mesh
매개 변수
Create Editable Mesh Async
매개 변수
Create Mesh Part Async
매개 변수
| 기본값: nil |
반환
Create Place Async
Create Place In Player Inventory Async
Create Surface Appearance Async
매개 변수
코드 샘플
AssetService:CreateSurfaceAppearanceAsync
local AssetService = game:GetService("AssetService")
local Workspace = game:GetService("Workspace")
-- 녹색 색상 - 편집 가능한 이미지 콘텐츠
local colorEditableImage = AssetService:CreateEditableImage({ Size = Vector2.new(4, 4) })
colorEditableImage:DrawRectangle(Vector2.zero, colorEditableImage.Size, Color3.fromRGB(0, 255, 0), 0, Enum.ImageCombineType.Overwrite)
-- 방출 (빨간 채널만 보기) - DataModel 콘텐츠
local mapSize = 128
local quarterMapSize = mapSize / 4
local emissiveEditableImage = AssetService:CreateEditableImage({ Size = Vector2.new(mapSize, mapSize) })
-- 전체 배경의 방출 값을 0으로 설정하고, 반대쪽에 두 개의 원이 방출 값을 1로 가지도록 하여 원형 패턴을 만듭니다.
emissiveEditableImage:DrawRectangle(Vector2.zero, emissiveEditableImage.Size, Color3.new(0, 0, 0), 0, Enum.ImageCombineType.Overwrite)
emissiveEditableImage:DrawCircle(Vector2.new(quarterMapSize, quarterMapSize*3), quarterMapSize, Color3.new(1, 0, 0), 0, Enum.ImageCombineType.Overwrite)
emissiveEditableImage:DrawCircle(Vector2.new(quarterMapSize*3, quarterMapSize), quarterMapSize, Color3.new(1, 0, 0), 0, Enum.ImageCombineType.Overwrite)
local dmcResult, emissiveDataModelContent = AssetService:CreateDataModelContentAsync(Content.fromObject(emissiveEditableImage))
assert(dmcResult == Enum.CreateContentResult.Success)
-- 금속성 (빨간 채널만 보기) - 자산 ID 콘텐츠
local METALNESS_ASSET_ID = "rbxassetid://658743164"
local surfaceAppearance = AssetService:CreateSurfaceAppearanceAsync({
ColorMap = Content.fromObject(colorEditableImage),
EmissiveMask = emissiveDataModelContent,
MetalnessMap = Content.fromUri(METALNESS_ASSET_ID)
})
-- 맵과 EmissiveMask에 사용되는 콘텐츠를 제외한 대부분의 속성은 여전히 변경할 수 있습니다.
surfaceAppearance.EmissiveStrength = 20
local meshPart = AssetService:CreateMeshPartAsync(Content.fromAssetId(16799342206))
meshPart.Parent = Workspace
meshPart.Anchored = true
meshPart.Position = Vector3.new(0, 2, 0)
-- 메쉬 파트에 표면 외관 적용
surfaceAppearance.Parent = meshPartGet Asset Ids For Package
Get Asset Ids For Package Async
Get Audio Metadata Async
매개 변수
반환
코드 샘플
오디오 메타데이터 가져오기
local AssetService = game:GetService("AssetService")
local SoundService = game:GetService("SoundService")
local trackIDs = {
SoundService.Sound1.SoundId,
SoundService.Sound2.SoundId,
SoundService.Sound3.SoundId,
SoundService.Sound4.SoundId,
}
local success, result = pcall(function()
return AssetService:GetAudioMetadataAsync(trackIDs)
end)
if success then
for i = 1, #trackIDs do
local contentId = "rbxassetid://" .. result[i].AssetId
if trackIDs[i] == contentId then
print(result[i].Title, "에 의해", result[i].Artist)
else
warn("요청된 자산 #" .. tostring(i) .. "에 대한 메타데이터를 가져올 수 없습니다.")
end
end
endGet Bundle Details Async
매개 변수
코드 샘플
번들 세부정보 가져오기
local AssetService = game:GetService("AssetService")
local BUNDLE_ID = 14
local success, result = pcall(function()
return AssetService:GetBundleDetailsAsync(BUNDLE_ID)
end)
if success then
print(result)
--[[
{
["BundleType"] = "BodyParts",
["Description"] = "연도는 5003년, Battlebot 5000은 그의 가장 강력한 적과 맞서야 하거나 구식이 되는 것을 피해야 합니다.",
["Id"] = 14,
["Items"] = {
[1] = {...},
[2] = {
["Id"] = 1678225030,
["Name"] = "SinisterBot 5001 왼쪽 팔",
["Type"] = "Asset"
},
[3] = {...},
[4] = {...},
[5] = {...},
[6] = {...},
[7] = {...}
},
["Name"] = "SinisterBot 5001"
}
--]]
endGet Composed Decal Layers
매개 변수
반환
{ { [string]: Content | Vector2 } }
코드 샘플
구성된 데칼 복사
local AssetService = game:GetService("AssetService")
local Workspace = game:GetService("Workspace")
local sourceDecal = Workspace.Part.Decal
-- ComposeDecalAsync가 데칼에 저장한 레이어 스택을 읽습니다.
local layers = AssetService:GetComposedDecalLayers(sourceDecal)
if #layers == 0 then
print("이 데칼은 구성되지 않았습니다.")
return
end
for index, layer in layers do
print("레이어", index, "ColorMap:", layer.ColorMap)
end
-- 레이어는 ComposeDecalAsync가 수용하는 형식을 사용하므로 다시 전달할 수 있습니다.
local copy = Instance.new("Decal")
local success, errorMessage = pcall(function()
AssetService:ComposeDecalAsync(copy, layers)
end)
if success then
copy.Parent = sourceDecal.Parent
else
warn("데칼 구성 실패:", errorMessage)
endGet Creator Asset ID
Get Game Places Async
반환
코드 샘플
AssetService:GetGamePlacesAsync
local AssetService = game:GetService("AssetService")
local placePages = AssetService:GetGamePlacesAsync()
while true do
for _, place in placePages:GetCurrentPage() do
print("이름:", place.Name)
print("장소 ID:", place.PlaceId)
end
if placePages.IsFinished then
break
end
placePages:AdvanceToNextPageAsync()
endPrompt Create Platform Content Async
Asset Service: Prompt Create Platform Content Async(
매개 변수
반환
Prompt Import Animation Clip From Video Async
Save Place Async
Search Audio
Search Audio Async
매개 변수
코드 샘플
음악 검색 제목 가져오기
local AssetService = game:GetService("AssetService")
local audioSearchParams = Instance.new("AudioSearchParams")
audioSearchParams.SearchKeyword = "happy"
local success, result = pcall(function()
return AssetService:SearchAudioAsync(audioSearchParams)
end)
if success then
local currentPage = result:GetCurrentPage()
for _, audio in currentPage do
print(audio.Title)
end
else
warn("AssetService 오류: " .. result)
end
--[[ 반환된 데이터 형식
{
"AudioType": string,
"Artist": string,
"Title": string,
"Tags": {
"string"
},
"Id": number,
"IsEndorsed": boolean,
"Description": string,
"Duration": number,
"CreateTime": string,
"UpdateTime": string,
"Creator": {
"Id": number,
"Name": string,
"Type": number,
"IsVerifiedCreator": boolean
}
}
--]]