Hello everybody ^-^ and Happy New Year (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:
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):
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 ^-^