/// <summary>
        /// Creates a new <see cref="StreamingAssetsAdaptor" /> instance.
        /// </summary>
        public StreamingAssetsAdaptor(string assetBundleName, StreamingAssetsAdaptorOptions options, bool downloadOnly = false)
        {
            m_DownloadOnly = downloadOnly;

            if (AssetBundleLoader.Instance)
            {
                m_Coroutine = StreamingAssetsAdaptorImpl(assetBundleName, options);
                AssetBundleLoader.Instance.StartCoroutine(m_Coroutine);
            }
        }
        /// <summary>
        /// Loads the asset bundle.
        /// </summary>
        private IEnumerator StreamingAssetsAdaptorImpl(string assetBundleName, StreamingAssetsAdaptorOptions options)
        {
            if (string.IsNullOrEmpty(assetBundleName))
            {
                throw new System.ArgumentNullException("assetBundleName");
            }
            if (string.IsNullOrEmpty(options.StreamingAssetsPath))
            {
                throw new System.ArgumentNullException("options.StreamingAssetsPath");
            }

            m_AssetBundle     = null;
            m_AssetBundleName = assetBundleName;
            m_Error           = null;
            m_KeepWaiting     = true;

            // Skip any loading from the adaptor.
            if (m_DownloadOnly)
            {
                Debug.LogFormat("[StreamingAssetsAdaptor] Bundle loading skipped : {0}", assetBundleName);
                m_KeepWaiting = false;
                m_Progress    = 1;
                yield break;
            }

            // use AssetBundle.LoadFromFileAsync instead of WWW on iOS and tvOS

#if UNITY_IOS || UNITY_TVOS
            Debug.LogFormat("[StreamingAssetsAdaptor] Load asset bundle : {0}", assetBundleName);
            m_AssetBundleCreateRequest = AssetBundle.LoadFromFileAsync(options.GetAssetBundlePath(assetBundleName));
            while (!m_AssetBundleCreateRequest.isDone)
            {
                m_Progress = m_AssetBundleCreateRequest.progress;
                yield return(null);
            }

            if (m_AssetBundleCreateRequest.assetBundle == null)
            {
                m_AssetBundle = null;
                m_AssetBundleCreateRequest = null;
                m_Error       = string.Format("Could not load asset bundle from file: {0}", options.GetAssetBundlePath(assetBundleName));
                m_KeepWaiting = false;
                m_Progress    = -1;
                yield break;
            }

            m_AssetBundle = m_AssetBundleCreateRequest.assetBundle;
            m_AssetBundleCreateRequest = null;
            m_Error       = null;
            m_KeepWaiting = false;
            m_Progress    = 1;
            yield break;
                        #else
                                #if UNITY_EDITOR
            // Getting streaming assets path when playing from the editor but have set "Platform" to Android derivative.
            m_WWW = new WWW("file://" + options.GetAssetBundlePath(assetBundleName));
                                #else
            // Getting path to Android streaming assets when on an Android device.
            m_WWW = new WWW(options.GetAssetBundlePath(assetBundleName));
                                #endif
            Debug.LogFormat("StreamingAssetsAdaptor-> StreamingAssetsAdaptorImpl: Getting asset bundle path from {0}", m_WWW.url);
            while (!m_WWW.isDone)
            {
                m_Progress = m_WWW.progress;
                yield return(null);
            }

            if (!string.IsNullOrEmpty(m_WWW.error))
            {
                m_AssetBundle = null;
                m_Error       = m_WWW.error;
                m_KeepWaiting = false;
                m_Progress    = -1;
                m_WWW.Dispose();
                m_WWW = null;
                yield break;
            }

            m_AssetBundle = m_WWW.assetBundle;
            m_Error       = null;
            m_KeepWaiting = false;
            m_Progress    = 1;
            m_WWW.Dispose();
            m_WWW = null;
            yield break;
                        #endif
        }