Beispiel #1
0
        static public IEnumerator LoadInResourcePackedAsset <T>(string assetBundleName, string resourcePath, System.Action <T> callback) where T : UnityEngine.Object
        {
            assetBundleName = assetBundleName.ToLower();

            AssetBundleLoadAssetOperation operation;

            if (m_AssetBundleManifest == null || string.IsNullOrEmpty(m_AssetBundleManifest.GetAllAssetBundles().FirstOrDefault(s => s == assetBundleName)))
            {
                operation = new ResourceLoadAssetOperationFull(resourcePath);
            }
            else
            {
                assetBundleName = RemapVariantName(assetBundleName);
                LoadAssetBundle(assetBundleName);
                operation = new AssetBundleLoadAssetOperationFull(assetBundleName, Path.GetFileNameWithoutExtension(resourcePath), typeof(T));
            }
            m_InProgressOperations.Add(operation);

            yield return(sInstance.StartCoroutine(operation));

            if (callback != null)
            {
                callback(operation.GetAsset <T>());
            }
        }
Beispiel #2
0
        static public IEnumerator LoadInResourceAssetAsync <T>(string resourcePath, System.Action <T> callback) where T : UnityEngine.Object
        {
            AssetBundleLoadAssetOperation operation;
            string assetBundleName = GetAssetBundleName(resourcePath);

            if (string.IsNullOrEmpty(assetBundleName))
            {
                operation = new ResourceLoadAssetOperationFull(resourcePath);
            }
            else
            {
                assetBundleName = RemapVariantName(assetBundleName);
                LoadAssetBundle(assetBundleName);
                operation = new AssetBundleLoadAssetOperationFull(assetBundleName, Path.GetFileNameWithoutExtension(resourcePath), typeof(T));
            }

            m_InProgressOperations.Add(operation);

            yield return(sInstance.StartCoroutine(operation));

            if (callback != null)
            {
                callback(operation.GetAsset <T>());
            }
        }