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 attach editor script on object

Discussion in 'Editor & General Support' started by aliwebconsultant, Sep 11, 2023.

  1. aliwebconsultant

    aliwebconsultant

    Joined:
    Sep 8, 2021
    Posts:
    35
    I want to attach editor script of RecorderController on Object but it is not working as it says Editor scripts cannot be attached on object. I want to attach the editor script on Object and dont want to call any of its functions in build I have enough required conditions for it. I just want to access its functions in playmode in editor
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    3,899
    Make that script a MonoBehaviour and enclose editor-only code in #if UNITY_EDITOR .. #endif preprocessor conditions.
     
    Kurt-Dekker likes this.
  3. aliwebconsultant

    aliwebconsultant

    Joined:
    Sep 8, 2021
    Posts:
    35
    It was in metadata So I was not able to edit it.
     
  4. aliwebconsultant

    aliwebconsultant

    Joined:
    Sep 8, 2021
    Posts:
    35
    But the issue is now solved.