private void StartMirror() { if (record == null) { return; } mirror.GetComponent <SimpleMovement>().enabled = true; player.GetComponent <SimpleMovement>().enabled = false; //foreach (UnityEngine.InputSystem.InputDevice device in InputSystem.devices) // InputSystem.DisableDevice(device); //InputSystem.DisableDevice(keyboard); mirror.transform.position = initial.transform.position + offset; mirror.transform.rotation = initial.transform.rotation; replay = record.Replay(); //replay.WithAllDevicesMappedToNewInstances(); replay.PlayAllEventsAccordingToTimestamps(); replay.paused = false; state = recordState.playing; }
private void Init() { if (_initialized) { return; } // Init the replay system switch (_traceMode) { // Do nothing case TraceManagerMode.NONE: _recordingIndicator.SetActive(false); _replayingIndicator.SetActive(false); break; // Saves input to file case TraceManagerMode.RECORD: // Filename based on date string dateFMT = System.DateTime.Now.ToString("u"); //preferred format for file ordering _savedInputFilename = "IT_" + dateFMT.Replace(" ", "_").Replace("-", "").Replace(":", "").Replace("Z", ""); //improved filename Debug.Log("Replay: Input will be saved to file '" + _savedInputFilename + "'"); _initialSeed = Random.seed; _trace = new InputEventTrace(); _trace.Enable(); _recordingIndicator.SetActive(true); _initialized = true; break; // Replays input from saved file case TraceManagerMode.REPRODUCE: /// todo: aqui hay que asignar el savedinputfilename Debug.Log("Replay: Loading Input Trace from file '" + _savedInputFilename + "'"); if (File.Exists(_savePath + _savedInputFilename)) { _trace = InputEventTrace.LoadFrom(_savePath + _savedInputFilename); } else { Debug.LogError("Replay ERROR: File '" + _savedInputFilename + "' doesn't exist. Trace reproduction Cancelled."); return; } if (File.Exists(_seedPath + _savedInputFilename + "Seed")) { string randomSeed = File.ReadAllText(_seedPath + _savedInputFilename + "Seed"); int seedValue = 0; if (int.TryParse(randomSeed, System.Globalization.NumberStyles.AllowLeadingSign, System.Globalization.NumberFormatInfo.InvariantInfo, out seedValue)) { Random.seed = seedValue; } else { Debug.LogWarning("Replay Warning: Seed file with incorrect format. Trace reproduction may not work as intented."); } } else { Debug.LogWarning("Replay Warning: Missing seed file. Trace reproduction may not work as intented."); } foreach (InputDevice device in InputSystem.devices) { InputSystem.DisableDevice(device); } _replayController = _trace.Replay(); _replayController.WithAllDevicesMappedToNewInstances(); _replayController.PlayAllEventsAccordingToTimestamps(); _replayingIndicator.SetActive(true); _initialized = true; break; } }