Search Unity

Waiting dabatabase loading

Discussion in 'Scripting' started by Jack-Mariani, Sep 5, 2014.

  1. Jack-Mariani

    Jack-Mariani

    Joined:
    Jul 12, 2013
    Posts:
    10
    Hi everyone. I'm a newbye, so, sorry if I'm asking something obvious.
    I have to do load and update a database with C#.

    The plan is to do the following:

    1) Load the database
    2) Wait until it finishes loading
    3) Update the database

    Alas seems I've a few problems with coroutines.

    I tried this:

    IEnumerator WaitDatabase (bool busy)
    {
    while (busy)
    {
    yield return null;
    }
    }

    public IEnumerator LoadDatabase()
    {
    //Load the database
    busy = false;
    }

    public void UpdateDatabase()
    {
    //update database
    }

    void Update
    {
    LoadDatabase();
    WaitDatabase();
    UpdateDatabase();
    }

    I'm still learning co routines and I think I really could use a hand.