예제 #1
0
    private void GetThumbnail()
    {
        var url = catalogItem?.GetThumbnailUrl();

        if (url == loadedThumbnailURL)
        {
            return;
        }

        if (catalogItem == null || string.IsNullOrEmpty(url))
        {
            return;
        }

        string newLoadedThumbnailURL     = url;
        var    newLoadedThumbnailPromise = new AssetPromise_Texture(url);


        newLoadedThumbnailPromise.OnSuccessEvent += SetThumbnail;
        newLoadedThumbnailPromise.OnFailEvent    += x => { Debug.Log($"Error downloading: {url}"); };

        AssetPromiseKeeper_Texture.i.Keep(newLoadedThumbnailPromise);


        AssetPromiseKeeper_Texture.i.Forget(loadedThumbnailPromise);
        loadedThumbnailPromise = newLoadedThumbnailPromise;
        loadedThumbnailURL     = newLoadedThumbnailURL;
    }
예제 #2
0
    private void GetThumbnail()
    {
        SetLoadingActive(true);

        if (catalogItem == null)
        {
            return;
        }

        var url = catalogItem.GetThumbnailUrl();

        if (string.IsNullOrEmpty(url) || url == loadedThumbnailURL)
        {
            return;
        }

        ClearThumbnailPromise();
        loadedThumbnailPromise = new AssetPromise_Texture(url);

        loadedThumbnailPromise.OnSuccessEvent += x =>
        {
            loadedThumbnailURL = url;
            SetThumbnail(x);
        };

        loadedThumbnailPromise.OnFailEvent += x =>
        {
            Debug.Log($"Error downloading: {url}");
            SetLoadingActive(false);
        };

        AssetPromiseKeeper_Texture.i.Keep(loadedThumbnailPromise);
    }
    private void SetCatalogItemToShortcut(CatalogItem catalogItem)
    {
        if (catalogItem == null)
        {
            return;
        }

        var url = catalogItem.GetThumbnailUrl();

        if (string.IsNullOrEmpty(url))
        {
            return;
        }

        ClearThumbnailPromise(quickBarShortcutsThumbnailPromises[lastIndexDroped]);
        quickBarShortcutsThumbnailPromises[lastIndexDroped] = new AssetPromise_Texture(url);

        quickBarShortcutsThumbnailPromises[lastIndexDroped].OnSuccessEvent += x =>
        {
            SetQuickBarShortcut(catalogItem, lastIndexDroped, x.texture);
        };

        quickBarShortcutsThumbnailPromises[lastIndexDroped].OnFailEvent += x =>
        {
            Debug.Log($"Error downloading: {url}");
        };

        AssetPromiseKeeper_Texture.i.Keep(quickBarShortcutsThumbnailPromises[lastIndexDroped]);
    }