mardi 29 mars 2016

How to access lists created in a singleton class from another script in Unity3d and C#

Working on an RPG in Unity3d. Have successfully refactored the code to run an an SQL database and into a singleton pattern. The gameobject is created at runtime. In each table I create a List based on its property script(I'm creating it there because it accesses the database). The other script is attached to the top panel where I want to display the character's name and stats, but I'm having trouble getting access to the list.

PlayerDatabaseManager PDM;

void Awake()
{
    PlayerDatabaseManager.Instance.LoadPersonal();
}

// Use this for initialization
void Start () 
{
    PDM.GetComponent<PlayerDatabaseManager>.Personal();
    Personal=PDM.Personal.Name();
}

I'm confused what to put where. Does personal need to be of type databasemanager or of type personal? Thanks in advance!

Aucun commentaire:

Enregistrer un commentaire