Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Input Recorder and OpenXR

Discussion in 'VR' started by wuenscher, Aug 12, 2021.

  1. wuenscher

    wuenscher

    Joined:
    Mar 17, 2020
    Posts:
    3
    I try to use the Input Recorder with openxr. The results are very inconsistent when the recordings will be played and when not. Is it in a buggy state or is there a (not documented) way how to use it properly?

    Thanks in advance!

    Edit: I tried it with quest 2 on oculus link and rift s in Unity 2020.3.14.
     
  2. wuenscher

    wuenscher

    Joined:
    Mar 17, 2020
    Posts:
    3
  3. thep3000

    thep3000

    Unity Technologies

    Joined:
    Aug 9, 2013
    Posts:
    398
    I haven't used InputRecorder with XR, but I have used InputEventTrace successfully which InputRecorder is based on.

    Recording example (to byte array):

    Code (CSharp):
    1. // declare locals
    2. private InputEventTrace inputEventTrace = new InputEventTrace();
    3.  
    4. // later... enable recording
    5. inputEventTrace.Enable()
    6.  
    7. // later... save to byte array
    8. MemoryStream ms = new MemoryStream();
    9. inputEventTrace.WriteTo(ms);
    10. var inputSystemBytes = ms.ToArray();
    11. inputEventTrace.Clear();

    Playback example (from byte array):

    Code (CSharp):
    1. // declare locals
    2. public InputEventTrace inputEventTrace = new InputEventTrace();
    3. public InputEventTrace.ReplayController replay = null;
    4.  
    5. // later... load from byte array and play back
    6. var ms = new MemoryStream(message.Value.Bytes, offset, msg.ByteCount);
    7. inputEventTrace.ReadFrom(ms);
    8.  
    9. if (replay == null)
    10. {
    11.     replay = inputEventTrace.Replay().WithAllDevicesMappedToNewInstances();
    12. }
    13.                    
    14. replay.Rewind();
    15. replay.PlayAllEvents();
    16.                    
    17. inputEventTrace.Clear();
     
  4. wuenscher

    wuenscher

    Joined:
    Mar 17, 2020
    Posts:
    3
    Hello thep3000, thank your for your response. Recording is working and replay during the same Playmode. But if i return to editor and go to playmode again. Then Replay is not working anymore. I save it to a file and load it... and it plays.. but controllers are standing still.

    The Sample is pretty much identical to your code but uses

    Code (CSharp):
    1.  
    2.             // Start replay.
    3.             if (m_SimulateOriginalTimingOnReplay)
    4.                 m_ReplayController.PlayAllEventsAccordingToTimestamps();
    5.             else
    6.                 m_ReplayController.PlayAllFramesOneByOne();
    7.  
    8.             m_ChangeEvent?.Invoke(Change.ReplayStarted);
    instead of PlayAllEvents

    but I guess it should work the same way, right?
     
    Last edited: Aug 26, 2021
  5. thep3000

    thep3000

    Unity Technologies

    Joined:
    Aug 9, 2013
    Posts:
    398
  6. Vailshnast

    Vailshnast

    Joined:
    Aug 1, 2022
    Posts:
    1
    @thep3000 Why did unity removed input recorder in new versions of input system?
     
  7. npatsiouras_ntua

    npatsiouras_ntua

    Joined:
    Feb 11, 2023
    Posts:
    12