Classe de moteur
ChangeHistoryService
*Ce contenu est traduit en utilisant l'IA (Beta) et peut contenir des erreurs. Pour consulter cette page en anglais, clique ici.
Résumé
Méthodes
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():() |
Événements
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 |
Référence API
Méthodes
FinishRecording
ChangeHistoryService:FinishRecording(
):()
Paramètres
Retours
()
Échantillons de code
ChangeHistoryService:EssayerDeCommencerLEnregistrement
local ChangeHistoryService = game:GetService("ChangeHistoryService")
local Selection = game:GetService("Selection")
local toolbar = plugin:CreateToolbar("Plugin Exemple")
local button = toolbar:CreateButton("Neoniser", "", "")
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
-- Rien à faire.
return
end
local recording = ChangeHistoryService:TryBeginRecording("Définir la sélection sur néon")
if not recording then
-- Gérer l'erreur ici. Cela indique que votre plugin a commencé un enregistrement précédent
-- et ne l'a jamais terminé. Vous ne pouvez avoir qu'un seul enregistrement
-- par plugin actif à la fois.
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():()
Retours
()
ResetWaypoints
ChangeHistoryService:ResetWaypoints():()
Retours
()
SetWaypoint
Paramètres
Retours
()
Échantillons de code
Service d'historique des modifications : Définir un point de repère
local ChangeHistoryService = game:GetService("ChangeHistoryService")
local Selection = game:GetService("Selection")
local toolbar = plugin:CreateToolbar("Exemple de Plugin")
local button = toolbar:CreateButton("Mettez-le en néon", "", "")
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
-- Appeler SetWaypoint avant le travail ne causera pas de problèmes, cependant
-- c'est redondant, seule l'appel APRÈS le travail est nécessaire.
--ChangeHistoryService:SetWaypoint("Définir la sélection en néon")
for _, part in pairs(parts) do
part.Material = Enum.Material.Neon
end
-- Appeler SetWaypoint APRÈS avoir terminé le travail
ChangeHistoryService:SetWaypoint("Définir la sélection en néon")
else
-- Rien à faire. Vous n'avez pas besoin d'appeler SetWaypoint dans le cas où
-- l'action n'a pas entraîné de modifications dans l'expérience.
end
end)TryBeginRecording
Retours
Échantillons de code
ChangeHistoryService:EssayerDeCommencerLEnregistrement
local ChangeHistoryService = game:GetService("ChangeHistoryService")
local Selection = game:GetService("Selection")
local toolbar = plugin:CreateToolbar("Plugin Exemple")
local button = toolbar:CreateButton("Neoniser", "", "")
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
-- Rien à faire.
return
end
local recording = ChangeHistoryService:TryBeginRecording("Définir la sélection sur néon")
if not recording then
-- Gérer l'erreur ici. Cela indique que votre plugin a commencé un enregistrement précédent
-- et ne l'a jamais terminé. Vous ne pouvez avoir qu'un seul enregistrement
-- par plugin actif à la fois.
return
end
for _, part in pairs(parts) do
part.Material = Enum.Material.Neon
end
ChangeHistoryService:FinishRecording(recording, Enum.FinishRecordingOperation.Commit)
end)Undo
ChangeHistoryService:Undo():()
Retours
()
Événements
OnRecordingFinished
ChangeHistoryService.OnRecordingFinished(
name:string, displayName:string?, identifier:string?, operation:Enum.FinishRecordingOperation, finalOptions:Dictionary?
Paramètres
OnRecordingStarted