Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Serialize and Scriptable Objects

Discussion in 'Scripting' started by Lancaster13, Apr 27, 2015.

  1. Lancaster13

    Lancaster13

    Joined:
    Dec 24, 2014
    Posts:
    25
    Hello Guys,

    I'm studying C# for Unity, but I cant to understand what happens when I put before the class the attribute [Serializable]. And I also cant to understand how to make persistent data, with the Scriptable Hiretance. Can Anyone explain me a little about these concepts and application?

    Thanks!!
     
  2. CaptainMurphy

    CaptainMurphy

    Joined:
    Jul 15, 2014
    Posts:
    746
    hamsterbytedev likes this.
  3. SubZeroGaming

    SubZeroGaming

    Joined:
    Mar 4, 2013
    Posts:
    1,008
    When you serialize a custom class, you're allowing it to be seen in the inspector. Same goes with Structs.

    You should be using [System. Serializable] for class/structs.

    for variables that are private, you can serialize those fields and see them in the inspector as well by using : [SerializeField]