private void AssetBundleStateChangedHandler(object x, AssetBundleStateChangedEventArgs eventarg)
        {
            Debug.Log("AssetBundleStateChangedHandler - " + eventarg.AssetBundleName + " - " + eventarg.State.ToString());
            if (!m_bundleQueue.ContainsKey(eventarg.AssetBundleName))
            {
                Debug.LogWarning("Asset bundle name " + eventarg.AssetBundleName + " not recognised, ignoring");
                return;
            }
            m_bundleQueue[eventarg.AssetBundleName].OnAssetBundleStateChanged(eventarg);

            m_sendAssetBundleLoadableEventOnMainThread |= eventarg.State == AssetBundleDownloadState.Loadable;
        }
Esempio n. 2
0
        public void OnAssetBundleStateChanged(AssetBundleStateChangedEventArgs eventArgs)
        {
            if (state != eventArgs.State && !IsBundleLoaded())
            {
                AssetBundleDownloadState oldState = state;
                if (state == AssetBundleDownloadState.NotBundled)
                {
                    Debug.LogError(String.Format("AssetBundle: {0} is not bundled but it's state is changing to {1}", m_assetBundleName, eventArgs.State));
                }
                //isretry is determined from errors in the state
                Debug.Log("State change: " + this + " > " + eventArgs.State + ", " + eventArgs.Error);
                if (eventArgs.IsRetry)
                {
                    downloadRetries++;
                    Debug.Log("OnAssetBundleStateChanged :: " + assetBundleName + " encountered an error. " + downloadRetries + "/3 errors encountered.");
                }
                if (downloadRetries >= 3)
                {
                    Debug.Log("OnAssetBundleStateChanged :: " + assetBundleName + " is assumed to be blocked after 3 retries.");
                    state = AssetBundleDownloadState.Blocked;
                    error = "Attempted download 3 times, failed each time. Stopping";
                    return;
                }
                state = eventArgs.State;
                error = eventArgs.Error;

                if (OnStateChanged != null)
                {
                    OnStateChanged(oldState, state);
                }
                //EventManager<Events>.Instance.TriggerEvent(Events.BundleStateChanged, this);
                if (state == AssetBundleDownloadState.Loadable)
                {
                    m_overrideDownloadPriority = DownloadPriority.Medium;
                    m_downloadPriority         = DownloadPriority.Medium;
                }
            }
        }