ChangeHistoryService

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

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

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

ผู้พัฒนาปลั๊กอิน จะต้องใช้ Class.ChangeHistoryService เพื่อบอก Studio วิธีการยกเลิกและทำซ้ำการเปลี่ยนแปลงที่พวกเขาทำให้กับป

ปลั๊กอินอาจเรียกใช้งานได้โปรแกรมมิงผ่าน ChangeHistoryService:Undo() หรือ ChangeHistoryService:Redo() ด้วย

ChangeHistoryService ไม่สามารถใช้ได้ในขณะที่เริ่มต้นได้ ดังนั้นการเรียกวิธีการของมันในประสบการณ์ที่ดำเนินอยู่จะไม่มีผล

สรุป

วิธีการ

  • FinishRecording(identifier : string,operation : Enum.FinishRecordingOperation,finalOptions : Dictionary?):void
    การรักษาความปลอดภัยของปลั๊กอิน

    สื่อสารกับ Studio ว่าบันทึกที่ระบุไว้เสร็จสิ้นแล้วและจะทำการดำเนินการสุดท้ายเพื่อเสร็จสิ้นการบันทึก

  • การรักษาความปลอดภัยของปลั๊กอิน

    กลับว่ามีการทำซ้ำหรือไม่ และ, ถ้ามี, กลับสุดท้ายของพวกเขา

  • การรักษาความปลอดภัยของปลั๊กอิน

    กลับว่ามีการกระทำที่สามารถยกเลิกได้หรือไม่ และหากมีการกระทำใด ๆ ก็จะกลับคืนสุดท้าย

  • การรักษาความปลอดภัยของปลั๊กอิน
  • Redo():void
    การรักษาความปลอดภัยของปลั๊กอิน

    ดำเนินการที่สุดที่ยกเลิก

  • การรักษาความปลอดภัยของปลั๊กอิน

    ล้างประวัติ ทำให้ทุกจุดมุ่งหมายที่ทำซ้ำ/ทำใหม่ถูกลบออก

  • SetEnabled(state : bool):void
    การรักษาความปลอดภัยของปลั๊กอิน

    ตั้งค่าว่า ChangeHistoryService จะเปิดใช้งานหรือไม่

  • SetWaypoint(name : string):void
    การรักษาความปลอดภัยของปลั๊กอิน

    ตั้งค่าจุดใหม่ที่สามารถใช้เป็นจุดย้อนกลับหรือทำซ้ำ

  • TryBeginRecording(name : string,displayName : string?):string?
    การรักษาความปลอดภัยของปลั๊กอิน

    เริ่มติดตามการเปลี่ยนแปลงของข้อมูลไปยังบันทึก

  • Undo():void
    การรักษาความปลอดภัยของปลั๊กอิน

    ยกเลิกการกระทําล่าสุดที่มีวิธีชี้นำ

อีเวนต์

  • OnRecordingFinished(name : string,displayName : string?,identifier : string?,operationn : Enum.FinishRecordingOperation,finalOptions : Dictionary?):RBXScriptSignal
    การรักษาความปลอดภัยของปลั๊กอิน

    แอ็คชันตัวแปรมาจาก TryBeginRecording() และ FinishRecording()

  • การรักษาความปลอดภัยของปลั๊กอิน

    เริ่มต้นด้วยการใช้งานเมื่อผู้ใช้เริ่มการดำเนินการ ตัวแปรมาจาก TryBeginRecording()

  • การรักษาความปลอดภัยของปลั๊กอิน

    ไฟร์เมื่อผู้ใช้ยกเลิกคำสั่งยกเลิก วิธีการจุดเริ่มต้นอธิบายประเภทของการดำเนินการที่ได้รับการทำซ้ำ

  • การรักษาความปลอดภัยของปลั๊กอิน

    ไฟร์เมื่อผู้ใช้ทำการกลับทำการในสตูดิโอ วิธีการจุดไฟร์อธิบายประเภทการกลับทำที่เกิดขึ้น

คุณสมบัติ

วิธีการ

FinishRecording

