-5

I have a little question, if someone can help me, I'll be grateful.

What is Serializable field in Unity ?

How it works for an object of a class ?

In code it's looks like :

[Serializable]

or

[System.Serializable]
FreeD
  • 3
  • 3
  • 2
    Feed your title to Google *et voila!*: [Why should I use SerializeField?](https://stackoverflow.com/questions/53192019/why-should-i-use-serializefield) – Ňɏssa Pøngjǣrdenlarp Aug 17 '20 at 20:02
  • It means...you'll never believe this...the class can be serialized! [Just like the docs say](https://learn.microsoft.com/en-us/dotnet/api/system.serializableattribute?view=netcore-3.1). – Wyck Aug 17 '20 at 20:19
  • `[Serializable]` just means that you can edit something in the inspector if you are talking about unity. `[System.Serializable]` is something else. Go check out https://learn.microsoft.com/en-us/dotnet/api/system.serializableattribute?view=netcore-3.1 – Itsme1 Aug 18 '20 at 08:32

2 Answers2

-1

[Serializable] private GameObject gameobject;

[System.Serializable] private int timer;

The serializable field works like a public variable except that you can using it for a private variable. Some people just use a public variable but a serializable private variable works the same.

Stephan
  • 155
  • 6
-2

Might be a lazy answer... but Unity provides a very useful documentation (with examples) which explains every command, even [Serializable].

Here is the link to what you are looking for:

https://docs.unity3d.com/ScriptReference/Serializable.html