Unity C# questions.

Hello everyone!

I am interested in learning c# to program/script in unity, but the majority of the books I’ve found are for c# 5.0, and after looking into it I noticed that unity uses c# 4.0. Will learning 5.0 allow me to do script using c# 4.0? I’m just unsure as to what the difference in versions is as I don’t have a very large amount of knowledge on the subject (hence looking into learning it :P).

As well, if anyone has recommendations on books that helped them learn c# would be greatly appreciated.

Thanks!

The biggest new feature of C# 5.0 is better support for asynchronous operations, using the new ‘await’ keyword, but that may be irrelevant for a beginner.
Also Microsofts C# 5.0 Standard was introduced together with .Net 4.5.

It actually uses .NET 3.5. What you’re looking at (4.0 and 5.0) are the language specifications. It’s not going to make a whole lot of difference. What you may run into is that some of the language features aren’t available, but most likely it will be framework specific (not language specific). For instance, you’ll learn about the “dynamic” keyword which isn’t available in Unity. I’d say go ahead with the C# 5.0 book and just be aware that Unity is using the .NET 3.5 Framework so there will be some things that just won’t work.

Oh okay, that clears some stuff up. :slight_smile:

Quick question though, when you mention “framework” specific what exactly are you referencing to? Does that mean features that are Unity specific? (Sorry! Just getting started into this stuff!)

Why look at books when you can do extremely well explained video courses?

Take a look at this course on pluralsight…

This course goes into the stuff that Unity supports (.NET 3.5 and earlier). So once you finish this you’ll be well on your way to being a proficient coder.

Both actually… things that are Unity specific and things that are in the .NET Framework. The Framework itself can be used with a number of different programming languages. You can ignore that bit for now as you’ll just be using C#. Now Unity as a game engine also has its own API or Framework if you’d like to call it that. It is a unique set of building blocks.

For example… in the .NET framework you have types, like collections. For instance, List is a collection type that is in the .NET Framework. You would use this in your C# code whether you’re writing for Unity or otherwise. Now Unity has its own types built in, such as Texture2D. You will also code for Texture2D but only in the context of Unity as it’s part of Unity’s framework.

Now, there are things in the .NET Framework that aren’t available in Unity for a variety of reasons, one of which is to keep build sizes down but also because there are large portions of those features that either aren’t applicable or wouldn’t work properly cross-platform. An example is the System.Data namespace. There are a lot of things inside of System.Data that you wouldn’t be able to use properly on a mobile device, or in the web player or that are specific to tech such as SQL Server.

Okay, now I understand what you mean. :slight_smile:
And as for the video thing Meltdown, I find that I have an easier time learning from books than videos. And I like the idea of having a physical copy of a book to refer back to if need be.

I’m with you there. PluralSight is great but videos struggle to hold my attention. I prefer books, blogs and tech resources.