Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Question about scriptable object instance

Discussion in 'Prefabs' started by rango302, Jun 17, 2021.

  1. rango302

    rango302

    Joined:
    Feb 1, 2018
    Posts:
    22
    Hi all,
    I just wondering what if I create a scriptable object SO in Resource/. Lets say it hold a variable currentLevel.
    I set currentLevel in inspector to 0 and build. At run time of the build currentLevel is set to 2 by a script that holds the reference of SO. Will currentLevel be 2 next time I start the build? If so, Is that mean I can treat it as a save data?
     
  2. flashframe

    flashframe

    Joined:
    Feb 10, 2015
    Posts:
    585
    It will in the editor, but not in a build of your game.
     
    rango302 likes this.
  3. Lurking-Ninja

    Lurking-Ninja

    Joined:
    Jan 20, 2015
    Posts:
    8,726
    No. SOs are assets just like for example materials. So they retain changes in the editor, but they do not retain changes in build between sessions.
     
    rango302 likes this.
unityunity