Ejemplo n.º 1
0
 void DownloadRemoteAssetPack(string assetPackName)
 {
     // Note that most methods in the AndroidAssetPacks class are either direct wrappers of java APIs in Google's PlayCore plugin,
     // or depend on values that the PlayCore API returns. If the PlayCore plugin is missing, calling these methods will throw an InvalidOperationException exception.
     try
     {
         AndroidAssetPacks.DownloadAssetPackAsync(new string[] { assetPackName }, CheckDownloadStatus);
     }
     catch (InvalidOperationException ioe)
     {
         Debug.LogError($"Cannot retrieve state for asset pack '{assetPackName}'. PlayCore Plugin is not installed: {ioe.Message}");
         m_ProviderInterface.Complete(this, false, new Exception("exception"));
     }
 }
Ejemplo n.º 2
0
        void CheckDownloadStatus(AndroidAssetPackInfo info)
        {
            string message = "";

            if (info.status == AndroidAssetPackStatus.Failed)
            {
                message = $"Failed to retrieve the state of asset pack '{info.name}'.";
            }
            else if (info.status == AndroidAssetPackStatus.Unknown)
            {
                message = $"Asset pack '{info.name}' is unavailable for this application. This can occur if the app was not installed through Google Play.";
            }
            else if (info.status == AndroidAssetPackStatus.Canceled)
            {
                message = $"Cancelled asset pack download request '{info.name}'.";
            }
            else if (info.status == AndroidAssetPackStatus.WaitingForWifi)
            {
                AndroidAssetPacks.RequestToUseMobileDataAsync(OnRequestToUseMobileDataComplete);
            }
            else if (info.status == AndroidAssetPackStatus.Completed)
            {
                string assetPackPath = AndroidAssetPacks.GetAssetPackPath(info.name);

                if (!string.IsNullOrEmpty(assetPackPath))
                {
                    // Asset pack was located on device. Proceed with loading the bundle.
                    PlayAssetDeliveryRuntimeData.Instance.AssetPackNameToDownloadPath.Add(info.name, assetPackPath);
                    base.Provide(m_ProviderInterface);
                }
                else
                {
                    message = $"Downloaded asset pack '{info.name}' but cannot locate it on device.";
                }
            }

            if (!string.IsNullOrEmpty(message))
            {
                Debug.LogError(message);
                m_ProviderInterface.Complete(this, false, new Exception("exception"));
            }
        }
Ejemplo n.º 3
0
 void LoadFromAssetPacksIfAvailable()
 {
     if (AndroidAssetPacks.coreUnityAssetPacksDownloaded)
     {
         // Core Unity asset packs use install-time delivery and are already installed.
         DownloadCustomAssetPacksData();
     }
     else
     {
         // Core Unity asset packs use fast-follow or on-demand delivery and need to be downloaded.
         string[] coreUnityAssetPackNames = AndroidAssetPacks.GetCoreUnityAssetPackNames(); // only returns names of asset packs that are fast-follow or on-demand delivery
         if (coreUnityAssetPackNames.Length == 0)
         {
             CompleteOverride("Cannot retrieve core Unity asset pack names. PlayCore Plugin is not installed.");
         }
         else
         {
             AndroidAssetPacks.DownloadAssetPackAsync(coreUnityAssetPackNames, CheckDownloadStatus);
         }
     }
 }
Ejemplo n.º 4
0
 void CheckDownloadStatus(AndroidAssetPackInfo info)
 {
     if (info.status == AndroidAssetPackStatus.Failed)
     {
         CompleteOverride($"Failed to retrieve the state of asset pack '{info.name}'.");
     }
     else if (info.status == AndroidAssetPackStatus.Unknown)
     {
         CompleteOverride($"Asset pack '{info.name}' is unavailable for this application. This can occur if the app was not installed through Google Play.");
     }
     else if (info.status == AndroidAssetPackStatus.Canceled)
     {
         CompleteOverride($"Cancelled asset pack download request '{info.name}'.");
     }
     else if (info.status == AndroidAssetPackStatus.WaitingForWifi)
     {
         AndroidAssetPacks.RequestToUseMobileDataAsync(result =>
         {
             if (!result.allowed)
             {
                 CompleteOverride("Request to use mobile data was denied.");
             }
         });
     }
     else if (info.status == AndroidAssetPackStatus.Completed)
     {
         string assetPackPath = AndroidAssetPacks.GetAssetPackPath(info.name);
         if (string.IsNullOrEmpty(assetPackPath))
         {
             CompleteOverride($"Downloaded asset pack '{info.name}' but cannot locate it on device.");
         }
         else if (AndroidAssetPacks.coreUnityAssetPacksDownloaded)
         {
             DownloadCustomAssetPacksData();
         }
     }
 }