KeyframeSequenceProvider
*Questo contenuto è tradotto usando AI (Beta) e potrebbe contenere errori. Per visualizzare questa pagina in inglese, clicca qui.
Il servizio KeyframeSequenceProvider fornisce funzioni per caricare e visualizzare KeyframeSequences .Include una serie di funzioni utili quando si lavora con Animations .
Un KeyframeSequence memorizza una serie di Poses che codifica la gerarchia e il movimento di un'animazioni.I dati di animazione che Roblox utilizza nel riproduzione di un'animazioni, referenziati dalla ProprietàAnimation.AnimationId, possono essere costruiti da un KeyframeSequence. di solito vengono creati dall'Editor di animazione Roblox ma possono essere creati tramite altri plugin o anche manualmente.
Campioni di codice
This code sample contains a simple function to generate an Animation with a generated hash ID to preview a KeyframeSequence locally.
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)
Sommario
Proprietà
Metodi
Genera un ID risorsa temporaneo da un KeyframeSequence che può essere utilizzato per test localizzati di un'animazioni. Genera un URL attivo://.
Genera un ID risorsa temporaneo da un KeyframeSequence che può essere utilizzato per test localizzati di un'animazioni. Genera un hash.
Questa funzione restituisce un oggetto InventoryPages che può essere utilizzato per iterare sulle animazioni di proprietà di un utente specifico.
Restituisce una sequenza di fotogrammi chiave in base all'ID specificato asincronamente.
Proprietà
Metodi
RegisterActiveKeyframeSequence
Genera un ID risorsa temporaneo da un KeyframeSequence che può essere utilizzato per test localizzati di un'animazioni.
Questa funzione esegue la stessa funzione a KeyframeSequenceProvider:RegisterKeyframeSequence() tuttavia questa funzione genera un URL attivo:// invece di un hash.
L'ID generato può essere utilizzato in una proprietà Animation.AnimationId per test.
L'ID risorsa generato da questa funzione è temporaneo e non può essere utilizzato al di fuori di Studio.Gli sviluppatori che desiderano generare un ID risorsa che può essere utilizzato online dovrebbero caricare il KeyframeSequence su Roblox.
Parametri
Il KeyframeSequence da utilizzare.
Restituzioni
Un ID risorsa temporaneo generato per la riproduzione animata localizzata.
Campioni di codice
This code sample contains a simple function to generate an Animation with a generated hash ID to preview a KeyframeSequence locally.
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
Genera un ID risorsa temporaneo da un KeyframeSequence che può essere utilizzato per test localizzati di un'animazioni.
Questa funzione esegue la stessa funzione a KeyframeSequenceProvider:RegisterActiveKeyframeSequence() tuttavia questa funzione genera un hash invece di un attivo:// URL.
L'ID generato può essere utilizzato per la proprietà Animation.AnimationId per testare le animazioni.
L'ID risorsa generato da questa funzione è temporaneo e non può essere utilizzato al di fuori di Studio.Gli sviluppatori che desiderano generare un ID risorsa che può essere utilizzato online dovrebbero caricare il KeyframeSequence su Roblox.
Parametri
Il KeyframeSequence da utilizzare.
Restituzioni
Un ID risorsa temporaneo generato per la riproduzione animata localizzata.
Campioni di codice
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
GetAnimations
Questa funzione restituisce un oggetto InventoryPages che può essere utilizzato per iterare sulle animazioni di proprietà di un utente specifico.
Questa funzione ha una serie di potenziali usi, come consentire agli utenti di navigare e importare animazioni in un plugin di animazione personalizzato.
Parametri
L'ID utente dell'utente.
Restituzioni
Un InventoryPages di animazioni.
Campioni di codice
This code sample includes a demonstration of how the content IDs of animations belonging to a player can be downloaded using KeyframeSequenceProvider:GetAnimations(). To run this code be sure to change the USER_ID variable to the ID of the user whose animations you want to download.
local KeyframeSequenceProvider = game:GetService("KeyframeSequenceProvider")
local USER_ID = 0 -- Insert your UserId here
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:GetAnimations(USER_ID)
local animationIds = extractPages(inventoryPages)
for _, id in pairs(animationIds) do
print(id)
end
print("total: ", #animationIds)
GetKeyframeSequenceAsync
GetKeyframeSequenceAsync restituisce un KeyframeSequence basato sull'ID risorsa specificato.L'assetId deve corrispondere a un'animazioni.La funzione renderà fino a quando il KeyframeSequence non verrà caricato dal sito web.Poiché questa è una chiamata web, dovrebbe essere avvolta in una pcall.
Parametri
L'ID del contenuto dell'animazioni.
Restituzioni
Il KeyframeSequence trovato.
Campioni di codice
Demonstrates getting an animation's KeyframeSequence using KeyframeSequenceProvider:GetKeyframeSequenceAsync() and printing the time of each keyframe.
local KeyframeSequenceProvider = game:GetService("KeyframeSequenceProvider")
local ANIMATION_ID = "rbxassetid://507771019"
-- Get the keyframe sequence for the asset
local keyframeSequence
local success, err = pcall(function()
keyframeSequence = KeyframeSequenceProvider:GetKeyframeSequenceAsync(ANIMATION_ID)
end)
if success then
-- Iterate over each keyframe and print its time value
local keyframeTable = keyframeSequence:GetKeyframes()
for key, value in keyframeTable do
print(`The time of keyframe number {key} is: {value.Time}`)
end
else
print(`Error getting KeyframeSequence: {err}`)
end