Пример #1
0
        protected IEnumerator LoadAssetBundleLoadAllAssets(string assetBundleName, Action <UnityEngine.Object[]> callback)
        {
#if ASSET_LOG
            Debug.Log("Start to load " + assetBundleName + " at frame " + Time.frameCount);
#endif

            AssetBundleLoadAllAssetsOperation request = AssetBundleManager.LoadAssetBundleLoadAllAssetsAsync(assetBundleName);
            if (request == null)
            {
                yield break;
            }
            yield return(StartCoroutine(request));

            if (callback != null)
            {
                callback(request.GetAssets <UnityEngine.Object>());
            }
        }
Пример #2
0
        static public AssetBundleLoadAllAssetsOperation LoadAssetBundleLoadAllAssetsAsync(string assetBundleName)
        {
            AssetBundleLoadAllAssetsOperation operation = null;

#if UNITY_EDITOR
            if (SimulateAssetBundleInEditor)
            {
                string[] assetBundlePaths = AssetDatabase.GetAssetPathsFromAssetBundle(assetBundleName);
                if (assetBundlePaths.Length == 0)
                {
                    ///@TODO: The error needs to differentiate that an asset bundle name doesn't exist
                    //        from that there right scene does not exist in the asset bundle...

                    Debug.LogError("There is no asset bundle with name \"" + assetBundleName + "\"");
                    return(null);
                }

                Object[] assets = new Object[assetBundlePaths.Length];

                for (int i = 0, count = assetBundlePaths.Length; i < count; ++i)
                {
                    string assetPath = assetBundlePaths[i];
                    assets[i] = AssetDatabase.LoadAssetAtPath <Object>(assetPath);
                }
                operation = new AssetBundleLoadAllAssetsOperationSimulation(assets);
            }
            else
#endif
            {
                LoadAssetBundle(assetBundleName);
                operation = new AssetBundleLoadAllAssetsOperationFull(assetBundleName);

                m_InProgressOperations.Add(operation);
            }

            return(operation);
        }