I had a lot of trouble understanding serialization in unity. But I understood a lot more when I started using struct. I understood that when my struct was serialized, I didn’t need to create it by code in my script when the program start, but with serialization I could should declare it in my script and the values would already be set because it is save in memory. (As far as I try to understand).
But I’m still confused about creating a serialized class at Runtime. Let’s say I have
public class Foo
{
private int value;
public Foo(int value)
{
this.value = value;
}
}
And
[Serializable]
public class FooSerialized
{
private int value;
public FooSerialized(int value)
{
this.value = value;
}
}
What would be the difference (Anything, performance, usability, memory, etc.) that would impact my game between these two :
public Foo foo = new Foo(1);
public FooSerialized fooSerialized = new FooSerialized(1);
Will they act the same? Thanks!