Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Question How to detect Recording? [SOLVED]

Discussion in 'Audio & Video' started by janbromberger, Jan 9, 2024.

  1. janbromberger


    Aug 7, 2023
    I am using Unity Recorder to record gameplay videos for marketing purposes.

    In those videos, I want to remove certain UI elements. Just in recording, not in normal gameplay.

    I've wasted long recordings forgetting to manually do this, so I want to automatically detect if Unity Recorder is recoding or not.

    I've tried polling for
    GameObject.Find("Unity - RecorderSessions")
    as I can see a game object with that name in the hirarchy during recordings, but somehow it doesn't ever trigger.

    I am starting the game by pressing "Start Recording".
    Recording mode: Manual
    Source: Game View

    How can we detect if Unity Recorder is recording?
    ByMedion likes this.
  2. Program-Gamer


    Nov 16, 2018
    Seconding this, I want to make a gameobject appear when recording that mimics the mouse cursor since the recorder hides it by default with no option to reveal it, but I'd like to automate the process of turning the object on and off depending on whether I'm in the process of recording a clip. Is there any way at all to poll the recording status?
  3. ByMedion


    May 10, 2018
    You can get instance of RecorderWindow and check recording status using IsRecording():
    Code (CSharp):
    1. var windows = Resources.FindObjectsOfTypeAll<RecorderWindow>();
    2. var recording = false;
    3. foreach (var window in windows)
    4. {
    5.     if (window.IsRecording())
    6.     {
    7.         recording = true;
    8.         break;
    9.     }
    10. }
    12. if (recording)
    13.     ...
    14. else
    15.     ...
    This can be combined with Update() or coroutine to check when recording starts/ends:
    Code (CSharp):
    1. private IEnumerator RecorderListenerCoroutine()
    2. {
    3.     var windows = Resources.FindObjectsOfTypeAll<RecorderWindow>();
    5.     while (true)
    6.     {
    7.         var recording = false;
    8.         foreach (var window in windows)
    9.         {
    10.             if (window.IsRecording())
    11.             {
    12.                 recording = true;
    13.                 break;
    14.             }
    15.         }
    17.         if (recording)
    18.             ...
    19.         else
    20.             ...
    22.         yield return null;
    23.     }
    24. }
    janbromberger likes this.
  4. janbromberger


    Aug 7, 2023
    Thank you @ByMedion that works.

    I've tested it in Awake, Start, and Update. For me, it detects recording in Awake, but not in Start, not in the first few Updates, and then again in Update after a few frames.