void
การรักษาความปลอดภัยของปลั๊กอิน

พารามิเตอร์

identifier: string

ระบุการบันทึกจากการโทรก่อนหน้านี้ไปยัง TryBeginRecording() หากการดำเนินการนี้เป็น Enum.ChangeHistoryService.FinishRecordingOperation.Cancel จะไม่มีการบันทึกนี้ และการบันทึกจะได้รับการกำหนดโด

ระบุการดำเนินการที่จะใช้

finalOptions: Dictionary

ตารางของค่าที่เป็นตัวแปรสำหรับการส่งไปยัง OnFinishRecording


ส่งค่ากลับ

void

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

To commit an undo/redo record, you need to first call TryBeginRecording() followed by calling FinishRecording().

ChangeHistoryService:TryBeginRecording

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 < 1 then
-- Nothing to do.
return
end
local recording = ChangeHistoryService:TryBeginRecording("Set selection to neon")
if not recording then
-- Handle error here. This indidcates that your plugin began a previous
-- recording and never completed it. You may only have one recording
-- per plugin active at a time.
return
end
for _, part in pairs(parts) do
part.Material = Enum.Material.Neon
end
ChangeHistoryService:FinishRecording(recording, Enum.FinishRecordingOperation.Commit)
end)

GetCanRedo

การรักษาความปลอดภัยของปลั๊กอิน

กลับว่ามีการทำซ้ำหรือไม่ และ, ถ้ามี, กลับสุดท้ายของพวกเขา


ส่งค่ากลับ

GetCanUndo

การรักษาความปลอดภัยของปลั๊กอิน

กลับว่ามีการกระทำที่สามารถยกเลิกได้หรือไม่ และหากมีการกระทำใด ๆ ก็จะกลับคืนสุดท้าย


ส่งค่ากลับ

IsRecordingInProgress

การรักษาความปลอดภัยของปลั๊กอิน

พารามิเตอร์

identifier: string

ส่งค่ากลับ

Redo

void
การรักษาความปลอดภัยของปลั๊กอิน

ดำเนินการที่สุดที่ยกเลิก


ส่งค่ากลับ

void

ResetWaypoints

void
การรักษาความปลอดภัยของปลั๊กอิน

ล้างประวัติ ทำให้ทุกจุดมุ่งหมายที่ทำซ้ำ/ทำใหม่ถูกลบออก


ส่งค่ากลับ

void

SetEnabled

void
การรักษาความปลอดภัยของปลั๊กอิน

ตั้งค่าว่า ChangeHistoryService เปิดหรือไม่ เมื่อตั้งค่าเป็น false จะล้างรายการยกเลิก/ทำซ้ำ และไม่สร้างใหม่ เมื่อตั้งค่าเป็น true อีกครั้ง รายการดั้งเดิมจะไม่ถูกคืน แต่การดำเนินการต่อไปจะแนบมาที่รายการอี

พารามิเตอร์

state: bool

ส่งค่ากลับ

void

SetWaypoint

void
การรักษาความปลอดภัยของปลั๊กอิน

วิธีนี้จะถูก แก้ไขในเร็ว ๆ นี้ ในความโปรดปรานของ TryBeginRecording()

ChangeHistoryService ติดตามประวัติของปลั๊กอินในฐานะสตรีมการเปลี่ยนแปลงสมบัติที่เป็นไปได้ SetWaypoint() สร้างการตัดในสตรีมการเปลี่ยนแปลงเหล่านั้นเพื่อให้ und

ตามปกติ, การกระทําที่เรียกโดยผู้ใช้ใน Studio จะต้อง โทร SetWaypoint() หลังจากที่พวกเขาเสร็จสิ้นการเปลี่ย

พารามิเตอร์

name: string

ส่งค่ากลับ

void

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

