# 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. – BlueRaja - Danny Pflughoeft Aug 10 '14 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? – Josh Aug 10 '14 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. – bummzack Aug 11 '14 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. – jhocking Aug 11 '14 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 '14 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 '14 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. – Viliam Búr Aug 13 '14 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 – max pleaner Jun 9 '17 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.

I would like to add to all the good answers here, especially @jhocking 's answer:

Almost everything I have found in Unity has a plain text counterpart in the projects folder tree. I have directly edited prefabs and other gameObjects without opening Unity, and those changes were successfully found by other devs upon commit.

While I didnt know as much about the Futile Framework until today, it looks to be a really awesome way to get at everything.

I currently use all the drag-and-drop stuff instead of going script-based, but that will have to change since my goal will have procedurally generated levels and bad guys.

My two cents says basically get the few objects you need in Unity, then rely on scripts in an external editor. You can do nearly everything in plain text.
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.19524863362312317, "perplexity": 1289.9297750545468}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.3, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2019-47/segments/1573496670448.67/warc/CC-MAIN-20191120033221-20191120061221-00558.warc.gz"}