Beispiel #1
0
    void Start()
    {
        _log = new Kayac.FileLogHandler("log.txt");
#if UNITY_EDITOR
        var storageCacheRoot = Application.dataPath;
#else
        var storageCacheRoot = Application.persistentDataPath;
#endif
        storageCacheRoot += "/../AssetFileCache";
        // キャッシュのスキャンはできるだけ早く始めた方が良い
        _loader = new Kayac.Loader(storageCacheRoot, useHashInStorageCache: true);

        _sb     = new System.Text.StringBuilder();
        _images = new RawImage[HandleCount];
        int   sqrtHandleCount = Mathf.FloorToInt(Mathf.Sqrt((float)HandleCount));
        float imageSize       = DeferenceScreenHeight / sqrtHandleCount;
        for (int i = 0; i < HandleCount; i++)
        {
            var go = new GameObject(i.ToString());
            _images[i] = go.AddComponent <RawImage>();
            var rect = _images[i].rectTransform;
            rect.anchorMin        = Vector2.zero;
            rect.anchorMax        = Vector2.zero;
            rect.pivot            = Vector2.zero;
            rect.sizeDelta        = Vector2.one * imageSize;
            rect.anchoredPosition = new Vector2(imageSize * (i / sqrtHandleCount), imageSize * (i % sqrtHandleCount));
            rect.SetParent(canvas.transform, false);
        }

        _database = new AssetFileDatabase();

        string downloadRoot;
        _fileList = new List <string>();
        if (!ReadAssetFileList(out downloadRoot))
        {
            for (int i = 1; i < FileCount; i++)
            {
                var path = string.Format("stamp_{0}.png", i);
                _fileList.Add(path);
            }
            downloadRoot = "file://" + Application.dataPath + "/../AssetBuild";
        }
        UpdateHashMap();

        if (downloadParallelCount < 1)
        {
            downloadParallelCount = 1;
        }
        // Databaseの準備ができたらロード可能にするためにStartを呼ぶ
        _loader.Start(
            downloadRoot,
            _database,
            downloadParallelCount);
        _loader.SetMemoryCacheLimit(this.memoryCacheLimitMB * 1024 * 1024);
        _loader.SetLoadLimit(this.loadLimitMB * 1024 * 1024);
    }
Beispiel #2
0
    void Start()
    {
        var database = new AssetBundleDatabase();

        var downloadRoot = "file:///" + Application.streamingAssetsPath + "/";

#if !USE_HANDLE_HOLDER
        _handles = new Kayac.LoadHandle[HandleCount];
#endif

        _loader = new Kayac.Loader(downloadRoot, database);
        // ログファイルへ
        _log   = new Kayac.FileLogHandler("log.txt");
        _texts = new UnityEngine.UI.Text[HandleCount];
        for (int i = 0; i < HandleCount; i++)
        {
            _texts[i] = Instantiate(_textPrefab, _textRoot, false);
        }
    }