In order for the waypoints to work correctly, you need to set one both before AND after you perform the action that should be able to be undone.

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
-- Calling SetWaypoint before the work will not cause any issues, however
-- it is redundant, only the call AFTER the work is needed.
--ChangeHistoryService:SetWaypoint("Setting selection to neon")
for _, part in pairs(parts) do
part.Material = Enum.Material.Neon
end
-- Call SetWaypoint AFTER completing the work
ChangeHistoryService:SetWaypoint("Set selection to neon")
else
-- Nothing to do. You do not need to call SetWaypoint in the case where
-- the action did not end up making any changes to the experience.
end
end)

TryBeginRecording

การรักษาความปลอดภัยของปลั๊กอิน

วิธีนี้เริ่มบันทึกเพื่อติดตามการเปลี่ยนแปลงในแบบข้อมูล คุณต้อง ต้อง เรียกมันก่อนที่จะทำการเปลี่ยนแปลงเพื่อหลีกเลี่ยงคำเตือนหรือข้อผิดพลาดในอนาคต

เมื่อการบันทึกเสร็จสิ้นคุณจะโทร FinishRecording() ด้วยตัวระบุการบันทึกที่กลับมาเพื่อเสร็จสิ้นการบันทึกและปรับปรุงการยกเลิก/ทำซ้ำสต็อก

วิธีนี้จะกลับมา nil หากไม่สามารถเริ่มบันทึกได้ บันทึกจะล้มเหลวหากปลั๊กอินมีการบันทึกอยู่แล้วหรือหากผู้ใช้อยู่ในโหมด วิ่ง หรือ เล่น คุณสามารถใช้ IsRecordingInProgress() เพื่อตรวจสอบสถานะการบันทึกของปลั๊กอิน

พารามิเตอร์

name: string

ชื่อการดำเนินการที่เหมาะสมสำหรับการบันทึกและการเขียนโค้ด

displayName: string

ชื่อของการกระทําที่จะแสดงให้กับผู้ใช้


ส่งค่ากลับ

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

To commit an undo/redo record, you need to first call TryBeginRecording() followed by calling FinishRecording().

ChangeHistoryService:TryBeginRecording

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 < 1 then
-- Nothing to do.
return
end
local recording = ChangeHistoryService:TryBeginRecording("Set selection to neon")
if not recording then
-- Handle error here. This indidcates that your plugin began a previous
-- recording and never completed it. You may only have one recording
-- per plugin active at a time.
return
end
for _, part in pairs(parts) do
part.Material = Enum.Material.Neon
end
ChangeHistoryService:FinishRecording(recording, Enum.FinishRecordingOperation.Commit)
end)

Undo

void
การรักษาความปลอดภัยของปลั๊กอิน

ยกเลิกการกระทําล่าสุดที่มีวิธีชี้นำ


ส่งค่ากลับ

void

อีเวนต์

OnRecordingFinished

การรักษาความปลอดภัยของปลั๊กอิน

พารามิเตอร์

name: string

ชื่อการดำเนินการที่เหมาะสมสำหรับการบันทึกและการเขียนโค้ด

displayName: string

ชื่อของการกระทําที่จะแสดงให้กับผู้ใช้

identifier: string

รหัสประจำตัวสำหรับการบันทึก

finalOptions: Dictionary

ตารางที่เปิดใช้งานได้จาก FinishOperation()


OnRecordingStarted

การรักษาความปลอดภัยของปลั๊กอิน

พารามิเตอร์

name: string

ชื่อการดำเนินการที่เหมาะสมสำหรับการบันทึกและการเขียนโค้ด

displayName: string

ชื่อของการกระทําที่จะแสดงให้กับผู้ใช้


OnRedo

การรักษาความปลอดภัยของปลั๊กอิน

ไฟร์เมื่อผู้ใช้ยกเลิกคำสั่งยกเลิก วิธีการจุดเริ่มต้นอธิบายประเภทของการดำเนินการที่ได้รับการทำซ้ำ

พารามิเตอร์

waypoint: string

OnUndo

การรักษาความปลอดภัยของปลั๊กอิน

ไฟร์เมื่อผู้ใช้ทำการกลับทำการในสตูดิโอ วิธีการจุดไฟร์อธิบายประเภทการกลับทำที่เกิดขึ้น

พารามิเตอร์

waypoint: string