Classe motore
KeyframeSequenceProvider
*Questo contenuto è tradotto usando AI (Beta) e potrebbe contenere errori. Per visualizzare questa pagina in inglese, clicca qui.
Sommario
Metodi
GetAnimations(userId: User):Instance |
GetAnimationsAsync(userId: User):Instance |
GetKeyframeSequence(assetId: ContentId):Instance |
GetKeyframeSequenceAsync(assetId: ContentId):Instance |
GetKeyframeSequenceById(assetId: number,useCache: boolean):Instance |
RegisterActiveKeyframeSequence(keyframeSequence: Instance):ContentId |
RegisterKeyframeSequence(keyframeSequence: Instance):ContentId |
Campioni di codice
Crea un'animazione temporanea
local KeyframeSequenceProvider = game:GetService("KeyframeSequenceProvider")
local function createPreviewAnimation(keyframeSequence)
local hashId = KeyframeSequenceProvider:RegisterKeyframeSequence(keyframeSequence)
local Animation = Instance.new("Animation")
Animation.AnimationId = hashId
return Animation
end
local keyframeSequence = Instance.new("KeyframeSequence")
local animation = createPreviewAnimation(keyframeSequence)
print(animation)Riferimento API
Metodi
GetAnimations
GetAnimationsAsync
Parametri
Restituzioni
Campioni di codice
KeyframeSequenceProvider GetAnimationsAsync
local KeyframeSequenceProvider = game:GetService("KeyframeSequenceProvider")
local USER_ID = 0 -- Inserisci qui il tuo UserId
local function extractPages(pagesObject)
local array = {}
while true do
local thisPage = pagesObject:GetCurrentPage()
for _, v in pairs(thisPage) do
table.insert(array, v)
end
if pagesObject.IsFinished then
break
end
pagesObject:AdvanceToNextPageAsync()
end
return array
end
local inventoryPages = KeyframeSequenceProvider:GetAnimationsAsync(USER_ID)
local animationIds = extractPages(inventoryPages)
for _, id in pairs(animationIds) do
print(id)
end
print("totale: ", #animationIds)GetKeyframeSequence
GetKeyframeSequenceAsync
Parametri
assetId:ContentId |
Restituzioni
Campioni di codice
Ottenere il KeyframeSequence di un'animazione
local KeyframeSequenceProvider = game:GetService("KeyframeSequenceProvider")
local ANIMATION_ID = "rbxassetid://507771019"
-- Ottieni il keyframe sequence per l'asset
local keyframeSequence
local success, err = pcall(function()
keyframeSequence = KeyframeSequenceProvider:GetKeyframeSequenceAsync(ANIMATION_ID)
end)
if success then
-- Itera su ogni keyframe e stampa il suo valore temporale
local keyframeTable = keyframeSequence:GetKeyframes()
for key, value in keyframeTable do
print(`Il tempo del keyframe numero {key} è: {value.Time}`)
end
else
print(`Errore durante l\'ottenimento di KeyframeSequence: {err}`)
endGetKeyframeSequenceById
RegisterActiveKeyframeSequence
Parametri
Restituzioni
ContentId
Campioni di codice
Crea un'animazione temporanea
local KeyframeSequenceProvider = game:GetService("KeyframeSequenceProvider")
local function createPreviewAnimation(keyframeSequence)
local hashId = KeyframeSequenceProvider:RegisterKeyframeSequence(keyframeSequence)
local Animation = Instance.new("Animation")
Animation.AnimationId = hashId
return Animation
end
local keyframeSequence = Instance.new("KeyframeSequence")
local animation = createPreviewAnimation(keyframeSequence)
print(animation)RegisterKeyframeSequence
Parametri
Restituzioni
ContentId
Campioni di codice
KeyframeSequenceProvider:RegisterKeyframeSequence
local KeyframeSequenceProvider = game:GetService("KeyframeSequenceProvider")
local asset = KeyframeSequenceProvider:RegisterKeyframeSequence(workspace.KeyframeSequence)
local animation = Instance.new("Animation")
animation.Name = "TestAnimation"
animation.AnimationId = asset
animation.Parent = workspace