Javascript and C#, different behaviour in inspector ?

Hello everybody ^-^ and Happy New Year :smiley: (few days late ^-^')

I’ve recently changed from javascript to c# and i have a slightly doubt about the inspector behaviour with the last one.

I mean, when i add a class as a variable of another in javascript:

#pragma strict

public class A extends MonoBehaviour {
	public var pol : int;
	public var b : B;
}

#pragma strict

public class B {
	public var al : int;
}

in the inspector i can access the public variables from the second (B) in the object containing the first (A), like this:

38158-dibujo.jpg

But when i try to do the same in C#:

using UnityEngine;
using System.Collections;

public class C : MonoBehaviour {
	public int pol;
	public D d;
}

using UnityEngine;
using System.Collections;

public class D  {
	public int al;
}

I can’t get the same inspector menu (i get this):

38159-dibujo.jpg

Unless i use [System.Serializable] in the second :

using UnityEngine;
using System.Collections;

[System.Serializable]
public class D  {
	public int al;
}

Then i get the same result as in javascript (in the inspector C has the D menu to modify, can’t post more images it seems ^-^').

So my question is, am i doing something wrong in C# to have that different behaviour?
Is that javascript is already serializable (has something similar to System.Serializable by default in each class already)?
Should i change the way of doing it? :o

Thank you in advance ^-^

JavaScript does a lot of things for you in the background. This is why its considered ‘easier to learn’. The down side is you are giving up some control. It also requires a fair bit of knowledge to know exactly what is happening behind the code.

C# requires you to do things manually. This means it does what you tell it to, allowing users more control. But it does mean you have to write out more code explicitly.

Declaring variables is another good example. C# will not let you use var at the class scope, you have to define it explicitly with a type. JS lets you use var and the compiler figures out what you were talking about. The compiler can actually mask some errors as it tries to help you. This is one of the key reasons I prefer C#.