void TraceEvents() { if (Trace == null) { if (ShouldTrace) { Debug.Log("Enabling Trace..."); EnableTrace(); } else { Debug.LogError($"Can't trace input; Trace is null! (ShouldTrace = {ShouldTrace}, isServer = {isServer})"); } } if (Trace != null) { //go through new events since last update InputEventPtr curEvent = new InputEventPtr(); while (Trace.GetNextEvent(ref curEvent)) { //turn into bytes now instead of later? TraceQueue.Enqueue(curEvent); if (DebugPrint) { Debug.Log($"Traced event {curEvent.ToEvent()}"); } } Trace.Clear(); ProcessEventsBytes(TraceQueue); } }
public void Events_CanClearEventTrace() { using (var trace = new InputEventTrace()) { trace.Enable(); var device = InputSystem.AddDevice <Gamepad>(); InputSystem.QueueStateEvent(device, new GamepadState()); InputSystem.QueueStateEvent(device, new GamepadState()); InputSystem.Update(); Assert.That(trace.ToList(), Has.Count.EqualTo(2)); trace.Clear(); Assert.That(trace.ToList(), Has.Count.EqualTo(0)); } }
private void Quit() { if (!_initialized) { return; } // Flush recorded data to file if (_traceMode == TraceManagerMode.RECORD) { Debug.Log("Replay: Saving Input to file '" + _savedInputFilename + "'"); // Create save folder if it does not exist if (!Directory.Exists(_savePath)) { Directory.CreateDirectory(_savePath); } _trace.WriteTo(_savePath + _savedInputFilename); if (!Directory.Exists(_seedPath)) { Directory.CreateDirectory(_seedPath); } File.WriteAllText(_seedPath + _savedInputFilename + "Seed", _initialSeed.ToString()); } else if (_traceMode == TraceManagerMode.REPRODUCE) { foreach (InputDevice device in InputSystem.devices) { InputSystem.EnableDevice(device); } _trace.Clear(); _trace = null; } _initialized = false; return; }