Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Communication with running Unity editor instance from shell script

Discussion in 'Testing & Automation' started by sergebat, Jul 20, 2020.

  1. sergebat

    sergebat

    Joined:
    Nov 22, 2015
    Posts:
    6
    I would like to invoke editor scripts in the running Unity Editor instance from the shell script running on the same dev machine (primarily Windows, but easy portability to OSX is preferred).

    Do I understand right that Unity CLI will not help me much with that https://docs.unity3d.com/Manual/CommandLineArguments.html ? I think it always opens fresh Unity Editor copy (and fails if I try to specify projectPath that is already open).

    Are there any assets/built-in functionality that can help me get this up and running quickly, or I have to go into something like named pipes or TCP sockets?

    Example scenarios:
    • Run the game, when I click F5/Attach Debugger in VS Code. Stop the game, when I detach the debugger.
    • "playscene sceneName" bat/sh file that will open the scene and Play it in the editor (without leaving my IDE).
    Thanks!
     
  2. salvolannister

    salvolannister

    Joined:
    Jan 3, 2019
    Posts:
    50
    Did u find a solution for that?
     
  3. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    @sergebat i have never heard of any existing solution that does this.
    The closest thing i know is the Rider IDE plugin - it includes a pre-compiled DLL (in later versions i think it was replaced with a unity package).

    This package is loaded in Unity and acts as a "server" that receives commands from the Rider IDE - when you run certain operations in Rider it communicates to the code running in the editor that allows it to query information or launch certain functionality.

    I believe the whole project is open source so you can peek to see how it is implemented here: https://github.com/JetBrains/resharper-unity