Search Unity

Storing data in unity

Discussion in 'Scripting' started by Camronas, Feb 11, 2016.

  1. Camronas

    Camronas

    Joined:
    Apr 20, 2012
    Posts:
    154
    Hey everyone, just wanting to know if it is possible to have a script store a list of information for me in the Unity Editor that I can access from other locations.
    I wanted to have a list be edited in the inspector so I created a custom script:


    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. [System.Serializable]
    5. public class Boolean_Save_Data
    6. {
    7.     public string boolName = "name";
    8.     public bool boolValue = false;
    9. }
    10.  
    In another script I made a list of "Boolean_Save_Data" like so:

    Code (CSharp):
    1.     public List<Boolean_Save_Data> booleanSaveData = new List<Boolean_Save_Data>();
    Is it possible to make a drop down menu in another script that can access this list displaying the names of all the elements in the list? The drop down would allow me in editor to set the value of that element in the list. In this case I could do something like:

    Select - boolName - Lights
    Set lights to true/false

    Is doing something like that possible in Unity? Any and all help is greatly appreciated!
     
  2. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
  3. Camronas

    Camronas

    Joined:
    Apr 20, 2012
    Posts:
    154
    Thanks, using some of the information from this link I have come up with some pretty good methods; thanks!