コード例 #1
0
    public void RefreshState()
    {
        buyBt.interactable = !store.store.IsItemBought(item.GetThisPlatformId());

        downloadBt.interactable = (store.store.IsItemBought(item.GetThisPlatformId()) &&
                                   !store.store.IsItemDownloaded(item.GetThisPlatformId()));
    }
コード例 #2
0
    public void LoadItem(ScriptableStoreItem item)
    {
        AssetBundleAssetLoader itemBundleLoader = new AssetBundleAssetLoader(item.bundle);

        itemBundleLoader.behaviorToRunCoroutines = this;
        itemBundleLoader.hasShippedVersion       = false;
        itemBundleLoader.autoDownloadNewVersion  = true;
        Hash128 hash = manifest.GetAssetBundleHash(item.bundle.assetBundleName);

        itemBundleLoader.hardcodedServerBundleHash = hash;
        itemBundleLoader.useHardcodedHash          = true;
        itemBundleLoader.onAssetLoaded.AddListener((Object asset) => {
            Debug.Log("Item ready: " + item.descriptiveName + ", asset: " + asset.name);
            itemsAsset[item.GetThisPlatformId()]      = asset;
            itemsDownloaded[item.GetThisPlatformId()] = true; // Mark it as downloaded right now for consistency
            onStoreItemReady.Invoke(item, asset);

            if (state.CurrentState == State.LOADING_DOWNLOADED_ITEMS)
            {
                itemsToLoad--; // CHECKING all items downloaded
                if (itemsToLoad == 0)
                {
                    SetStoreReady();
                }
            }
        });
        itemBundleLoader.LoadBundleAndAsset(); // can load from cache if available, or download it
    }