Exemple #1
0
    IEnumerator LoadAllAssetsFromBundleCR <T>(string bundleName, ReceiveObjectDelegate <T[]> sendEvent, string key, bool lockLoadingScreen, int assetKey) where T : Object
    {
        bool load = true;

        if (!bundleDict.ContainsKey(bundleName))
        {
            Coroutine cr = null;
            LoadAssetBundleAsync(bundleName, lockLoadingScreen, out cr);
            load = cr != null;
            yield return(cr);
        }

        if (load)
        {
            var req = bundleDict[bundleName].LoadAllAssetsAsync <T>();
            yield return(req);            // Wait for request to finish

            // Send object out
            var obj = req.allAssets as T[];
            if (sendEvent != null)
            {
                sendEvent(obj, assetKey);
            }
        }
        else
        {
            Debug.LogError("Could not load assets from bundle '" + bundleName);
        }

        //if (lockLoadingScreen)
        //	LoadingScreen.GetActiveLoadingScreen().RemoveLoadingLocker(key);
    }
Exemple #2
0
        public T ReceiveObject <T>(ReceiveObjectDelegate <T> action) where T : class
        {
            var retval = default(T);

            if (!action(out retval))
            {
                return(default(T));
            }
            if (retval == null)
            {
                return(default(T));
            }
            RegisterObject(retval);
            return(retval);
        }
Exemple #3
0
    public static Coroutine LoadAllObjectsInBundleAsync <T>(string bundleName, ReceiveObjectDelegate <T[]> receiver, bool lockLoadingScreen, int assetKey) where T : Object
    {
        string key = "";

        //if (lockLoadingScreen)
        //{
        //	var loadingScreen = LoadingScreen.GetActiveLoadingScreen();
        //	if (loadingScreen != null)
        //	{
        //		key = bundleName + instance.GetInstanceID();
        //		loadingScreen.SetLoadingLocker(key);
        //		return instance.StartCoroutine(instance.LoadAllAssetsFromBundleCR(bundleName, receiver, key, lockLoadingScreen, assetKey));
        //	}
        //}
        return(instance.StartCoroutine(instance.LoadAllAssetsFromBundleCR(bundleName, receiver, key, lockLoadingScreen, assetKey)));
    }