Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  2. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    Dismiss Notice

Edit script at runtime

Discussion in 'Getting Started' started by McFly85, Sep 19, 2019.

  1. McFly85

    McFly85

    Joined:
    Sep 17, 2018
    Posts:
    7
    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. Bill_Martini

    Bill_Martini

    Joined:
    Apr 19, 2016
    Posts:
    441
    You can't modify a script at runtime. Scripts are compiled, source code is not available. The whole project would need to be recompiled after an edit even if you had access to source.

    @JoeStrout has been working on a scriptable language that runs in Unity. Don't know much about it but maybe send him a PM to see if it will work for your needs.
     
    JoeStrout and McFly85 like this.
  3. McFly85

    McFly85

    Joined:
    Sep 17, 2018
    Posts:
    7
    Bummer. Thanks for the lead
     
  4. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    8,747
    Thanks for the shout-out, Bill. MiniScript is indeed designed for exactly this need. @McFly85 and I are chatting now by PM.
     
    McFly85 likes this.
  5. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    8,315
    To do so you will need to use an interpreted language. There are a handful readily available for this purpose, but C# isn't one of them as far as I know.
     
    McFly85 likes this.
  6. McFly85

    McFly85

    Joined:
    Sep 17, 2018
    Posts:
    7
    JoeStrout likes this.
unityunity