# How can I build a game in Unity with minimum/no use of the visual editor?

I'd like to write a game completely in C#. In my search for an engine, I found Unity3D, but all the tutorials and documentation are speaking about a visual editor and the Unity IDE in which you click and point around to create scenes and scripts.

I don't want to do that. I prefer full code coverage over designers abstracting things away from me. I'd like to only write pure C# code from scratch or if required the Unity scripts as an addition. I couldn't find any explanation or documentation about doing so; how can I build a game using Unity and making minimum (or no) use of the visual editor?

• Voting to close, this is a framework recommendation disguised as a question about Unity. Aug 10, 2014 at 18:14
• I'm not actually sure if I agree with that, though I wouldn't overturn a community close vote. However, I will note that this question is specifically asking about some capability of Unity: answers that don't address that may be removed. Let's not turn this into an off topic question if we don't have to, okay?
– user1430
Aug 10, 2014 at 18:37
• Most developers look for a visual editor at some point to design their levels, because visually positioning stuff is so much simpler than setting the position of every little doodad in code. Same goes for editing/designing GUI layouts. Having this stuff already built-in is a huge benefit IMHO. Aug 11, 2014 at 7:01
• I prefer writing my own level editor which provides only the stuff really neccessary for my game okay that basically means you don't want to be using a game engine, you want to be programming with a graphics library. However you already hit a technical snag when trying to do that, so... I sense a contradiction here. Aug 11, 2014 at 13:19
• @jhocking Then our defintion of game engine seems to be very different. A class library is a game engine if it abstracts typical game tasks like camera mathematics, a sound system and maybe even a bit of physics stuff, but a designer isn't a requirement and in my opinion shouldn't even be a must-use.
– Ray
Aug 11, 2014 at 14:27

I am a complete beginner in Unity, but this is how I do it at the moment, and it reduces the editor usage to minimum:

In editor, I only have three objects: An empty GameObject called "main", a camera, and a light. And this is only because so far I only work with a single camera and a single light, so it was faster this way. Later I will probably remove them, and only the "main" will remain.

In "Assets/MyScripts" I have a class "Main", which is added to the "main" GameObject as a behavior. Which means that when the program starts, the "Main" class in instantiated and its method is called. The "Main" class is like this:

using UnityEngine;

public class Main : MonoBehaviour
{

void Start ()
{
// initialize the game
}

void Update ()
{
// update physics
}

}


In the game I dynamically build the environment like this:

GameObject floor = GameObject.CreatePrimitive (PrimitiveType.Cube);
floor.renderer.material.color = RandomGreen ();


But this is because so far I am only making a prototype. Later I will want to replace the cubes with some nice things edited in Blender. Which will require making them in Blender, and importing them to Units as "prefabs". Then, I will similarly instantiate the "prefabs" from the C# code.

If you want to make an object react to events, such as collisions with other objects, you can instantiate the object and add them dynamically a behavior class, which is a C# class derived from MonoBehavior. For example, if you want to have a car, you make a car prefab, and write a "CarBehavior" class for its behavior in the game.

This way you can reduce the interaction with the editor to a minimum, although probably not completely to zero. Now it depends on whether this is an acceptable solution for you.

• I'd say this looks like a pretty clear and solid answer for just a Unity beginner :)
– Ray
Aug 11, 2014 at 14:31
• Thanks! I am an experienced programmer otherwise, but this is my first project in Unity and it is far from finished. I haven't used prefabs yet. There may be some complications I am currently not aware of, so I recommend taking my advice with a grain of salt. By the way, serialization in Unity feels a bit counter-intuitive to me. I will have to study it deeper, and it may influence some design decisions. Aug 13, 2014 at 9:43

When working with Unity you have to do some work within Unity's editor; that's simply how Unity works.

However the vast majority of what you'd be doing as a programmer doesn't happen within Unity's editor; the script files are external text files written in an external IDE, and as a programmer you only use Unity's editor for linking which scripts to run and then hitting Play to actually run the game. That's not unlike linking in classes in the project settings, and then hitting Run within your IDE.

Most other game development tools that have a central visual editor are also saddled with limited and inflexible scripting support, but Unity doesn't suffer that disadvantage. Although everything created for Unity ultimately goes through the visual editor, this core interface involves a lot of linking projects to custom code that runs in Unity's game engine. Experienced programmers, don't dismiss this development environment, mistaking it for some click together game creator with limited programming capability!

(also, it sounds like the book I'm currently writing would be a great resource for you, since it's targeted at experienced programmers)

• was in the middle of reading your book when i came across this answer Jun 9, 2017 at 23:14

I believe what you are looking for is the Futile Framework for Unity.

Basically, you can then do all your programming using scripts without having to "drag and drop" stuff or mess with the visual editor much. All you need is a single GameObject in your Scene which will be the container for your entire game. You then do everything procedurally as you would with a non-visual editor.

Disclaimer: While Futile is very code centric, it is inevitable that you will have to mess with the Unity editor in some fashion. But this is very much reduced with Futile.