Inheritance: YieldInstruction
Beispiel #1
12
 public override void OnEnter()
 {
     if (this.dontDestroyOnLoad.Value)
     {
         Transform root = base.Owner.transform.root;
         UnityEngine.Object.DontDestroyOnLoad(root.gameObject);
     }
     if (this.additive)
     {
         if (this.async)
         {
             this.asyncOperation = Application.LoadLevelAdditiveAsync(this.levelName.Value);
             Debug.Log("LoadLevelAdditiveAsyc: " + this.levelName.Value);
             return;
         }
         Application.LoadLevelAdditive(this.levelName.Value);
         Debug.Log("LoadLevelAdditive: " + this.levelName.Value);
     }
     else
     {
         if (this.async)
         {
             this.asyncOperation = Application.LoadLevelAsync(this.levelName.Value);
             Debug.Log("LoadLevelAsync: " + this.levelName.Value);
             return;
         }
         Application.LoadLevel(this.levelName.Value);
         Debug.Log("LoadLevel: " + this.levelName.Value);
     }
     this.Log("LOAD COMPLETE");
     base.Fsm.Event(this.loadedEvent);
     base.Finish();
 }
 IEnumerator LoadScene(string vSceneName, ChangeSceneOver vChangeOver)
 {
     // modify by Conglin
     //Application.LoadLevelAsync(vSceneName);
     mLoadingState = UnityEngine.SceneManagement.SceneManager.LoadSceneAsync(vSceneName, UnityEngine.SceneManagement.LoadSceneMode.Single);
     //ResourceLoadManager.Instance.UnloadDependAB();
     if (null == mLoadingState)
     {
         yield break;
     }
     else
     {
         _BeforeSceneName = _NowSceneName;
         _NowSceneName    = vSceneName;
         HintManager.Instance.OpenLoad();
     }
     _crrentSceneState = LoadSceneState.Loading;
     while (!mLoadingState.isDone)
     {
         yield return(0);
     }
     if (ChangeOver != null)
     {
         ChangeOver(vSceneName);
         ChangeOver -= vChangeOver;
     }
     PlayerSceneMusic(vSceneName);
     _crrentSceneState = LoadSceneState.NotLoading;
     HintManager.Instance.CloseLoad();
     mLoadingState = null;
 }
Beispiel #3
0
    //This takes some time (do this stuff by default, this stuff should be remvoed later one bcause the prefabs will be setup naturally like this, run through a loop and have a settings that it iwll be applied to all)
    private void LoadTerrain(UnityEngine.AsyncOperation op)
    {
        Scene s = SceneManager.GetSceneByName(terrainID + "_Scene");

        loadedTerrain = s.GetRootGameObjects()[0].GetComponent <NoiseGenerator>();
        loadedTerrain.overrideEditing = TerrainManager.instance.editingTerrain;
        loadedTerrain.GetComponent <NoiseGenerator>().enabled = TerrainManager.instance.editingTerrain;
        Debug.LogWarning("LOD Group Hasn't been removed for all prefabs...");
        if (loadedTerrain.transform.GetChild(0).GetComponent <LODGroup>() != null)
        {
            loadedTerrain.transform.GetChild(0).GetComponent <LODGroup>().enabled = false;
        }
        loadedTerrain.transform.GetChild(0).GetChild(1).gameObject.SetActive(true);
        loadedTerrain.transform.GetChild(0).GetChild(0).gameObject.SetActive(false);
        loadedTerrain.transform.GetChild(0).GetChild(2).gameObject.SetActive(false);

        if (tempCallback != null)
        {
            tempCallback.Invoke(s, tempArgs, "");
        }

        if (loadedTerrain != null)
        {
            loadedTerrain.terrainID = terrainID;

            loaded           = true;
            tempPlayingScene = s;
        }
        else if (loadedTerrain == null)
        {
            Debug.LogError("Scene was not loaded?");
            loaded = false;
        }
    }
    static int _CreateUnityEngine_AsyncOperation(IntPtr L)
    {
#if UNITY_EDITOR
        ToluaProfiler.AddCallRecord("UnityEngine.AsyncOperation.ctor");
#endif
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 0)
            {
                UnityEngine.AsyncOperation obj = new UnityEngine.AsyncOperation();
                ToLua.PushObject(L, obj);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to ctor method: UnityEngine.AsyncOperation.New"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Beispiel #5
0
// fields

// properties
    static void AsyncOperation_isDone(JSVCall vc)
    {
        UnityEngine.AsyncOperation _this = (UnityEngine.AsyncOperation)vc.csObj;
        var result = _this.isDone;

        JSApi.setBooleanS((int)JSApi.SetType.Rval, (System.Boolean)(result));
    }
Beispiel #6
0
        public virtual void ServerChangeScene(string newSceneName, LoadSceneMode sceneMode, LocalPhysicsMode physicsMode)
        {
            if (string.IsNullOrEmpty(newSceneName))
            {
                Debug.LogError("ServerChangeScene empty scene name");
                return;
            }

            if (LogFilter.Debug)
            {
                Debug.Log("ServerChangeScene " + newSceneName);
            }
            NetworkServer.SetAllClientsNotReady();
            networkSceneName = newSceneName;

            LoadSceneParameters loadSceneParameters = new LoadSceneParameters(sceneMode, physicsMode);

            loadingSceneAsync = SceneManager.LoadSceneAsync(newSceneName, loadSceneParameters);

            SceneMessage msg = new SceneMessage()
            {
                sceneName   = newSceneName,
                sceneMode   = loadSceneParameters.loadSceneMode,
                physicsMode = loadSceneParameters.localPhysicsMode
            };

            NetworkServer.SendToAll(msg);

            startPositionIndex = 0;
            startPositions.Clear();
        }
Beispiel #7
0
 public void Call(UnityEngine.AsyncOperation param0)
 {
     func.BeginPCall();
     func.PushObject(param0);
     func.PCall();
     func.EndPCall();
 }
 static public int get_progress(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
         UnityEngine.AsyncOperation self = (UnityEngine.AsyncOperation)checkSelf(l);
         pushValue(l, true);
         pushValue(l, self.progress);
         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
 }
 static public int set_allowSceneActivation(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
         UnityEngine.AsyncOperation self = (UnityEngine.AsyncOperation)checkSelf(l);
         bool v;
         checkType(l, 2, out v);
         self.allowSceneActivation = v;
         pushValue(l, true);
         return(1);
     }
     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
 }
