Learning Unity Internals

This is a bit hard to explain.

So far all of the learning materials I’ve seen take one of two approaches: 1. Use case tutorial, i.e. “How to do X”; 2. Manual or reference.

Neither focuses on what I want: theory. I don’t mean the theoretical details of video game technology, I know where to find that stuff. I mean the things strictly about Unity, the software, that will allow me to figure things out logically, rather than by trial and error or asking someone else. If such information is in the manual or reference, it’s scattered around in a useless way.

For example, recently I made a public variable of class Foo in my script Bar so I could drag a Foo into the Bar component in the inspector. Foo was defined in my Foo script, but I couldn’t drag the Foo script into the Bar component. However, I found that I could drag in an object that had the Foo script as a component. I didn’t know Unity would go find the Foo in that object (and anyway I now understand that I was conflating a Foo with the definition of a Foo). That particular detail of Unity’s behavior doesn’t seem to be in any of the materials I’ve seen.

Any ideas?

You are basically asking how Photoshop does its thing and complaining about there are tutorials for “How to do X in Photoshop”, as it is clearly what’s necessary for users, while former is just a “stats for nerds” thing.

While I do not think you’d find such a document on Unity, you can go through manuals to see if they included such an information. For example, Unity explains how view frustum works.

Your example requires a little bit of a programming knowledge. Note that Unity works in a pattern oriented fashion instead of object oriented, meaning it’s component based. An empty gameobject comes with Transform component. Everything else is a component, which can be referenced from each other; i.e. a Hinge is not a gameobject (or an object for that matter) but a component, which can be added to any gameobject, but also requires RigidBody component.

Where you are wrong is you are trying to drag the script file inside your object with Bar component. Your script file is a physical file on harddisk, Unity does not convert it to a gameobject. BUT, you can add the said script to your gameobject as a component.

Unity checks that gameobject IF it includes the required component. That’s a very easy check, any beginner can write a code for that, and a complex software like Unity can pretty much handle it in any case.

Another thing to mention is that a variable and a gameobject are different things. You can add a component to a gameobject, but you cannot add a gameobject to a gameobject, unless it is a variable.

So, you should probably start here: http://docs.unity3d.com/Manual/TheGameObject-ComponentRelationship.html

I believe you simply want to learn how to write a game engine, and define shaders. I know this much, because my friend has basically written a game engine similar to Unity3d, but it was the 3rd game engine he wrote.
Unfortunately, Game Engines are as complex as your question, hah, depending on what you want to do.
I, myself, am a self-taught programmer who happens to have a mentor (that guy, an amazing senior programmer at Smashing Ideas) and at this point, I have taken his advice, read books, but still not dove into game engines.
I still have a lot to learn, but I think, this answer is the best one so far, at least until Unity says what philosophy is behind their engine’s inner structs

If you are Intermediate or above in your programming skills you can use a program called ILSpy.

Open the Unity/Mono dlls with this program and all the internal methods will be revealed. There is no better way to see how Unity Internals work.

https://www.google.co.uk/search?q=unity+ilspy&ie=utf-8&oe=utf-8&gws_rd=cr&ei=JWz6VpDzBcXyPN2vsdAE#q=unity+ilspy+internals