Search Unity

How to edit script at runtime

Discussion in 'Getting Started' started by Resolutionxh, Aug 28, 2020.

  1. Resolutionxh

    Resolutionxh

    Joined:
    Aug 28, 2020
    Posts:
    1
    Is there a way to get the text of a script component so it can be accessed and edited in a UI input field at runtime?

    (I mean get the whole script in text form)
     
  2. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    No.

    If you need runtime scripting, then you'll probably want to use something like MiniScript, which was designed for exactly that.
     
    Joe-Censored likes this.
  3. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    In compiled languages like C# the original text of the scripts does not exist in your game's build. You need a language which is interpreted at runtime.
     
    JoeStrout likes this.