Beispiel #10
0
        // 滚动流畅的版本,但是,可能会拖慢加载时间
        IEnumerator LoadScene()
        {
            float curProcess = 0.0f;

            m_Async = Application.LoadLevelAsync(Global.g_MainScene);
            m_Async.allowSceneActivation = false;

            while(m_Async.progress < 0.9f &&
                  curProcess <m_Async.progress)
            {
                curProcess += 0.01f;
                // 显示进度小于当前进度时,不断地累加
                m_BarControl.OnValueChange(curProcess, "");

                yield return new WaitForEndOfFrame();
            }

            while(curProcess < 1.0f)
            {
                curProcess += 0.01f;
                m_BarControl.OnValueChange(curProcess, "");

                yield return new WaitForEndOfFrame();
            }
            m_Async.allowSceneActivation = true;
        }
    static int set_completed(IntPtr L)
    {
        try
        {
            UnityEngine.AsyncOperation obj = (UnityEngine.AsyncOperation)ToLua.CheckObject(L, 1, typeof(UnityEngine.AsyncOperation));
            EventObject arg0 = null;

            if (LuaDLL.lua_isuserdata(L, 2) != 0)
            {
                arg0 = (EventObject)ToLua.ToObject(L, 2);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "The event 'UnityEngine.AsyncOperation.completed' can only appear on the left hand side of += or -= when used outside of the type 'UnityEngine.AsyncOperation'"));
            }

            if (arg0.op == EventOp.Add)
            {
                System.Action <UnityEngine.AsyncOperation> ev = (System.Action <UnityEngine.AsyncOperation>)arg0.func;
                obj.completed += ev;
            }
            else if (arg0.op == EventOp.Sub)
            {
                System.Action <UnityEngine.AsyncOperation> ev = (System.Action <UnityEngine.AsyncOperation>)arg0.func;
                obj.completed -= ev;
            }

            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
        /// <summary>
        /// 卸载场景
        /// </summary>
        /// <param name="levelName">要卸载场景的名字</param>
        /// <param name="endUnload">结束卸载</param>
        /// <param name="startUnload">开始卸载</param>
        public IEnumerator UnloadScene(string levelName, Action _startUnload = null, Action <float> _updateUnload = null, Action _endUnload = null)
        {
            UnityEngine.AsyncOperation asyncOperation = default(UnityEngine.AsyncOperation);
            try
            {
                asyncOperation            = UnityEngine.SceneManagement.SceneManager.UnloadSceneAsync(levelName);
                asyncOperation.completed += AsyncUnload_completed;;

                startUnload  = _startUnload;
                updateUnload = _updateUnload;
                endUnload    = _endUnload;
                startUnload?.Invoke();
            }
            catch (Exception ex)
            {
                UnityEngine.Debug.Log("错误:活动场景中不存在场景==" + levelName + "====" + ex.Data);
                GC.Collect();
                Resources.UnloadUnusedAssets();
            }
            if (asyncOperation != null)
            {
                while (!asyncOperation.isDone)
                {
                    updateUnload?.Invoke(asyncOperation.progress);
                    yield return(new WaitForFixedUpdate());
                }
            }

            yield return(null);
        }
        public override void OnUpdate()
        {
            //	Debug.Log(asyncOperation.isDone);

            if (asyncOperation ==null || asyncOperation.isDone )
            {
                Debug.Log(state);

                if (state == loadState.LoadBase)
                {
                    LogDebug("UnloadUnusedAssets");
                    state = loadState.UnloadUnusedResources;
                    asyncOperation = null;
                    asyncOperation =  Resources.UnloadUnusedAssets();

                }else if (state == loadState.UnloadUnusedResources)
                {
                    LogDebug("loading level :"+levelName.Value);
                    state = loadState.LoadLevel;
                    asyncOperation = null;
                    asyncOperation = Application.LoadLevelAdditiveAsync(levelName.Value);

                }else if (state == loadState.LoadLevel)
                {
                    LogDebug("loading done");

                    Fsm.Event(loadedEvent);
                    Finish();
                }
            }
        }
            void OnGetAuthSignature(AsyncOperation op)
            {
                if (op.isDone && (m_AuthSignatureRequest != null) && m_AuthSignatureRequest.downloadHandler.isDone)
                {
                    if ((m_AuthSignatureRequest.result != UnityWebRequest.Result.ProtocolError) && (m_AuthSignatureRequest.result != UnityWebRequest.Result.ConnectionError))
                    {
                        var jsonParser = new JSONParser(m_AuthSignatureRequest.downloadHandler.text);
                        try
                        {
                            var json = jsonParser.Parse();

                            m_ProjectAuthSignature = json.AsDict()[k_JsonKeyAuthSignature].AsString();
                            if (m_SettingKey)
                            {
                                SubmitGooglePlayKey();
                            }
                            else
                            {
                                RetrieveGooglePlayKey();
                            }
                        }
                        catch (Exception ex)
                        {
                            NotificationManager.instance.Publish(provider.serviceInstance.notificationTopic, Notification.Severity.Error,
                                                                 string.Format(L10n.Tr(k_AuthSignatureExceptionMessage), Connect.UnityConnect.instance.projectInfo.projectName, ex.Message));

                            Debug.LogException(ex);
                        }
                    }

                    m_AuthSignatureRequest.Dispose();
                    m_AuthSignatureRequest = null;
                }
            }
    /// <summary>
    /// 加载目标场景
    /// </summary>
    /// <param name="targetSceneName">目标场景</param>
    /// <returns></returns>
    private IEnumerator LoadSceneAsync(string targetSceneName)
    {
        float t1 = SceneMask.Show(false);

        yield return(new WaitForSeconds(t1));

        m_SceneAsyncOperation = SceneManager.LoadSceneAsync(SceneName.IntermediaScene);
        m_SceneAsyncOperation.allowSceneActivation = true;


        //yield return new WaitForSeconds(3f);
        //等待中间场景
        while (!m_SceneAsyncOperation.isDone)
        {
            yield return(null);
        }
        //加载目标场景
        m_SceneAsyncOperation = SceneManager.LoadSceneAsync(targetSceneName);

        while (!m_SceneAsyncOperation.isDone)
        {
            yield return(null);
            //m_SceneAsyncOperation.progress
        }

        m_CurrentSceneName = targetSceneName;

        //隐藏SceneMask,StartScene比较特殊,不隐藏SceneMask。
        if (m_CurrentSceneName != SceneName.StartScene)
        {
            SceneMask.Hide(false);
        }
    }
