KeyframeSequenceProvider

사용되지 않는 항목 표시
만들 수 없음
서비스
복제되지 않음

The KeyframeSequenceProvider service provides functions to load and preview KeyframeSequences. It includes a number of functions that are useful when working with Animations.

What is a KeyframeSequence?

A KeyframeSequence stores a series of Poses that encode the hierarchy and motion of an animation. The animation data Roblox uses in the playback of an animation, referenced by the Animation.AnimationId property, can be constructed from a KeyframeSequence. KeyframeSequences are usually created by the Roblox Animation Editor but can be created through other plugins or even manually.

For more information, see the KeyframeSequence page.

What does the KeyframeSequenceProvider do?

The KeyframeSequenceProvider has a number of uses.

  • Download the KeyframeSequence associated with an animation content ID from the Roblox website
  • Generate a temporary id to locally preview an animation
  • Fetch the content IDs of animations owned by a particular user.

코드 샘플

Create temporary animation

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)

요약

메서드

속성

메서드

RegisterActiveKeyframeSequence

Generates a temporary asset ID from a KeyframeSequence that can be used for localized testing of an animation.

This function performs the same function to KeyframeSequenceProvider:RegisterKeyframeSequence() however this function generates an active:// URL instead of a hash.

The ID generated can be used in an Animation.AnimationId property for testing.

The asset ID generated by this function is temporary and cannot be used outside of Studio. Developers wishing to generate an asset ID that can be used online should upload the KeyframeSequence to Roblox.

매개 변수

keyframeSequence: Instance

The KeyframeSequence to be used.


반환

A temporary asset ID generated for localized animation playback.

코드 샘플

Create temporary animation

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

Generates a temporary asset ID from a KeyframeSequence that can be used for localized testing of an animation.

This function performs the same function to KeyframeSequenceProvider:RegisterActiveKeyframeSequence() however this function generates a hash instead of an active:// URL.

The ID generated can be used for the Animation.AnimationId property to test animations.

The asset ID generated by this function is temporary and cannot be used outside of Studio. Developers wishing to generate an asset ID that can be used online should upload the KeyframeSequence to Roblox.

매개 변수

keyframeSequence: Instance

The KeyframeSequence to be used.


반환

A temporary asset ID generated for localized animation playback.

코드 샘플

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

GetAnimations

생성

This function returns an InventoryPages object which can be used to iterate over animations owned by a specific user.

This function has a number of potential uses, such as allowing users to browse and import animations into a custom animation plugin.

매개 변수

userId: number

The user ID of the user.


반환

An InventoryPages of animations.

코드 샘플

KeyframeSequenceProvider GetAnimations

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 returns a KeyframeSequence based on the specified assetId. The assetId must correspond to an animation. The function will yield until the KeyframeSequence is loaded from the website. Because this is a webcall it should wrapped in a pcall.

매개 변수

assetId: Content

The content ID of the animation.


반환

코드 샘플

Getting an animation's KeyframeSequence

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

이벤트