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("ตัวอย่างปลั๊กอิน")
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("Neon it up", "", "")
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("Setting selection to neon")
for _, part in pairs(parts) do
part.Material = Enum.Material.Neon
end
-- เรียก SetWaypoint หลังจากทำงานเสร็จสิ้น
ChangeHistoryService:SetWaypoint("Set selection to neon")
else
-- ไม่มีอะไรต้องทำ คุณไม่ต้องเรียก SetWaypoint ในกรณีที่
-- การกระทำไม่ได้ทำการเปลี่ยนแปลงใดๆ ต่อประสบการณ์.
end
end)TryBeginRecording
ส่งค่ากลับ
ตัวอย่างโค้ด
ChangeHistoryService:TryBeginRecording
local ChangeHistoryService = game:GetService("ChangeHistoryService")
local Selection = game:GetService("Selection")
local toolbar = plugin:CreateToolbar("ตัวอย่างปลั๊กอิน")
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