add debug buttons and logging for undo

main
Anton Franzluebbers 2023-08-17 13:39:01 -04:00
parent 22bbb3ce6a
commit ec72bd39bf
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[][]>();
public int maxUndoSteps = 50;
public bool debugLog;
/// <summary>
@ -32,6 +33,11 @@ namespace VelNet
objects[i].networkObject.TakeOwnership();
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);
if (debugLog) Debug.Log($"Saved undo state");
while (undoBuffer.Count > maxUndoSteps)
{
undoBuffer.RemoveAt(0);
if (debugLog) Debug.Log($"Reached maximum undo history");
}
}
public int UndoHistoryLength()
@ -81,6 +90,11 @@ namespace VelNet
t.SaveUndoState();
}
if (EditorApplication.isPlaying && GUILayout.Button("Undo now"))
{
t.Undo();
}
if (GUILayout.Button("Find all undoable components in children."))
{
SyncState[] components = t.GetComponentsInChildren<SyncState>();

View File

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