IEnumerator DownloadAndCache()
    {
        while (!Caching.ready)
        {
            yield return(null);
        }

        var www = WWW.LoadFromCacheOrDownload(bundleURL, version);

        yield return(www);

        if (!string.IsNullOrEmpty(www.error))
        {
            Debug.Log(www.error);
            yield break;
        }
        Debug.Log("IsLoaded");
        var assetBundle = www.assetBundle;

        var itemRequest = assetBundle.LoadAllAssetsAsync(typeof(TypeOfItemScript));

        while (!itemRequest.isDone)
        {
            float progressFloat = itemRequest.progress / 0.9f;
            progressCircle.fillAmount = progressFloat;
            yield return(itemRequest);
        }

        Debug.Log("TypeOfItemLoaded");

        typeOfItems = itemRequest.asset as TypeOfItemScript;

        itemRequest = assetBundle.LoadAllAssetsAsync(typeof(ItemScript));

        progressCircle.fillAmount = 0;

        while (!itemRequest.isDone)
        {
            float progressFloat = itemRequest.progress / 0.9f;
            progressCircle.fillAmount = progressFloat;

            yield return(itemRequest);
        }

        Debug.Log("ItemLoaded");

        Debug.Log(itemRequest.allAssets.Length);
        for (int i = 0; i < itemRequest.allAssets.Length; i++)
        {
            items.Add(itemRequest.allAssets[i] as ItemScript);
        }
    }
    public void LoadFilesFromServer()
    {
        StartCoroutine(checkInternetConnection());

        typeOfItems             = new TypeOfItemScript();
        typeOfItems.typesOfItem = new List <string>();
        typeOfItems.nameOfCategoryForMainWindow       = new List <string>();
        typeOfItems.secondNameOfCategoryForMainWindow = new List <string>();

        StartCoroutine(LoadInfoFromServer());
        Caching.ClearCache();
        StartCoroutine(DownloadAndCache());
    }
Example #3
0
    private void LoadFromItemsFromPath()
    {
        allFiles = Directory.GetFiles("Assets/Resources/AllItems");
        for (int i = 0; i < allFiles.Length; i++)
        {
            allFiles[i] = Path.GetFileNameWithoutExtension(allFiles[i]);
        }

        for (int i = 0; i < (allFiles.Length / 2) - 1; i++)
        {
            items.Add(Resources.Load("allItems/" + allFiles[i * 2]) as ItemScript);
        }

        typesOfItem = Resources.Load("allItems/" + allFiles[allFiles.Length - 2]) as TypeOfItemScript;
    }
Example #4
0
    IEnumerator DownloadAndCache()
    {
        yield return(checkInternetConnection());

        while (!Caching.ready)
        {
            yield return(null);
        }

        var www = WWW.LoadFromCacheOrDownload(bundleURL, version);

        yield return(www);

        if (!string.IsNullOrEmpty(www.error))
        {
            Debug.Log(www.error);
            yield break;
        }
        Debug.Log("IsLoaded");
        var assetBundle = www.assetBundle;

        var itemRequest = assetBundle.LoadAllAssetsAsync(typeof(TypeOfItemScript));

        yield return(itemRequest);

        Debug.Log("TypeOfItemLoaded");

        typeOfItems = itemRequest.asset as TypeOfItemScript;

        itemRequest = assetBundle.LoadAllAssetsAsync(typeof(ItemScript));
        yield return(itemRequest);

        Debug.Log("ItemLoaded");

        Debug.Log(itemRequest.allAssets.Length);
        for (int i = 0; i < itemRequest.allAssets.Length; i++)
        {
            items.Add(itemRequest.allAssets[i] as ItemScript);
        }

        isFileLoaded = true;
    }