I have 2 computers, one with the Unity Editor installed, and one without. I would like to be able to run C# scripts on the computer without the editor installed through the command line.
Let’s say I have the following C# file in my project:
using UnityEngine;
class TestClass
{
static void Main(string[] args)
{
Vector3 vec = Vector3.zero;
Console.WriteLine("Hello, world!");
}
}
I would like to, from the command line, run this main-method. In this way I can keep developing game-logic which is independent from the Editor. How is this done with dotnet? Do I create a new .csproj-file? Can I do this through Visual Studio?
Instead you want to create a managed plugin for Unity that references the UnityEngine DLLs (if needed). Then you build and drop the DLL into the project (this step can and should be automated). You don’t need two computers for this either.
Just to make this clear what CodeSmile said: You can not use most things from the UnityEngine.dll outside of a Unity application. By Unity application I mean either a build of your game or the Unity editor itself. Pretty much all types in the UnityEngine.dll are wrapper types for the native C++ types. Even the Vector3 struct has methods that are implemented on the native C++ side of the engine. So you can not use the Vector3 type outside of Unity in a pure C# application. That’s not possible.
What the others have suggested is to create a (mono) build of your game, so you have an application that can run on any machine. Here you can simply re-compile and replace one of your own managed DLLs and run the build in order to test it. Though you can not use engine features without the engine and the engine is written in C++. The source code for the UnityEngine.dll is provided here (for reference only!). Many parts rely on “extern” native method implementation.