Search Unity

Is it possible to call a function in the running editor assembly from the command-line?

Discussion in 'Formats & External Tools' started by Xarbrough, Nov 30, 2020.

  1. Xarbrough

    Xarbrough

    Joined:
    Dec 11, 2014
    Posts:
    1,188
    It's possible to start the Unity editor from the command-line and pass the name of a static function to be executed. This is almost exclusively used to trigger an automated build process.

    Is it also possible to call such a function from outside of Unity while the editor is already running with its GUI open? Basically, I'd be interested in writing a .bat-file that, when double-clicked runs a function in the running editor instance. My command-line script would be its own process, so I doubt that it has the necessary rights to do so, even if it was possible, but just asking in case there is some hidden feature or workaround, I don't know about. I was almost thinking about placing some sort of marker file in the project, that when changed, would trigger a custom import, which could then call my function, however, I then realized, that some users (myself included), don't have auto-refresh enabled and so I couldn't ensure that it actually gets run.
     
  2. Siccity

    Siccity

    Joined:
    Dec 7, 2013
    Posts:
    255
    Having written a few programs I've only ever seen parameters getting passed at the start of a program. I don't know if Unity has anything like what you ask for, but an alternate solution could be having unity create and listen on some network socket?
     
    Xarbrough likes this.