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 How can I start and stop recording with script using unity recorder in editor not builds

Discussion in 'Audio & Video' started by aliwebconsultant, Sep 11, 2023.

  1. aliwebconsultant

    aliwebconsultant

    Joined:
    Sep 8, 2021
    Posts:
    35
    So I am using unity record to create animations But I want to start and stop recording from script I found that it is possible
    There is a class as RecorderController defined in UnityEditor.Recorder;

    Here is the recorder controller script and you can see It contains all req functions I need

    Code (CSharp):
    1. #region Assembly Unity.Recorder.Editor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
    2. // E:\Siriusnest\Pokey Card Game\Poker-Game\Library\ScriptAssemblies\Unity.Recorder.Editor.dll
    3. #endregion
    4.  
    5. namespace UnityEditor.Recorder
    6. {
    7.     public class RecorderController
    8.     {
    9.         public RecorderController(RecorderControllerSettings settings);
    10.  
    11.         public RecorderControllerSettings Settings { get; }
    12.  
    13.         public bool IsRecording();
    14.         public void PrepareRecording();
    15.         public bool StartRecording();
    16.         public void StopRecording();
    17.     }
    18. }
    But now the issue is that when I create an object of this class I cant set its referrence because I cant add this script on any object so I can set its referrence from there. Whenever I try to attach this script on Object It says You cant attach this script on Object as it is the editor script. But I dont want to use this script in builds I have conditions to prevent it before calling any of these functions.

    So now my issue is to attach this script on object and it is not working. If anyone knows the solution It will be very helpful
     
  2. rooose

    rooose

    Unity Technologies

    Joined:
    Jun 8, 2022
    Posts:
    30
    Hi aliwebconsultant,

    When you install the recorder, there is a sample called Movie Recorder Sample that shows how to record via a script using a RecorderController and a RecorderSettings. You can adapt it to use an AnimationRecorderSettings too. Since it is a MonoBehaviour, you'll also be able to attach it to an Object.

    Let me know if this helps!
     
  3. aliwebconsultant

    aliwebconsultant

    Joined:
    Sep 8, 2021
    Posts:
    35
    Thanks I already have solved it.
     
    rooose likes this.