public ResourceQueryYieldInstruction(MonoBehaviour monoBehaviour, params string[] resourceTags)
        {
            m_MonoBehaviour       = null;
            m_IsDone              = false;
            m_IsResourceAvailable = false;
            if (monoBehaviour != null)
            {
                m_MonoBehaviour = monoBehaviour;

                if (!m_ResourceQueryContainer.ContainsValue(this))
                {
                    m_ResourceQueryContainer.Add(this.GetHashCode(), this);
                                        #if SAGO_IOS && !UNITY_EDITOR
                    string[] versionedResourceTags = resourceTags.Select(tag => PlatformUtil.AppendVersion(tag)).ToArray();
                    _CheckResourceAvailability(this.GetHashCode(), versionedResourceTags, versionedResourceTags.Length, ResourceQueryCallback);
                                        #endif
                }
            }
            else
            {
                m_IsDone = true;
                Debug.LogError("ResourcesQueryYieldInstruction-> MonoBehaviour reference passed is null.", DebugContext.SagoApp);
            }
        }
示例#2
0
        /// <summary>
        /// Creates an <see cref="IAssetBundleAdaptor" /> object for the specified asset bundle.
        /// </summary>
        /// <param name="assetBundleName">
        /// The name of the asset bundle.
        /// </param>
        public IAssetBundleAdaptor CreateAdaptor(string assetBundleName, bool downloadOnly = false)
        {
            AssetBundleAdaptorType adaptorType;

            adaptorType = GetAdaptorType(assetBundleName);

            Debug.LogFormat(DebugContext.SagoApp, "Creating an adaptor type [{0}] for asset bundle: {1}", adaptorType.ToString(), assetBundleName);
            switch (adaptorType)
            {
            case AssetBundleAdaptorType.StreamingAssets: {
                return(new StreamingAssetsAdaptor(assetBundleName, new StreamingAssetsAdaptorOptions()
                    {
                        StreamingAssetsPath = (
                            Application.isEditor ?
                            Path.Combine(Application.dataPath, "Project/AssetBundles/StreamingAssets") :
                            Application.streamingAssetsPath
                            )
                    },
                                                  downloadOnly));
            }

            case AssetBundleAdaptorType.OnDemandResources: {
                                        #if UNITY_EDITOR
                // OnDemandResources don't work in the editor...
                return(new StreamingAssetsAdaptor(assetBundleName, new StreamingAssetsAdaptorOptions()
                    {
                        StreamingAssetsPath = (
                            Application.isEditor ?
                            Path.Combine(Application.dataPath, "Project/AssetBundles/OnDemandResources") :
                            Application.streamingAssetsPath
                            )
                    },
                                                  downloadOnly));
                                        #else
                return(new LowDiskSpaceAssetBundleAdaptor(new OnDemandResourcesAdaptor(assetBundleName, downloadOnly, (string name) => PlatformUtil.AppendVersion(name))));
                                        #endif
            }

            case AssetBundleAdaptorType.AssetBundleServer: {
                return(new ServerAdaptor(assetBundleName, new ServerAdaptorOptions()
                    {
                        Token = m_ServerAdaptorOptions.Token,
                        Url = m_ServerAdaptorOptions.Url
                    }));
            }
            }

            return(null);
        }