Beispiel #16
0
    static int QPYX_set_completed_YXQP(IntPtr L_YXQP)
    {
        try
        {
            UnityEngine.AsyncOperation QPYX_obj_YXQP = (UnityEngine.AsyncOperation)ToLua.CheckObject(L_YXQP, 1, typeof(UnityEngine.AsyncOperation));
            EventObject QPYX_arg0_YXQP = null;
            if (LuaDLL.lua_isuserdata(L_YXQP, 2) != 0)
            {
                QPYX_arg0_YXQP = (EventObject)ToLua.ToObject(L_YXQP, 2);
            }
            else
            {
                return(LuaDLL.luaL_throw(L_YXQP, "The event 'UnityEngine.AsyncOperation.completed' can only appear on the left hand side of += or -= when used outside of the type 'UnityEngine.AsyncOperation'"));
            }

            if (QPYX_arg0_YXQP.op == EventOp.Add)
            {
                System.Action <UnityEngine.AsyncOperation> QPYX_ev_YXQP = (System.Action <UnityEngine.AsyncOperation>)QPYX_arg0_YXQP.func;
                QPYX_obj_YXQP.completed += QPYX_ev_YXQP;
            }
            else if (QPYX_arg0_YXQP.op == EventOp.Sub)
            {
                System.Action <UnityEngine.AsyncOperation> QPYX_ev_YXQP = (System.Action <UnityEngine.AsyncOperation>)QPYX_arg0_YXQP.func;
                QPYX_obj_YXQP.completed -= QPYX_ev_YXQP;
            }

            return(0);
        }
        catch (Exception e_YXQP)                {
            return(LuaDLL.toluaL_exception(L_YXQP, e_YXQP));
        }
    }
 static public int LoadLevelAsync_s(IntPtr l)
 {
     try{
         if (matchType(l, 1, typeof(System.Int32)))
         {
             System.Int32 a1;
             checkType(l, 1, out a1);
             UnityEngine.AsyncOperation ret = UnityEngine.Application.LoadLevelAsync(a1);
             pushValue(l, ret);
             return(1);
         }
         else if (matchType(l, 1, typeof(System.String)))
         {
             System.String a1;
             checkType(l, 1, out a1);
             UnityEngine.AsyncOperation ret = UnityEngine.Application.LoadLevelAsync(a1);
             pushValue(l, ret);
             return(1);
         }
         LuaDLL.luaL_error(l, "No matched override function to call");
         return(0);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
Beispiel #18
0
        internal void ClientChangeScene(string newSceneName, LoadSceneMode sceneMode, LocalPhysicsMode physicsMode)
        {
            if (string.IsNullOrEmpty(newSceneName))
            {
                Debug.LogError("ClientChangeScene empty scene name");
                return;
            }

            if (LogFilter.Debug)
            {
                Debug.Log("ClientChangeScene newSceneName:" + newSceneName + " networkSceneName:" + networkSceneName);
            }

            // vis2k: pause message handling while loading scene. otherwise we will process messages and then lose all
            // the state as soon as the load is finishing, causing all kinds of bugs because of missing state.
            // (client may be null after StopClient etc.)
            if (LogFilter.Debug)
            {
                Debug.Log("ClientChangeScene: pausing handlers while scene is loading to avoid data loss after scene was loaded.");
            }
            Transport.activeTransport.enabled = false;

            // Let client prepare for scene change
            OnClientChangeScene(newSceneName);

            loadingSceneAsync = SceneManager.LoadSceneAsync(newSceneName, new LoadSceneParameters()
            {
                loadSceneMode    = sceneMode,
                localPhysicsMode = physicsMode,
            });
            networkSceneName = newSceneName; //This should probably not change if additive is used
        }
Beispiel #19
0
    static int LoadLevelAdditiveAsync(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 1 && TypeChecker.CheckTypes(L, typeof(string)))
            {
                string arg0 = ToLua.ToString(L, 1);
                UnityEngine.AsyncOperation o = UnityEngine.Application.LoadLevelAdditiveAsync(arg0);
                ToLua.PushObject(L, o);
                return(1);
            }
            else if (count == 1 && TypeChecker.CheckTypes(L, typeof(int)))
            {
                int arg0 = (int)LuaDLL.lua_tonumber(L, 1);
                UnityEngine.AsyncOperation o = UnityEngine.Application.LoadLevelAdditiveAsync(arg0);
                ToLua.PushObject(L, o);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: UnityEngine.Application.LoadLevelAdditiveAsync"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Beispiel #20
0
        IEnumerator SendInit()
        {
            UnityWebRequest request = UnityWebRequest.Get(this.hostNameFull);

            UnityEngine.AsyncOperation async = request.Send();
            yield return(async);
        }
Beispiel #21
0
    static void AsyncOperation_progress(JSVCall vc)
    {
        UnityEngine.AsyncOperation _this = (UnityEngine.AsyncOperation)vc.csObj;
        var result = _this.progress;

        JSApi.setSingle((int)JSApi.SetType.Rval, (System.Single)(result));
    }
        public IEnumerator Init()
        {
            #if UNITY_EDITOR
            if (AssetBundleUtility.SimulateAssetBundleInEditor)
            {
                yield break;
            }
            #endif
            if (mAssetBundleManifest != null)
            {
                Resources.UnloadAsset(mAssetBundleManifest);
                mAssetBundleManifest = null;
            }
            LoadSceneAsyncOpe = null;
            mAssetBundleInfos = null;
            UnloadAllAssetBundles(true);

            //解析version文件
            string error = "";
            Int64 versionID;
            byte[] versionBytes = File.ReadAllBytes(Path.Combine(AssetBundleUtility.LocalAssetBundlePath, AssetBundleUtility.VersionFileName));
            if (!AssetBundleUtility.ResolveEncryptedVersionData(versionBytes, ref mAssetBundleInfos, out versionID, out error))
            {
                Debug.LogErrorFormat("resolve version file failed: {0}", error);
                yield break;
            }

            //加载Manifest
            AssetBundleCreateRequest bundleRequest = AssetBundle.LoadFromFileAsync(AssetBundleName2FilePath(AssetBundleUtility.GetPlatformName() + AssetBundleUtility.AssetBundleExtension));
            yield return bundleRequest;
            AssetBundleRequest assetRequest = bundleRequest.assetBundle.LoadAssetAsync<AssetBundleManifest>("AssetBundleManifest");
            yield return assetRequest;
            mAssetBundleManifest = assetRequest.asset as AssetBundleManifest;
            bundleRequest.assetBundle.Unload(false);
        }
		/// <summary>
		/// Loads the target scene asynchronously.
		/// </summary>
		/// <returns>The async.</returns>
		protected virtual IEnumerator LoadAsync() {
			//set up the elements in the scene
			LoadingSceneSetup ();

			//start loading scene
			asyncOperation = SceneManager.LoadSceneAsync (sceneToLoad, LoadSceneMode.Single);
			asyncOperation.allowSceneActivation = false;

			//while scene loads, assign operation progress to a float to use to fill the progress bar smoothly
			while (asyncOperation.progress < 0.09f) {
				filltarget = asyncOperation.progress;
				yield return null;
			}
			//set to 100% if load is close to the end, (should never reach this)
			filltarget = 1.0f;

			//while bar is not fully filled
			while (LoadingProgressBar.GetComponent<Image> ().fillAmount != filltarget) {
				yield return null;
			}

			// load is now complete
			LoadingSceneComplete ();
			yield return new WaitForSeconds(LoadingDelay);

			//fade to black
			GUIManager.Instance.FadeEffectOn(true, FinishFadeDuration);
			yield return new WaitForSeconds (FinishFadeDuration);

			//switch to new scene as soon as its ready
			asyncOperation.allowSceneActivation = true;
		}
Beispiel #24
0
 private IEnumerator LoadLevel()
 {
     this._asyncOperation = Application.LoadLevelAsync("MainScene");
     while (!this._asyncOperation.isDone)
     {
         yield return null;
     }
 }
Beispiel #25
0
        IEnumerator ClearPistonQueue()
        {
            string          hostNameFull = string.Format("http://{0}:{1}/api/clearQueue", "localhost", 8080);
            UnityWebRequest request      = UnityWebRequest.Get(hostNameFull);

            UnityEngine.AsyncOperation async = request.Send();
            yield return(async);
        }
Beispiel #26
0
        IEnumerator AddPistonQueue(float interval, int direction)
        {
            string          hostNameFull = string.Format("http://{0}:{1}/api/addQueue?direction={2}&interval={3}", "localhost", 8080, direction, interval);
            UnityWebRequest request      = UnityWebRequest.Get(hostNameFull);

            UnityEngine.AsyncOperation async = request.Send();
            yield return(async);
        }
        public IEnumerator Loading(string sceneName)
        {
            async = Application.LoadLevelAsync(sceneName);

            yield return async;

            Debug.Log ("loading Complete");
        }
Beispiel #28
0
 void LoadAsync(string name)
 {
     isBegin = true;
     async   = SceneManager.LoadSceneAsync(name);
     async.allowSceneActivation = false;
     //柔和加载
     Loading(60);
 }
Beispiel #29
0
 IEnumerator loadScene()
 {
     asyncOperation = Application.LoadLevelAsync(1);//跳转到下一个场景,这里可以写成字符串的形式
     if (asyncOperation.isDone) {
         this.gameObject.SetActive(false);
     }
     yield return asyncOperation;
 }
		void Update() {
			if (_inEnded && _async != null && _async.isDone) {
				_async = null;

				loadingObject.Hide (_outDuration);
				SceneEventManager.TriggerSceneLoaded (new SceneEventArgs { Name = SceneManager.GetActiveScene().name });
				StartCoroutine (OnOutEnd());
			}
		}
        public static IObservable <float> ToObservable(this UnityEngine.AsyncOperation asyncOperation)
        {
            if (asyncOperation == null)
            {
                throw new ArgumentNullException("asyncOperation");
            }

            return(Observable.FromCoroutine <float>((observer, cancellationToken) => RunAsyncOperation(asyncOperation, observer, cancellationToken)));
        }
    public IEnumerator loadAsyncScene()
    {
        yield return(new WaitForSeconds(0.1f));

        async = SceneManager.LoadSceneAsync(level);
        async.allowSceneActivation = false;

        yield return(async);
    }
Beispiel #33
0
 private static IEnumerator AsynCoroutine(UnityEngine.AsyncOperation operation_, Action <float> progress_, Action <AsyncOperation> complete_)
 {
     while (!operation_.isDone)
     {
         progress_(operation_.progress);
         yield return(null);
     }
     complete_(operation_);
 }
 public static int  obj_hash(long L)
 {
     UnityEngine.AsyncOperation obj = FCGetObj.GetObj <UnityEngine.AsyncOperation>(L);
     if (obj != null)
     {
         return(obj.GetHashCode());
     }
     return(0);
 }
Beispiel #35
0
 void LoadOver()
 {
     isBegin = false;
     async.allowSceneActivation = true;
     async = null;
     if (OnLoadingOver != null)
     {
         Util.DelayOneFrame(OnLoadingOver, loadingScene);  //等待一帧
     }
 }
Beispiel #36
0
 /// <summary>
 /// 执行卸载
 /// </summary>
 private void DoUnloadUnusedAsset()
 {
     if (!IsUnloadUnusedAsset())
     {
         uloadResAsyn      = Resources.UnloadUnusedAssets();
         m_unloadSinceLast = GameTimeStamp;
         //Engine.Utility.Log.Info("GameApp->DoUnloadUnusedAsset Time:{0}" ,GameTimeStamp);
     }
     m_bunloadUnuseAssetMaskEnable = false;
 }
        //异步场景加载完成
        private void AsyncLoading_completed(UnityEngine.AsyncOperation obj)
        {
            updateLoading?.Invoke(obj.progress);

            endLoading?.Invoke();

            MTEvent.EventParamete eventParamete = new MTEvent.EventParamete();
            eventParamete.AddParameter(obj.progress);
            EventManager.TriggerEvent(MTEvent.GenericEventEnumType.Message, LoadingMessageType.LoadingProcess.ToString(), eventParamete);
        }
Beispiel #38
0
 public static void Switch()
 {
     if (_currentLoadJob != null) {
         _currentLoadJob.allowSceneActivation = true;
         _currentLoadJob = null;
     } else {
     #if DEBUG
         Debug.Log("Could not switch because no scene was loaded.");
     #endif
     }
 }
Beispiel #39
0
 IEnumerator loadScene(string name)
 {
     asyncOperation = Application.LoadLevelAsync(name);
     while(asyncOperation.progress < 0.9f) {
         slider.value = asyncOperation.progress;             //实际加载场景的进度值显示在Slider里面
         yield return new WaitForEndOfFrame();
     }
     //作一个跳转的场景
     Debug.Log(asyncOperation.progress);
     yield return asyncOperation;
 }
 static public int get_allowSceneActivation(IntPtr l)
 {
     try {
         UnityEngine.AsyncOperation self = (UnityEngine.AsyncOperation)checkSelf(l);
         pushValue(l, self.allowSceneActivation);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int get_priority(IntPtr l)
 {
     try {
         UnityEngine.AsyncOperation self = (UnityEngine.AsyncOperation)checkSelf(l);
         pushValue(l, self.priority);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
        public override void OnEnter()
        {
            asyncOperation = Resources.UnloadUnusedAssets();

            if (UnloadDoneEvent!=null)
            {
                return; // Don't Finish()
            }

            Finish();
        }
        IEnumerator _LoadGameScene(string strSceneName, Action callBack)
        {
            op = Application.LoadLevelAsync(strSceneName);
            while (!op.isDone)
                yield return 0;

            if (callBack != null)
                callBack();

            // http://answers.unity3d.com/questions/348974/edit-camera-culling-mask.html
            Camera.main.cullingMask &= ~(1 << LayerMask.NameToLayer("UI"));
        }
	static public int constructor(IntPtr l) {
		try {
			UnityEngine.AsyncOperation o;
			o=new UnityEngine.AsyncOperation();
			pushValue(l,true);
			pushValue(l,o);
			return 2;
		}
		catch(Exception e) {
			return error(l,e);
		}
	}
        public void Start()
        {
            StartCoroutine(FlashScreen());
            Screen.orientation = ScreenOrientation.Landscape;
            sound = SoundKit.instance.playSound(PowerGuit);

            aSync = SceneManager.LoadSceneAsync(k.Scenes.DEFAULT);
            aSync.allowSceneActivation = false;
            Go.Tapped += (o, e) => StartGame();
            CreditsButton.Tapped += (o, e) => Credits();
            QuitButton.Tapped += (o, e) => Quit();
        }
        IEnumerator _LoadGameScene(string strSceneName, bool closeAllUI, Action callBack)
        {
            op = Application.LoadLevelAsync(strSceneName);
            while (!op.isDone)
                yield return 0;

            if (closeAllUI)
                UICenterMasterManager.Instance.HideAllShownWindow(true);

            if (callBack != null)
                callBack();
            Camera.main.cullingMask &= ~(1 << LayerMask.NameToLayer("UI"));
        }
Beispiel #47
0
 private static bool _Load(Func<AsyncOperation> getLoadJob)
 {
     if(_currentLoadJob != null) {
     #if DEBUG
         Debug.Log("Could not load a new level, because a level is already loading");
     #endif
         return false;
     }
     _currentLoadJob = getLoadJob();
     if(_currentLoadJob != null)
         _currentLoadJob.allowSceneActivation = false;
     return _currentLoadJob != null;
 }
 public static int constructor(IntPtr l)
 {
     try {
         UnityEngine.AsyncOperation o;
         o=new UnityEngine.AsyncOperation();
         pushValue(l,o);
         return 1;
     }
     catch(Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return 0;
     }
 }
Beispiel #49
0
        public override void OnEnter()
        {
            if (dontDestroyOnLoad.Value)
            {
                // Have to get the root, since this FSM will be destroyed if a parent is destroyed.

                var root = Owner.transform.root;

                Object.DontDestroyOnLoad(root.gameObject);
            }

            if (additive)
            {
                if (async)
                {
                    //asyncOperation = Application.LoadLevelAdditiveAsync( levelName.Value );
                    asyncOperation = SceneManager.LoadSceneAsync( levelName.Value, LoadSceneMode.Additive );

                    Debug.Log("LoadLevelAdditiveAsyc: " + levelName.Value);

                    return; // Don't Finish()
                }

            //				Application.LoadLevelAdditive(levelName.Value);
                SceneManager.LoadScene( levelName.Value, LoadSceneMode.Additive );

                Debug.Log("LoadLevelAdditive: " + levelName.Value);
            }
            else
                if (async)
                {
            //					asyncOperation = Application.LoadLevelAsync(levelName.Value);
                    asyncOperation = SceneManager.LoadSceneAsync( levelName.Value );

                    Debug.Log("LoadLevelAsync: " + levelName.Value);

                    return; // Don't Finish()
                }
                else
                {
                //Application.LoadLevel( levelName.Value );
                SceneManager.LoadScene( levelName.Value );

                Debug.Log("LoadLevel: " + levelName.Value);
                }

            Log("LOAD COMPLETE");

            Fsm.Event(loadedEvent);
            Finish();
        }
        public void NextScene(int nextLevel)
        {
            Log.Assert(_asyncOp == null, "Scene transition already in progress!");
            Log.Debug("SceneTransition", "Set next level {0}", nextLevel);

            #if USE_UNITY_PRO
            asyncOp = Application.LoadLevelAsync(nextLevel); // TODO: Scene name or index!
            #else
            _asyncOp = new AsyncOperationWrapper(nextLevel);
            #endif
            _asyncOp.allowSceneActivation = false; // Should wait for the fade.
            audioPlayer.FadeOut(1f/4f);

            Animator a = this.gameObject.GetComponent<Animator>();
            a.Play("FadeOut");
        }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public override bool Run(WorldLoadingProcessor previousProcessor)
        {
            float deltaTime = Time.realtimeSinceStartup - this._start;
            if (deltaTime >= 3.0f && !_isLoading)
            {
                _isLoading = true;
                _operation = Application.LoadLevelAdditiveAsync (_sceneFile);
            }

            if (_operation == null)
                return false;

            if (!_operation.isDone)
                return false;

            return true;
        }
        bool IRadicalYieldInstruction.Tick(out object yieldObject)
        {
            if (_recentOperation == null || _recentOperation.isDone)
            {
                for (int i = 0; i < _operations.Length; i++)
                {
                    if (!_operations[i].isDone)
                    {
                        _recentOperation = _operations[i];
                        yieldObject = _recentOperation;
                        return true;
                    }
                }
            }

            yieldObject = null;
            return false;
        }
Beispiel #53
0
        private bool sceneChanged = false; // 次のシーンに移行したかどうかのフラグ.

        #endregion Fields

        #region Methods

        void CheckSpwan()
        {
            if (character.MoveTime > spawnInterval && asyncOpe==null)
            {
                asyncOpe= UnityEngine.SceneManagement.SceneManager.LoadSceneAsync("MainScene");
                asyncOpe.allowSceneActivation = false;
            }

            if (asyncOpe != null)
            {
                if (!sceneChanged && asyncOpe.progress >= 0.9f)
                {
                    // 次のシーンに移行.
                    asyncOpe.allowSceneActivation = true;
                    sceneChanged = true;

                }
            }
        }
	static int _CreateUnityEngine_AsyncOperation(IntPtr L)
	{
		try
		{
			int count = LuaDLL.lua_gettop(L);

			if (count == 0)
			{
				UnityEngine.AsyncOperation obj = new UnityEngine.AsyncOperation();
				ToLua.PushObject(L, obj);
				return 1;
			}
			else
			{
				return LuaDLL.luaL_throw(L, "invalid arguments to ctor method: UnityEngine.AsyncOperation.New");
			}
		}
		catch(Exception e)
		{
			return LuaDLL.toluaL_exception(L, e);
		}
	}
Beispiel #55
0
 public void LoadLevel(string level)
 {
     win.enabled = true;
     timer = 0;
     LevelToLoad = level;
     if (BeginLoadLevel != null) BeginLoadLevel();
     async = Application.LoadLevelAsync(level);
     async.allowSceneActivation = false;
     SoundPlayer[] bgms = FindObjectsOfType<SoundPlayer>();
     soundsInScene = new SoundPlayer[bgms.Length - 1];
     int i = 0;
     foreach (SoundPlayer s in bgms)
     {
         if (s != music)
         {
             s.Stop();
             soundsInScene[i] = s;
             i++;
         }
     }
     music.PlaySong(0);
 }
        static IEnumerator AsObservableCore(AsyncOperation asyncOperation, IObserver<AsyncOperation> observer, IProgress<float> reportProgress, CancellationToken cancel)
        {
            while (!asyncOperation.isDone && !cancel.IsCancellationRequested)
            {
                if (reportProgress != null)
                {
                    try
                    {
                        reportProgress.Report(asyncOperation.progress);
                    }
                    catch (Exception ex)
                    {
                        observer.OnError(ex);
                        yield break;
                    }
                }
                yield return null;
            }

            if (cancel.IsCancellationRequested) yield break;

            observer.OnNext(asyncOperation);
            observer.OnCompleted();
        }
Beispiel #57
0
 private void InitFinalize() {
     if (asyncLoading) {
         if (MadLevel.hasExtension && MadLevel.CanContinue()) {
             asyncOperation = MadLevel.ContinueAsync();
         } else {
             Debug.LogWarning("Level loading screen is meant to be in extension as 'before' scene.");
             asyncOperation = MadLevel.LoadNextAsync();
         }
     }
 }
 private IEnumerator loadSceneAsync()
 {
     _asyncOperation = Application.LoadLevelAsync(LevelName);
     yield return _asyncOperation;
 }
Beispiel #59
0
 public ResourceLoader(string resName, LoadResDoneCallback loadResDone)
 {
     this.ResName = resName;
     this.LoadDoneCallback = loadResDone;
     int end = resName.LastIndexOf('.');
     string resPath = resName.Substring(0, (end == -1 ? resName.Length : end));
     this.req = Resources.LoadAsync(resPath);
 }
Beispiel #60
0
 IEnumerator StartScene(string name)
 {
     CustDebug.Log("异步加载场景");
     btnBigen.SetActive(false);
     back.SetActive(false);
     progressBar.gameObject.SetActive(true);
     async = Application.LoadLevelAsync(name);
     GameCillter.SceneNameDefine(name);
     //async = GameCillter.GotoScene(name) as AsyncOperation;
     //StartCoroutine(LoadScene());
     yield return async;
 }