예제 #1
0
    private IEnumerator FetchNFTImage(NFTInfo nftInfo)
    {
        spinnerNftImage.SetActive(true);

        IWrappedTextureAsset nftImageAsset = null;

        yield return(Utils.FetchWrappedTextureAsset(nftInfo.previewImageUrl,
                                                    (asset) =>
        {
            nftImageAsset = asset;
        }));

        if (nftImageAsset == null)
        {
            yield return(Utils.FetchWrappedTextureAsset(nftInfo.originalImageUrl,
                                                        (asset) =>
            {
                nftImageAsset = asset;
            }, WrappedTextureMaxSize._256));
        }

        if (nftImageAsset != null)
        {
            imageAsset       = nftImageAsset;
            imageNft.texture = nftImageAsset.texture;

            var gifAsset = nftImageAsset as WrappedGif;
            if (gifAsset != null)
            {
                gifAsset.SetUpdateTextureCallback((texture) =>
                {
                    imageNft.texture = texture;
                });
            }
            SetNFTImageSize(nftImageAsset.texture);
            if (!backgroundColorSet)
            {
                SetSmartBackgroundColor(nftImageAsset.texture);
            }

            imageNft.gameObject.SetActive(true);
            spinnerNftImage.SetActive(false);
        }
    }
예제 #2
0
    private void SetNFTInfo(NFTInfo info, string comment)
    {
        spinnerGeneral.SetActive(false);

        imageNftBackground.color = Color.white;
        backgroundColorSet       = info.backgroundColor != null;
        if (backgroundColorSet)
        {
            imageNftBackground.color = info.backgroundColor.Value;
        }

        textNftName.text = info.name;
        textNftName.gameObject.SetActive(true);

        textOwner.text = FormatOwnerAddress(info.owner);
        textOwner.gameObject.SetActive(true);

        if (!string.IsNullOrEmpty(info.lastSaleAmount))
        {
            textLastSalePrice.text = ShortDecimals(info.lastSaleAmount, 4);
            textLastSalePrice.gameObject.SetActive(true);
        }
        else
        {
            textLastSaleNeverSold.gameObject.SetActive(true);
        }

        if (!string.IsNullOrEmpty(info.currentPrice))
        {
            textPrice.text = ShortDecimals(info.currentPrice, 4);
            textPrice.gameObject.SetActive(true);

            if (info.currentPriceToken != null)
            {
                SetTokenSymbol(textPriceSymbol, info.currentPriceToken.Value.symbol);
            }
        }
        else
        {
            textPriceNotForSale.gameObject.SetActive(true);
        }

        if (info.lastSaleToken != null)
        {
            SetTokenSymbol(textLastSaleSymbol, info.lastSaleToken.Value.symbol);
        }

        if (!string.IsNullOrEmpty(info.description))
        {
            textDescription.text = info.description;
            containerDescription.SetActive(true);
        }

        if (!string.IsNullOrEmpty(comment))
        {
            textComment.text = comment;
            containerComment.SetActive(true);
        }

        textOpenMarketButton.text = "VIEW";
        if (info.marketInfo != null)
        {
            textOpenMarketButton.text = $"{textOpenMarketButton.text} IN {info.marketInfo.Value.name.ToUpper()}";
        }

        marketUrl = null;
        if (!string.IsNullOrEmpty(info.marketLink))
        {
            marketUrl = info.marketLink;
        }
        else if (!string.IsNullOrEmpty(info.assetLink))
        {
            marketUrl = info.assetLink;
        }

        buttonCancel.gameObject.SetActive(true);
        buttonOpenMarket.gameObject.SetActive(true);

        if (!string.IsNullOrEmpty(info.thumbnailUrl))
        {
            spinnerNftImage.SetActive(true);
            fetchNFTImageRoutine = StartCoroutine(Utils.FetchWrappedTextureAsset(info.thumbnailUrl, (asset) =>
            {
                imageAsset       = asset;
                imageNft.texture = asset.texture;

                var gifAsset = asset as WrappedGif;
                if (gifAsset != null)
                {
                    gifAsset.SetUpdateTextureCallback((texture) =>
                    {
                        imageNft.texture = texture;
                    });
                }
                SetNFTImageSize(asset.texture);
                if (!backgroundColorSet)
                {
                    SetSmartBackgroundColor(asset.texture);
                }

                imageNft.gameObject.SetActive(true);
                spinnerNftImage.SetActive(false);
            }));
        }
    }