Beispiel #1
0
    public AssetLoader LoadAssetAsync(string assetBundleName, string assetName, System.Type type)
    {
        AssetLoader loader = null;

#if UNITY_EDITOR
        if (SimulateAssetBundleInEditor)
        {
            assetBundleName = assetBundleName.ToLower();
            string[] assetPaths = AssetDatabase.GetAssetPathsFromAssetBundleAndAssetName(assetBundleName, assetName);
            if (assetPaths.Length == 0)
            {
                Debug.LogError("There is no asset with name \"" + assetName + "\" in " + assetBundleName);
                return(null);
            }
            // @TODO: Now we only get the main object from the first asset. Should consider type also.
            Object obj = AssetDatabase.LoadMainAssetAtPath(assetPaths[0]);
            loader = new AssetBundleSimulationLoader(obj);
        }
        else
#endif
        {
            //LoadAssetBundle(assetBundleName);
            loader = new AssetBundleAssetLoader(assetBundleName, assetName, type);

            //m_InProgressOperations.Add(operation);
        }

        return(loader);
    }
Beispiel #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
    }
Beispiel #3
0
    public AssetBundleAssetLoader MakeLoader()
    {
        AssetBundleAssetLoader loader = new AssetBundleAssetLoader(this);

        return(loader);
    }