Why is there no official C# example of how to use GameObject.GetComponent?

From what I understand, GetComponent works very differently in C# than in Javascript, so why no help for the C# guys eh?

The answer is pretty simple: The documentation is an “evolving mess”. Everytime they improve something in the docs, something else get worse. Besides that most examples are simply wrong or a bad choice UT should at least try to keep a certain equal level across the docs.

That said i should mention that GetComponent doesn’t work “very differently” on C# since it is actually the exact same method. UnityScript has a different syntax and the syntax is shown in the docs for both languages.

The MSDN documentation of a lot methods don’t have any examples. In the past there wasn’t any online documentation at all. Also keep in mind that the purpose of a documentation is to document the syntax and describe what a method does, it’s not a tutorial to teach programming. Documentations can only be understood by people from that field of expertise. If i would show any Unity docs to my mother she won’t understand anything, even after reading it 20 times.

Unity has a lot of user guide and reference pages like this one:

http://docs.unity3d.com/412/Documentation/ScriptReference/index.Accessing_Other_Game_Objects.html

All examples are (finally) available in all languages. If you’re new to Unity and C# you have to understand that UT is not responsible to teach users C# basics. The docs / guides are only to explain how Unity and it’s related interfaces / methods / concepts works.

http://docs.unity3d.com/Documentation/Manual/GenericFunctions.html