Engine Class
ChangeHistoryService
*เนื้อหานี้แปลโดยใช้ AI (เวอร์ชัน Beta) และอาจมีข้อผิดพลาด หากต้องการดูหน้านี้เป็นภาษาอังกฤษ ให้คลิกที่นี่
สรุป
วิธีการ
FinishRecording(identifier: string,operation: Enum.FinishRecordingOperation,finalOptions: Dictionary?):() |
IsRecordingInProgress(identifier: string?):boolean |
Redo():() |
ResetWaypoints():() |
SetEnabled(state: boolean):() |
SetWaypoint(name: string):() |
TryBeginRecording(name: string,displayName: string?):string? |
Undo():() |
เหตุการณ์
OnRecordingFinished(name: string,displayName: string?,identifier: string?,operation: Enum.FinishRecordingOperation,finalOptions: Dictionary?):RBXScriptSignal |
OnRecordingStarted(name: string,displayName: string?):RBXScriptSignal |
OnRedo(waypoint: string):RBXScriptSignal |
OnUndo(waypoint: string):RBXScriptSignal |
เอกสารอ้างอิงเกี่ยวกับ API
วิธีการ
FinishRecording
ChangeHistoryService:FinishRecording(
):()
พารามิเตอร์
ส่งค่ากลับ
()
ตัวอย่างโค้ด
ChangeHistoryService:TryBeginRecording
local ChangeHistoryService = game:GetService("ChangeHistoryService")
local Selection = game:GetService("Selection")
local toolbar = plugin:CreateToolbar("Example Plugin")
local button = toolbar:CreateButton("ทำให้เป็นนีออน", "", "")
button.Click:Connect(function()
local parts = {}
for _, part in pairs(Selection:Get()) do
if part:IsA("BasePart") then
parts[#parts + 1] = part
end
end
if #parts < 1 then
-- ไม่มีอะไรให้ทำ.
return
end
local recording = ChangeHistoryService:TryBeginRecording("ตั้งค่าการเลือกเป็นนีออน")
if not recording then
-- จัดการข้อผิดพลาดที่นี่ นี่แสดงว่าปลั๊กอินของคุณเริ่มบันทึกก่อนหน้านี้
-- และไม่เคยเสร็จสิ้น คุณสามารถมีการบันทึกได้เพียงหนึ่งรายการ
-- ต่อปลั๊กอินที่เปิดใช้งานในเวลาเดียวกัน.
return
end
for _, part in pairs(parts) do
part.Material = Enum.Material.Neon
end
ChangeHistoryService:FinishRecording(recording, Enum.FinishRecordingOperation.Commit)
end)IsRecordingInProgress
Redo
ChangeHistoryService:Redo():()
ส่งค่ากลับ
()
ResetWaypoints
ChangeHistoryService:ResetWaypoints():()
ส่งค่ากลับ
()
SetWaypoint
พารามิเตอร์
ส่งค่ากลับ
()
ตัวอย่างโค้ด
ChangeHistoryService:SetWaypoint
local ChangeHistoryService = game:GetService("ChangeHistoryService")
local Selection = game:GetService("Selection")
local toolbar = plugin:CreateToolbar("Example Plugin")
local button = toolbar:CreateButton("ทำให้เป็นนีออน", "", "")
button.Click:Connect(function()
local parts = {}
for _, part in pairs(Selection:Get()) do
if part:IsA("BasePart") then
parts[#parts + 1] = part
end
end
if #parts > 0 then
-- การเรียก SetWaypoint ก่อนทำงานจะไม่ทำให้เกิดปัญหาใด ๆ แต่
-- มันเป็นการทำซ้ำเท่านั้น การเรียกหลังจากทำงานเป็นสิ่งที่จำเป็น
--ChangeHistoryService:SetWaypoint("กำลังตั้งค่าการเลือกเป็นนีออน")
for _, part in pairs(parts) do
part.Material = Enum.Material.Neon
end
-- เรียก SetWaypoint หลังจากเสร็จสิ้นการทำงาน
ChangeHistoryService:SetWaypoint("ตั้งค่าการเลือกเป็นนีออน")
else
-- ไม่มีอะไรให้ทำ คุณไม่จำเป็นต้องเรียก SetWaypoint ในกรณีที่
-- การกระทำไม่ได้ทำการเปลี่ยนแปลงใด ๆ ต่อประสบการณ์
end
end)TryBeginRecording
ส่งค่ากลับ
ตัวอย่างโค้ด
ChangeHistoryService:TryBeginRecording
local ChangeHistoryService = game:GetService("ChangeHistoryService")
local Selection = game:GetService("Selection")
local toolbar = plugin:CreateToolbar("Example Plugin")
local button = toolbar:CreateButton("ทำให้เป็นนีออน", "", "")
button.Click:Connect(function()
local parts = {}
for _, part in pairs(Selection:Get()) do
if part:IsA("BasePart") then
parts[#parts + 1] = part
end
end
if #parts < 1 then
-- ไม่มีอะไรให้ทำ.
return
end
local recording = ChangeHistoryService:TryBeginRecording("ตั้งค่าการเลือกเป็นนีออน")
if not recording then
-- จัดการข้อผิดพลาดที่นี่ นี่แสดงว่าปลั๊กอินของคุณเริ่มบันทึกก่อนหน้านี้
-- และไม่เคยเสร็จสิ้น คุณสามารถมีการบันทึกได้เพียงหนึ่งรายการ
-- ต่อปลั๊กอินที่เปิดใช้งานในเวลาเดียวกัน.
return
end
for _, part in pairs(parts) do
part.Material = Enum.Material.Neon
end
ChangeHistoryService:FinishRecording(recording, Enum.FinishRecordingOperation.Commit)
end)Undo
ChangeHistoryService:Undo():()
ส่งค่ากลับ
()
เหตุการณ์
OnRecordingFinished
ChangeHistoryService.OnRecordingFinished(
name:string, displayName:string?, identifier:string?, operation:Enum.FinishRecordingOperation, finalOptions:Dictionary?
พารามิเตอร์
OnRecordingStarted