I have a software project that calls my Unity game’s built executable from the command line with some command line arguments, and my game accesses them using Environment.GetCommandLineArgs().
Is there a way to have the in-editor preview run using command line arguments that are accessible the same way as that?
Otherwise, to test any changes I make, I have to Build the game so I can run the built executable with command line arguments.
Redesign your command line argument script so it takes arguments from 2 sources. First is you FindWithTag a GameObject, if not null then you GetComponent a script on that GameObject which provides command line arguments. If it is null, then you get command line arguments from GetCommandLineArgs as you’re doing now. The script on this GameObject really just has a public List with command line arguments you can add or remove from in the inspector, and in Start you set DontDestroyOnLoad. Then create a new scene and just add this one GameObject with this script and set your in editor command line args there. Set the scene to scene 0 in build settings, and open this scene before you launch the game in editor, but never include the scene in any actual builds. Just use it for in editor testing.