Ejemplo n.º 1
0
        private void GetAssetBundle(string bundleName, Action <bool> callback)
        {
            Hash128 hash = new Hash128();

            Debug.Log(bundleName);
            string bundleNameTransfered = LWAssetBundleParser.TransferItemIdToBundleName(bundleName);

            Console.text += bundleName + "\r\n";
            AssetBundleRef requestAB = new AssetBundleRef(bundleNameTransfered, hash);

            AssetBundleManager.DownloadAssetBundle(requestAB, callback);
        }
Ejemplo n.º 2
0
        public void OnPreviewClicked()
        {
            if (!string.IsNullOrEmpty(currentLoadedBundleName))
            {
                AssetBundleManager.Unload(currentLoadedBundleName, true);
            }

            foreach (Transform child in root)
            {
                Destroy(child.gameObject);
            }
            string skinId = Skin.text;

            GetAssetBundle(skinId, (result) =>
            {
                if (result)
                {
                    currentLoadedBundleName = LWAssetBundleParser.TransferItemIdToBundleName(skinId);
                    string skinName         = LWAssetBundleParser.SplitsToSingleItemString(skinId)[1];
                    AssetBundle ab          = AssetBundleManager.GetAssetBundle(currentLoadedBundleName);
                    if (ab != null)
                    {
                        GameObject obj = Instantiate(ab.LoadAsset <GameObject>(skinName + "-inv"));
                        SetParentAndNormalize(obj.transform, root);
                        Debug.Log("Get AssetBundle success!");
                    }
                    else
                    {
                        Debug.Log("Get AssetBundle failed!");
                    }
                }
                else
                {
                    Debug.Log("Get AssetBundle failed!");
                }
            });
        }