Search Unity

This Friday we published the Unity engine and editor C# source code on GitHub, under a reference-only license.

Wait… what?

It’s always been possible to disassemble the Unity .NET assemblies, and our terms of service explicitly permits doing so, for the purpose of understanding or improving your projects made with Unity. But there are two obvious disadvantages to disassembling: 1) while not hard to do, it’s still rather inconvenient, and 2) the disassembled output doesn’t give you the original comments and variable names, frustrating attempts to understand the code.

To address the convenience issue, a number of community members went out of their way and provided GitHub repositories with the disassembled code. Truth be told, we had mixed feelings about this. On one hand, we were happy to see our users organize a useful service to the wider Unity community, but on the other, their actions were, strictly speaking, not legal (while our terms permit disassembly, they do not permit redistribution, because that’s a legal can of worms).

There was only one good solution that’d address both issues: namely for us to publish the original source code ourselves.

What this is not

In the interest of forestalling misunderstandings and clickbait, it’s worth taking a moment to emphasize what we’re not doing.

We are not releasing Unity as open source. Not even a little bit. (Sorry.) It’s not that we don’t like open source. We’d open source all of Unity today if we thought we could get away with it and still be in business tomorrow, and we do have a growing number of open source projects. But the main engine will remain proprietary for the foreseeable future, and the C# reference source code is released under a license which only permits you to read the code, not modify it. Please consult the full license text for details before you get carried away.

We also do not take pull requests against the C# reference source code. We have neither the legal nor organizational frameworks in place to handle such PRs, not to mention that the mere act of preparing a PR is actually against the reference license (which, again, doesn’t permit modifications to the code). We would like to hear about it if you find a bug in the C# reference source code, but please report it using the Unity Bug Reporter (describing the issue and possibly linking to the relevant lines or files in the reference source code), not by submitting a pull request on GitHub.

What is it then?

C# source of everything that goes into UnityEngine and UnityEditor managed assemblies, for every single version going back to Unity 2017.1. Going forward, the repository will be updated shortly after every new release.

By looking at each commit you can see what has changed between successive versions. For example, 2017.3.1 patch 2 changed these files:

That’s it! The reference source code repository is at https://github.com/Unity-Technologies/UnityCsReference, enjoy using it as reference for your Unity learning needs.

56 replies on “Releasing the Unity C# source code”

To make it clear:
1) We don’t want, Substance, Enlighten, etc in source forms. Leave them as binary.
2) We want C++ backend sources to inspect and enhance them, would like to submit PRs.
3) We want C++ sources, to debug vague Unity errors, and possibly fix those in sources (see 2). There is no such thing as professional gamedev on a black-box engine. This simply doesn’t exist.
4) We want to be able to write on C++ freely and unencumbered. Without the need for GC, if we wish to.
5) We would like to take full control of our tech, not just the things, that you open for us like scriptable render, etc.
6) We don’t want to compromise Unity in any way as it is the engine of our choice and we love it. We just want to make it more development-, professional- and community-friendly.

Considering current Unity development direction (ECS, SRP) I think that C++ side will be less significant than C#. All new systems are released as C# sources (UI, SRP). In the future, C++ backend will be reduced to ECS and job system. You should read “Entity Component System principles and vision” in ECS documentation. It contains Unity roadmap for future releases.

You should set this up to handle pull requests. I would like to add some missing operators for your math libraries (particularly related to vectors).

It’s a pretty pathetic excuse to try and pin it all on legal issues that you’re not open sourcing the code. If it was so difficult, why are there thousands of open source projects that do just fine? You’re smart people, surely you can find a way to make it happen.

It’s really hard to find anything in the repo. Where is the reference for the UI Button script and the editor inspector for the button?

Wouldn’t it be technically possible to make a PR if you would sign over copyright (and other rights) to Unity itself,
or was this the “can of worms” mentioned.

It is legally complicated. We may eventually figure something out (there seems to be a lot of interest), but for now, we can’t take PRs.

