Search Unity

Save bool data

Discussion in 'Scripting' started by Jersey_591, Aug 17, 2017.

  1. Jersey_591

    Jersey_591

    Joined:
    Aug 12, 2017
    Posts:
    5
    Hello
    I have a lot of boolean value, I want to save them in a folder, how can I do that?
    Can you help me
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,742
    If you are talking about a Unity3D-centric solution, using a ScriptableObject is a way to approach it:

    Code (csharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. [CreateAssetMenu]
    5. public class BooleanArrayScriptableObject : ScriptableObject
    6. {
    7.     // you can do it with specific flags
    8.     public bool Flag1;
    9.     public bool Flag2;
    10.  
    11.     // or you can do it as an array
    12.     public bool[] Flags;
    13. }
    You can right-click and make as many of those assets as you want in your project.

    You can also serialize pretty much any basic types in there in addition to booleans.
     
  3. Jersey_591

    Jersey_591

    Joined:
    Aug 12, 2017
    Posts:
    5
    Yes I don't write it, but I want to serialize, and I'm in 2D
     
    Last edited: Aug 17, 2017