add debug buttons and logging for undo

upm
Anton Franzluebbers 2023-08-17 13:39:01 -04:00
parent 54932afdbb
commit 7d844f7b04
2 changed files with 15 additions and 1 deletions

View File

@ -17,6 +17,7 @@ namespace VelNet
private readonly List<byte[][]> undoBuffer = new List<byte[][]>(); private readonly List<byte[][]> undoBuffer = new List<byte[][]>();
public int maxUndoSteps = 50; public int maxUndoSteps = 50;
public bool debugLog;
/// <summary> /// <summary>
@ -32,6 +33,11 @@ namespace VelNet
objects[i].networkObject.TakeOwnership(); objects[i].networkObject.TakeOwnership();
objects[i].UnpackState(lastStates[i]); objects[i].UnpackState(lastStates[i]);
} }
if (debugLog) Debug.Log($"Undo {objects.Count} objects");
}
else
{
if (debugLog) Debug.Log($"No more undo to undo");
} }
} }
@ -45,10 +51,13 @@ namespace VelNet
undoBuffer.Add(states); undoBuffer.Add(states);
if (debugLog) Debug.Log($"Saved undo state");
while (undoBuffer.Count > maxUndoSteps) while (undoBuffer.Count > maxUndoSteps)
{ {
undoBuffer.RemoveAt(0); undoBuffer.RemoveAt(0);
if (debugLog) Debug.Log($"Reached maximum undo history");
} }
} }
public int UndoHistoryLength() public int UndoHistoryLength()
@ -81,6 +90,11 @@ namespace VelNet
t.SaveUndoState(); t.SaveUndoState();
} }
if (EditorApplication.isPlaying && GUILayout.Button("Undo now"))
{
t.Undo();
}
if (GUILayout.Button("Find all undoable components in children.")) if (GUILayout.Button("Find all undoable components in children."))
{ {
SyncState[] components = t.GetComponentsInChildren<SyncState>(); SyncState[] components = t.GetComponentsInChildren<SyncState>();

View File

@ -1,7 +1,7 @@
{ {
"name": "edu.uga.engr.vel.velnet", "name": "edu.uga.engr.vel.velnet",
"displayName": "VelNet", "displayName": "VelNet",
"version": "1.2.0", "version": "1.2.1",
"unity": "2019.1", "unity": "2019.1",
"description": "A custom networking library for Unity.", "description": "A custom networking library for Unity.",
"keywords": [ "keywords": [