>We’d open source all of Unity today if we thought we could get away with it and still be in business tomorrow.
Can you please give us some insight into why this is the case? If I’m not mistaken, it has been shown that being non-open-source isn’t a prerequisite to having success in the game engine business. After all, it isn’t the engine itself that is being opened up (the real stuff is happening in C++ isn’t it?), just the managed DLLs.

“We’d open source all of Unity today if we thought we could get away with it and still be in business tomorrow”

The single biggest threat to your success right now is NOT releasing the sources. All the best companies are open-sourcing their engines (Epic, Amazon Lumberyard, Cryengine) and benefiting immensely from it. Unity is the only one still stuck with the archaic and almost evil mindset of not releasing sources.

If selling Unity source code is your main income source, then just ask for 5% royalties instead. But by all means, release the full sources of the engine

Yeah, I second this. Not releasing source code when ALL major competitors already did is really weird. All Unity competitors ride the wave of community led improvements to their engines. Every seasoned Unity developer knows engine’s hard edges and soft spots that could be easily improved/expanded. Why not use this FREE workforce? We too want Unity to be the best engine on the market, why not let us help you UT?

No, 5% royalty is really a lot and many people stay in Unity because it’s cheaper
I would rather see only the C# part being open source(it’s already half way there), and the C++ side should stay closed if that means charging 5% royalty.

A quick google search can tell that none of the engines you just mentioned are open source (Epic, Amazon Lumberyard, Cryengine). All of them have their source code published to github for reference only, so literally what Unity just did.

Not true. The Unreal Engine is open (just not “open source”). You can modify the engine as you see fit and use it, as long as it’s within the EULA. A few have already done that.

Nick
“Yep, just to clarify, it is not technically “open source” it’s just a very very easily available source code…” – Alexander Paschall – Former Epic Games Staff

So no UE4 is not open source and you can not distribute the engine as you wish, just look at how modding work with UE4,
also “You are permitted to post snippets of Engine Code, up to 30 lines of code in length…”

“The source code is open, and you are permitted to modify or extend it for your own uses but not to redistribute it or derivatives of it. You are also prohibited from combining it with other code that is licensed in such a way that would require it to be licensed under any other terms (for example, GPL’d code).”

For those reasons and many more UE4 and those other engines mentioned are not really considered open source.

You are correct none of these engines are open source, but they still allow you to do pull requests and fix the code.
in Unity case, you can’t touch the code but just look at it, I think if they allowed us to work on the C# part of the engine that would be enough.

and thank you for pointing that out, I for one have forgotten what open source actually means.

That part specifically pertains to modifying and distributing the editor. You are not allowed to distribute an editor (modified or not) outside of Epic’s channels.

If you make modifications to the engine for your shipped game builds that is all fine.

For our modding, we have a version of our project that is cut down and works with the stock editor. Our engine changes are only for runtime issues anyway.

So a fix (pull request) has been made on github and it fixes a problem the engine has for years, but wont be accepted because lawyers…

Unity Team I hope you realize how lame this is, and start to accept our fixes.

Just want to update this and say that the Unity team is working on a fix for the bug posted on github

I’m very happy that they decided to not look away and are actually fixing it, because this was a very old bug I was very skeptical of Unity response but I’m glad they are doing their best withing the current legal situation.

Keep the good work!

This is AMAZING and extremely helpful for all game developers using the engine Thank you!!

now allow us to fix bugs, that’s literally FREE work and Unity should make use of our ability to find and fix these things
it would benefit Unity as an engine and company but also it would be a great deal for all developers having bug issues.

You can still review the code changes and approve or refuse it, just allow us to make fixing bugs faster

Please allow us to modify the code, you have already let us read it, it makes no sense that we can’t modify it and test ways to make it better.

“We’d open source all of Unity today if we thought we could get away with it and still be in business tomorrow”
With Unreal engine conquering mobiles like storm, you’ll be out of business tomorrow, if you WON’T release the sources, like Epics did. I can’t believe, that in 2018 there is still a software business model, that sells a dark skin as part of its subscription. Continue this way, and you will bury us all.

