KeyframeSequenceProvider

แสดงที่เลิกใช้งานแล้ว

*เนื้อหานี้แปลโดยใช้ AI (เวอร์ชัน Beta) และอาจมีข้อผิดพลาด หากต้องการดูหน้านี้เป็นภาษาอังกฤษ ให้คลิกที่นี่

ไม่สามารถสร้าง
บริการ
ไม่ซ้ำ

บริการ KeyframeSequenceProvider ให้ฟังก์ชันในการโหลดและดูตัวอย่าง KeyframeSequencesมันรวมถึงฟังก์ชันหลายอย่างที่มีประโยชน์เมื่อทำงานกับ Animations

A KeyframeSequence เก็บชุดของ Poses ที่เข้ารหัสลำดับชั้นและการเคลื่อนไหวของแอนิเมชั่นข้อมูลแอนิเมชันที่ Roblox ใช้ในการเล่นแอนิเมชันที่อ้างอิงโดยคุณสมบัติ Animation.AnimationId สามารถสร้างได้จาก Class.KeyframeSequence``Class.KeyframeSequence|KeyframeSequences มักจะสร้างโดย Roblox เครื่องมือแก้ไขแอนิเมชั่น แต่สามารถสร้างผ่านปลั๊กอินอื่นหรือแม้แต่ด้วยตัวเองได้

ตัวอย่างโค้ด

This code sample contains a simple function to generate an Animation with a generated hash ID to preview a KeyframeSequence locally.

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(keyframeSequence : Instance):ContentId

    สร้างรหัสสินทรัพย์ชั่วคราวจาก KeyframeSequence ที่สามารถใช้สําหรับการทดสอบท้องถิ่นของแอนิเมชั่น สร้าง URL active://

  • RegisterKeyframeSequence(keyframeSequence : Instance):ContentId

    สร้างรหัสสินทรัพย์ชั่วคราวจาก KeyframeSequence ที่สามารถใช้สําหรับการทดสอบในท้องถิ่นของแอนิเมชั่น สร้างคําภีร์

  • ผลตอบแทน

    ฟังก์ชันนี้จะคืนวัตถุ InventoryPages ซึ่งสามารถใช้เพื่อเลื่อนผ่านแอนิเมชั่นที่เป็นเจ้าของโดยผู้ใช้รายเฉพาะได้

  • GetKeyframeSequenceAsync(assetId : ContentId):Instance
    ผลตอบแทน

    ส่งคืนเฟรมเวลาหลักตามรหัสสินทรัพย์ที่ระบุโดยไม่ซิงโครไลซ์อย่างเชิงเดียว

คุณสมบัติ

วิธีการ

RegisterActiveKeyframeSequence

ContentId

สร้างรหัสสินทรัพย์ชั่วคราวจาก KeyframeSequence ที่สามารถใช้สําหรับการทดสอบท้องถิ่นของแอนิเมชั่น

ฟังก์ชันนี้ทําหน้าที่เดียวกันกับ KeyframeSequenceProvider:RegisterKeyframeSequence() อย่างไรก็ตามฟังก์ชันนี้จะสร้าง URL active:// แทนที่จะเป็นฮาช

รหัสที่สร้างได้สามารถใช้ในคุณสมบัติ Animation.AnimationId สำหรับการทดสอบ

รหัสสินทรัพย์ที่สร้างโดยฟังก์ชันนี้เป็นชั่วคราวและไม่สามารถใช้ภายนอกสตูดิโอได้นักพัฒนาที่ต้องการสร้าง ID สินทรัพย์ที่สามารถใช้ออนไลน์ได้ควรอัปโหลด KeyframeSequence ไปยัง Roblox

พารามิเตอร์

keyframeSequence: Instance

The KeyframeSequence ที่จะใช้

ค่าเริ่มต้น: ""

ส่งค่ากลับ

ContentId

รหัสสินทรัพย์ชั่วคราวที่สร้างขึ้นสำหรับการเล่นแอนิเมชั่นในท้องถิ่น

ตัวอย่างโค้ด

This code sample contains a simple function to generate an Animation with a generated hash ID to preview a KeyframeSequence locally.

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

ContentId

สร้างรหัสสินทรัพย์ชั่วคราวจาก KeyframeSequence ที่สามารถใช้สําหรับการทดสอบท้องถิ่นของแอนิเมชั่น

ฟังก์ชันนี้ทําหน้าที่เดียวกันกับ KeyframeSequenceProvider:RegisterActiveKeyframeSequence() แต่ฟังก์ชันนี้สร้างคําอธิบายไม่ซ้ํากันแทนที่จะเป็น URL active://

รหัสที่สร้างได้สามารถใช้สําหรับคุณสมบัติ Animation.AnimationId เพื่อทดสอบแอนิเมชั่น

รหัสสินทรัพย์ที่สร้างโดยฟังก์ชันนี้เป็นชั่วคราวและไม่สามารถใช้ภายนอกสตูดิโอได้นักพัฒนาที่ต้องการสร้าง ID สินทรัพย์ที่สามารถใช้ออนไลน์ได้ควรอัปโหลด KeyframeSequence ไปยัง Roblox

พารามิเตอร์

keyframeSequence: Instance

The KeyframeSequence ที่จะใช้

ค่าเริ่มต้น: ""

ส่งค่ากลับ

ContentId

รหัสสินทรัพย์ชั่วคราวที่สร้างขึ้นสำหรับการเล่นแอนิเมชั่นในท้องถิ่น

ตัวอย่างโค้ด

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

ผลตอบแทน

ฟังก์ชันนี้จะคืนวัตถุ InventoryPages ซึ่งสามารถใช้เพื่อเลื่อนผ่านแอนิเมชั่นที่เป็นเจ้าของโดยผู้ใช้รายเฉพาะได้

ฟังก์ชันนี้มีจำนวนการใช้งานที่อาจเกิดขึ้น เช่น ปลั๊กอิน

พารามิเตอร์

userId: number

ID ผู้ใช้ของผู้ใช้

ค่าเริ่มต้น: ""

ส่งค่ากลับ

แอนิเมชั่น InventoryPages ของ

ตัวอย่างโค้ด

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.

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 ส่งคืน KeyframeSequence ขึ้นอยู่กับรหัสสินทรัพย์ที่ระบุassetId ต้องตรงกับแอนิเมชั่นฟังก์ชันจะให้ผลจนกว่า KeyframeSequence จะโหลดจากเว็บไซต์เนื่องจากนี่เป็นการโทรเว็บ จึงควรห่อหุ้มด้วย pcall

พารามิเตอร์

assetId: ContentId

ID เนื้อหาของแอนิเมชั่น

ค่าเริ่มต้น: ""

ส่งค่ากลับ

พบ KeyframeSequence ที่

ตัวอย่างโค้ด

Demonstrates getting an animation's KeyframeSequence using KeyframeSequenceProvider:GetKeyframeSequenceAsync() and printing the time of each keyframe.

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

อีเวนต์