- Home /
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?
Answer by Tanshaydar · Oct 16, 2014 at 12:30 PM
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
Thanks for trying. I mean it. $$anonymous$$aybe my request isn't realistic. shrug
@Tanshaydar, I think you've half interpreted (and unnecessarily dismissed) the value of this question. Implementation details of particular features of the engine aren't what's of interest. A view frustum exists in all 3D engines. It's very well-documented, and you'd encounter it in any intro to 3D graphics course at a university. I think OP's intention is to find a map of the object model that Unity, specifically, uses. For example, if you are writing scripts for the music software Ableton, they provide a full map of all objects' relationships ( https://docs.cycling74.com/max5/refpages/m4l-ref/m4l_live_object_model.html )
I've also found that Unity's documentation is a bit lacking in this area. An object model is infinitely helpful when planning a set of Best Practices, which aside from a number of lectures and blog posts from various developers, I've yet to find a prescribed methodology. It's confusing, and begs me to ask the question "What, exactly, was this engine designed to do?"
I'd also like to shed some light on a claim you made - you mentioned that Unity is "pattern oriented ins$$anonymous$$d of object oriented." While it is true that various design patterns have been used in the design of this software (as they are with most software designs), it is untrue that this is in opposition to an object model. Your comment implies that Unity has no object model. Patterns are just commonly-used compositions of objects. They are not opposing ideas.
I, too, wish there was a map that shows the end-to-end relationships between input, feedback, and the objects and patterns that support the engine in general. An API is helpful for implementation details, but a map of the O$$anonymous$$ helps me to plan my own patterns and objects.
Answer by feiting · Feb 12, 2016 at 06:13 PM
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
Answer by meat5000 · Mar 29, 2016 at 11:51 AM
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.
Your answer
Follow this Question
Related Questions
A node in a childnode? 1 Answer
Can kids use unity? 5 Answers
Practice projects for unity? 1 Answer
Best Place For An Absolute Beginer To Start Learning Unity 2 Answers
Instantiating a MonoBehavior Class at runtime and pass it a normal Class 1 Answer