I’m agree with you, but it works not for every type of business. For example, a company has a new project every month with cost $25k – $30k each. It’s about $300k annual, so 5% royalty to Epic will be $15k per year. But this company can buy annual Unity license for $1500, and it’s will be 10 times cheaper. So there are some point of balance between project cost, project length and number of projects per year where choosing Unity will be much cheaper, than Unreal.

It will cost for a company $1500 annually only if it’s a one person-company. I don’t think such a company can open a new project every month. Well, it could, but obviously they won’t be profitable.

Look in perspective. Several years ago UE4 can’t mobiles at all. Now they can and they started conquering them. Several years ago UE4 was like a nightmare and total no-no for indies. Look at twitter now: lots of indie creating beautiful things with ease. So it’s just a matter of time. Short time.

Thank you for doing this. We are in a new era of software property protections. Judicious steps like this one are the right way to go forward, as we balance the benefits to the customer of publishing source against the commercial interests of owner. Overall, I am very pleased by Unity’s general “we’re all in this together” philosophy.

This is one of the most exiting updates I’ve read in a while. (The other being UnityScript’s departure) It will be immensely useful for making custom editors and UI things since disassembling does not provide enough context, and a lot of the Unity Docs for editor things tend to be one line blurbs with no examples. Hopefully in the future Unity will begin accepting PR’s or at least community modification in some way so that many of the bugs/typos that go unfixed for months or years can finally be fixed!

Great news.Just been browsing the source code and I’ve already picked up a few development tips. Thanks for making this available for reference purposes

Thanks for this! I frequently reference the source, and this will save me the hassle of disassembling it and dealing with all of the associated peculiarities. Also, as mentioned, being able to see the diffs is awesome.

“only permits you to read the code, not modify it.”

That’s dumb. At least allow me to fix the bugs I encounter, even if I don’t publish them.

you “technically” could, just not give fixes to anyone else or ever admit to having done it…

Legally gray at best though!

Oh yes, the famous Unity Bug tracker where even the simplest thing that require a “typo fix” go to die for 10 years. Yes, please report the bug to UBT and dont forget to buy Pro!

BRB just making my unity clone illegally using c# code and absolutely no engine and certainly not 1000 staff… or maybe not. But thanks for being transparent with existing code so that it may serve as a useful reference for how to do things the Unity way. For example rolling own tools with your own source. Now you know how a certain thing is supposed to be done.

Hello. Please note that in many jurisdictions, modifying something for private use cannot be disabled by licensing terms since it corresponds to tinkering and is then part of common sense or jurisdiction laws. In my jurisdiction for example, If I download, modify then recompile the project for private testing is perfectly legal, as long, as I don’t distribute the modified library.

You manually wrote that:
“We would like to hear about it if you find a bug in the C# reference source code” – This is nice but it also implies that we usually compiled the code, made it run, tinkered it a bit, and debugged it inside the Unity itself (debugged Unity itself). Or, the act of tinkering, again :) It would be your best if you see somebody of us post a patch via the Bug Reporter to actually investigate it since most of us who analyze the code will actually write a patch-as-bug-report to give hints to your developers. (there is one pull request already on GitHub with very important potential-fix now).

We’re aware that jurisdictions vary (hence section 7 of the license). The blog post is obviously not legal advise, but just meant to give a layman’s summary of the most important restrictions. To learn your exact legal situation, always refer to the full license text and/or consult a lawyer.

“If you find a bug” was definitely not meant to imply that you should attempt to fix bugs yourself, but simply refers to cases where people are reading the code and notice something that appears to be a bug. If so, we’d of course like to hear about it (preferably via the Bug Reporter, not a GitHub PR). :-)

This is great news! On another note, is it possible to enable viewing of entire articles for feed readers? That would be much appreciated.

That’s great. The diff between each versions (comments included) is definitely a plus that disassembled code could not provide.
While it doesn’t cover all changes (the rest of the engine being closed C++, it does give an opportunity to make sure plugings follow breaking changes between versions.
Thanks for that!

Comments are closed.