add debug buttons and logging for undo
parent
22bbb3ce6a
commit
ec72bd39bf
|
|
@ -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>();
|
||||
|
|
|
|||
|
|
@ -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": [
|
||||
|
|
|
|||
Loading…
Reference in New Issue