示例#1
0
 static public int MoveNext(IntPtr l)
 {
     try {
                     #if DEBUG
         var    method     = System.Reflection.MethodBase.GetCurrentMethod();
         string methodName = GetMethodName(method);
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.BeginSample(methodName);
                     #else
         Profiler.BeginSample(methodName);
                     #endif
                     #endif
         AssetBundleLoadOperation self = (AssetBundleLoadOperation)checkSelf(l);
         var ret = self.MoveNext();
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
             #if DEBUG
     finally {
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.EndSample();
                     #else
         Profiler.EndSample();
                     #endif
     }
             #endif
 }
        IEnumerator <YieldInstruction> InitializeAndThenLoadSceneIntoLevel(string assetBundleName, string sceneName)
        {
#if DLK_AssetBundleIntegrationEnabled
            initialized = true;

            if (variantPossibilities != null && variantPossibilities.Length > 0)
            {
                SetVariant(activeVariant);
            }
            else
            {
                variantPossibilities = null;
                activeVariant        = null;
            }

            AssetBundleManager.logMode = logMode == AssetBundleManagerLogMode.All ? AssetBundleManager.LogMode.All : AssetBundleManager.LogMode.JustErrors;

            if (streamingType == StreamingType.SimulationModeOrLocalAssetServer)
            {
                AssetBundleManager.SetDevelopmentAssetBundleServer();
            }
            else if (streamingType == StreamingType.StreamingAssetsFolder)
            {
                AssetBundleManager.SetSourceAssetBundleURL("file:///" + Application.streamingAssetsPath + "/");
            }
            else
            {
                AssetBundleManager.SetSourceAssetBundleURL(serverURL);
            }

            // Initialize AssetBundleManifest which loads the AssetBundleManifest object.
            var initializeRequest = AssetBundleManager.Initialize();

            if (initializeRequest != null)
            {
                while (initializeRequest.MoveNext())
                {
                    yield return(null);
                }
            }

            AssetBundleLoadOperation levelLoadRequest = AssetBundleManager.LoadLevelAsync(assetBundleName, sceneName, true);

            if (levelLoadRequest != null)
            {
                while (levelLoadRequest.MoveNext())
                {
                    yield return(null);//request.Current just returns null, so we can do that instead
                }
                AssetBundleManager.UnloadAssetBundle(assetBundleName);
            }
            else
            {
                Debug.Log("Could not load level " + assetBundleName + " Asset Bundle.");
                yield break;
            }
#else
            throw new NotImplementedException("You must enable Asset Bundle Integration to utilize the Asset Bundle Loader.");
#endif
        }
        IEnumerator <YieldInstruction> LoadSceneIntoLevel(string assetBundleName, string sceneName)
        {
#if DLK_AssetBundleIntegrationEnabled
            AssetBundleLoadOperation request = AssetBundleManager.LoadLevelAsync(assetBundleName, sceneName, true);

            if (request != null)
            {
                while (request.MoveNext())
                {
                    yield return(null);//request.Current just returns null, so we can do that instead
                }
                AssetBundleManager.UnloadAssetBundle(assetBundleName);
            }
            else
            {
                Debug.Log("Could not load level " + assetBundleName + " Asset Bundle.");
                yield break;
            }
#else
            throw new NotImplementedException("You must enable Asset Bundle Integration to utilize the Asset Bundle Loader.");
#endif
        }