From ec72bd39bf6d670f45dfd62b6df815434838b1df Mon Sep 17 00:00:00 2001 From: Anton Franzluebbers Date: Thu, 17 Aug 2023 13:39:01 -0400 Subject: [PATCH] add debug buttons and logging for undo --- .../Packages/VelNetUnity/Runtime/Util/UndoGroup.cs | 14 ++++++++++++++ .../Packages/VelNetUnity/package.json | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/TestVelGameServer/Packages/VelNetUnity/Runtime/Util/UndoGroup.cs b/TestVelGameServer/Packages/VelNetUnity/Runtime/Util/UndoGroup.cs index a59d0ba..c57a12b 100644 --- a/TestVelGameServer/Packages/VelNetUnity/Runtime/Util/UndoGroup.cs +++ b/TestVelGameServer/Packages/VelNetUnity/Runtime/Util/UndoGroup.cs @@ -17,6 +17,7 @@ namespace VelNet private readonly List undoBuffer = new List(); public int maxUndoSteps = 50; + public bool debugLog; /// @@ -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(); diff --git a/TestVelGameServer/Packages/VelNetUnity/package.json b/TestVelGameServer/Packages/VelNetUnity/package.json index 4923be5..be1ae93 100644 --- a/TestVelGameServer/Packages/VelNetUnity/package.json +++ b/TestVelGameServer/Packages/VelNetUnity/package.json @@ -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": [