Exemplo n.º 1
0
 private static void OperationCompleted(UnityEngine.AsyncOperation obj)
 {
     if (((UnityWebRequestAsyncOperation)obj).webRequest.responseCode != 200)
     {
         // Roll back changes on client
     }
 }
Exemplo n.º 2
0
        private IEnumerator LoadScene(string sceneName, bool startImmediately)
        {
            if (OnStartLoading != null)
            {
                OnStartLoading();
            }

            yield return(null);

            asyncOp = SceneManager.LoadSceneAsync(sceneName);
            asyncOp.allowSceneActivation = startImmediately;

            while (!asyncOp.isDone)
            {
                yield return(null);

                if (!startImmediately &&
                    (Progress < MAGIC_UNITY_LOADING_VALUE) &&
                    (asyncOp.progress >= MAGIC_UNITY_LOADING_VALUE))
                {
                    if (OnSceneReady != null)
                    {
                        OnSceneReady();
                    }
                }

                Progress = asyncOp.progress;
            }

            asyncOp  = null;
            Progress = 1.0f;

            yield return(null);

            var assetService = GlobalState.AssetService;

            while (assetService.IsLoading || (loadingRoutines.Count > 0))
            {
                var index = 0;

                while (index < loadingRoutines.Count)
                {
                    if (!loadingRoutines[index].MoveNext())
                    {
                        loadingRoutines.RemoveAt(index);
                    }
                    else
                    {
                        index++;
                    }
                }

                yield return(null);
            }

            if (OnFinishedLoading != null)
            {
                OnFinishedLoading();
            }
        }
        static int _e_completed(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
                int gen_param_count         = LuaAPI.lua_gettop(L);
                UnityEngine.AsyncOperation gen_to_be_invoked            = (UnityEngine.AsyncOperation)translator.FastGetCSObj(L, 1);
                System.Action <UnityEngine.AsyncOperation> gen_delegate = translator.GetDelegate <System.Action <UnityEngine.AsyncOperation> >(L, 3);
                if (gen_delegate == null)
                {
                    return(LuaAPI.luaL_error(L, "#3 need System.Action<UnityEngine.AsyncOperation>!"));
                }

                if (gen_param_count == 3)
                {
                    if (LuaAPI.xlua_is_eq_str(L, 2, "+"))
                    {
                        gen_to_be_invoked.completed += gen_delegate;
                        return(0);
                    }


                    if (LuaAPI.xlua_is_eq_str(L, 2, "-"))
                    {
                        gen_to_be_invoked.completed -= gen_delegate;
                        return(0);
                    }
                }
            } catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }
            LuaAPI.luaL_error(L, "invalid arguments to UnityEngine.AsyncOperation.completed!");
            return(0);
        }
        /// <summary>
        /// Example ToObservable method from UniRX Docs.
        /// </summary>
        /// <param name="asyncOperation"></param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException"></exception>
        public static IObservable <float> ToObservable(this UnityEngine.AsyncOperation asyncOperation)
        {
            if (asyncOperation == null)
            {
                throw new ArgumentNullException(nameof(asyncOperation));
            }

            return(Observable.FromCoroutine <float>((observer, cancellationToken) => RunAsyncOperation(asyncOperation, observer, cancellationToken)));
        }
        static StackObject *Ctor_0(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            CSHotFix.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *__ret = ILIntepreter.Minus(__esp, 0);

            var result_of_this_method = new UnityEngine.AsyncOperation();

            return(ILIntepreter.PushObject(__ret, __mStack, result_of_this_method));
        }
Exemplo n.º 6
0
        public Task RunWithProgressAsync(AsyncOperation asyncOperation,
                                         Func <float> getProgressFunc, Action <float> progressChanged)
        {
            var tcs = new TaskCompletionSource <object>();

            _agent.RunWithProgress(asyncOperation, () => tcs.SetResult(null),
                                   getProgressFunc, progressChanged);

            return(tcs.Task);
        }
        static int _g_get_progress(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

                UnityEngine.AsyncOperation gen_to_be_invoked = (UnityEngine.AsyncOperation)translator.FastGetCSObj(L, 1);
                LuaAPI.lua_pushnumber(L, gen_to_be_invoked.progress);
            } catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }
            return(1);
        }
        static int _s_set_priority(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

                UnityEngine.AsyncOperation gen_to_be_invoked = (UnityEngine.AsyncOperation)translator.FastGetCSObj(L, 1);
                gen_to_be_invoked.priority = LuaAPI.xlua_tointeger(L, 2);
            } catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }
            return(0);
        }
Exemplo n.º 9
0
        static int _g_get_priority(RealStatePtr L)
        {
            ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

            try {
                UnityEngine.AsyncOperation __cl_gen_to_be_invoked = (UnityEngine.AsyncOperation)translator.FastGetCSObj(L, 1);
                LuaAPI.xlua_pushinteger(L, __cl_gen_to_be_invoked.priority);
            } catch (System.Exception __gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e));
            }
            return(1);
        }
Exemplo n.º 10
0
        static int _s_set_allowSceneActivation(RealStatePtr L)
        {
            ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

            try {
                UnityEngine.AsyncOperation __cl_gen_to_be_invoked = (UnityEngine.AsyncOperation)translator.FastGetCSObj(L, 1);
                __cl_gen_to_be_invoked.allowSceneActivation = LuaAPI.lua_toboolean(L, 2);
            } catch (System.Exception __gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e));
            }
            return(0);
        }
Exemplo n.º 11
0
        private async void OnRemoteRootInfos(UnityEngine.AsyncOperation obj)
        {
            var async = obj as UnityWebRequestAsyncOperation;
            var w     = async.webRequest;

            if (w.isNetworkError)
            {
                if (remoteRootInfoNetworkErrorHandler != null)
                {
                    remoteRootInfoNetworkErrorHandler(w.error);
                }
                w.Dispose();
            }
            else
            {
                var text = System.Text.Encoding.UTF8.GetString(w.downloadHandler.data);
                var ca   = text.Split('\n');
                for (int i = 0; i < ca.Length; i++)
                {
                    if (string.IsNullOrEmpty(ca[i]))
                    {
                        continue;
                    }
                    var spl = ca[i].Split(',');
                    m_remoteRootInfos.Add(spl[0], Convert.ToInt32(spl[1]));
                }
                foreach (var remotes in m_remoteRootInfos)
                {
                    if (m_localRootInfos.ContainsKey(remotes.Key))
                    {
                        if (m_localRootInfos[remotes.Key] < remotes.Value)
                        {
                            m_changedInfos.Add(remotes.Key);
                        }
                    }
                    else
                    {
                        m_addInfos.Add(remotes.Key);
                    }
                }
                foreach (var local in m_localRootInfos)
                {
                    if (!m_remoteRootInfos.ContainsKey(local.Key))
                    {
                        m_deletedInfos.Add(local.Key);
                    }
                }
                w.Dispose();
                await CheckChangedInfos();
            }
        }
        private static IEnumerator RunAsyncOperation(UnityEngine.AsyncOperation asyncOperation, IObserver <float> observer, CancellationToken cancellationToken)
        {
            while (!asyncOperation.isDone && !cancellationToken.IsCancellationRequested)
            {
                observer.OnNext(asyncOperation.progress);
                yield return(null);
            }

            if (!cancellationToken.IsCancellationRequested)
            {
                observer.OnNext(asyncOperation.progress); // push 100%
                observer.OnCompleted();
            }
        }
Exemplo n.º 13
0
        static int _m_UnloadSceneAsync_xlua_st_(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);



                int gen_param_count = LuaAPI.lua_gettop(L);

                if (gen_param_count == 1 && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 1))
                {
                    int _sceneBuildIndex = LuaAPI.xlua_tointeger(L, 1);

                    UnityEngine.AsyncOperation gen_ret = UnityEngine.SceneManagement.SceneManager.UnloadSceneAsync(_sceneBuildIndex);
                    translator.Push(L, gen_ret);



                    return(1);
                }
                if (gen_param_count == 1 && (LuaAPI.lua_isnil(L, 1) || LuaAPI.lua_type(L, 1) == LuaTypes.LUA_TSTRING))
                {
                    string _sceneName = LuaAPI.lua_tostring(L, 1);

                    UnityEngine.AsyncOperation gen_ret = UnityEngine.SceneManagement.SceneManager.UnloadSceneAsync(_sceneName);
                    translator.Push(L, gen_ret);



                    return(1);
                }
                if (gen_param_count == 1 && translator.Assignable <UnityEngine.SceneManagement.Scene>(L, 1))
                {
                    UnityEngine.SceneManagement.Scene _scene; translator.Get(L, 1, out _scene);

                    UnityEngine.AsyncOperation gen_ret = UnityEngine.SceneManagement.SceneManager.UnloadSceneAsync(_scene);
                    translator.Push(L, gen_ret);



                    return(1);
                }
            } catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }

            return(LuaAPI.luaL_error(L, "invalid arguments to UnityEngine.SceneManagement.SceneManager.UnloadSceneAsync!"));
        }
        static StackObject *get_progress_1(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 1);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            UnityEngine.AsyncOperation instance_of_this_method = (UnityEngine.AsyncOperation) typeof(UnityEngine.AsyncOperation).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags) 0);
            __intp.Free(ptr_of_this_method);

            var result_of_this_method = instance_of_this_method.progress;

            __ret->ObjectType       = ObjectTypes.Float;
            *(float *)&__ret->Value = result_of_this_method;
            return(__ret + 1);
        }
        static StackObject *get_priority_2(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            CSHotFix.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 1);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            UnityEngine.AsyncOperation instance_of_this_method = (UnityEngine.AsyncOperation) typeof(UnityEngine.AsyncOperation).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            var result_of_this_method = instance_of_this_method.priority;

            __ret->ObjectType = ObjectTypes.Integer;
            __ret->Value      = result_of_this_method;
            return(__ret + 1);
        }
        static StackObject *set_allowSceneActivation_5(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            CSHotFix.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 2);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            System.Boolean @value = ptr_of_this_method->Value == 1;

            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            UnityEngine.AsyncOperation instance_of_this_method = (UnityEngine.AsyncOperation) typeof(UnityEngine.AsyncOperation).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            instance_of_this_method.allowSceneActivation = value;

            return(__ret);
        }
Exemplo n.º 17
0
        static int __CreateInstance(RealStatePtr L)
        {
            ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

            try {
                if (LuaAPI.lua_gettop(L) == 1)
                {
                    UnityEngine.AsyncOperation __cl_gen_ret = new UnityEngine.AsyncOperation();
                    translator.Push(L, __cl_gen_ret);
                    return(1);
                }
            }
            catch (System.Exception __gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e));
            }
            return(LuaAPI.luaL_error(L, "invalid arguments to UnityEngine.AsyncOperation constructor!"));
        }
        static StackObject *add_completed_2(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 2);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            System.Action <UnityEngine.AsyncOperation> @value = (System.Action <UnityEngine.AsyncOperation>) typeof(System.Action <UnityEngine.AsyncOperation>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags) 8);
            __intp.Free(ptr_of_this_method);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            UnityEngine.AsyncOperation instance_of_this_method = (UnityEngine.AsyncOperation) typeof(UnityEngine.AsyncOperation).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags) 0);
            __intp.Free(ptr_of_this_method);

            instance_of_this_method.completed += value;

            return(__ret);
        }
Exemplo n.º 19
0
        static int _e_completed(RealStatePtr L)
        {
            ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
            int __gen_param_count       = LuaAPI.lua_gettop(L);

            UnityEngine.AsyncOperation __cl_gen_to_be_invoked = (UnityEngine.AsyncOperation)translator.FastGetCSObj(L, 1);
            try {
                System.Action <UnityEngine.AsyncOperation> __gen_delegate = translator.GetDelegate <System.Action <UnityEngine.AsyncOperation> >(L, 3);
                if (__gen_delegate == null)
                {
                    return(LuaAPI.luaL_error(L, "#3 need System.Action<UnityEngine.AsyncOperation>!"));
                }

                if (__gen_param_count == 3)
                {
                    System.IntPtr strlen;

                    System.IntPtr str = LuaAPI.lua_tolstring(L, 2, out strlen);

                    if (str != System.IntPtr.Zero && strlen.ToInt32() == 1)
                    {
                        byte op = System.Runtime.InteropServices.Marshal.ReadByte(str);


                        if (op == (byte)'+')
                        {
                            __cl_gen_to_be_invoked.completed += __gen_delegate;
                            return(0);
                        }


                        if (op == (byte)'-')
                        {
                            __cl_gen_to_be_invoked.completed -= __gen_delegate;
                            return(0);
                        }
                    }
                }
            } catch (System.Exception __gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e));
            }
            LuaAPI.luaL_error(L, "invalid arguments to UnityEngine.AsyncOperation.completed!");
            return(0);
        }
        static int _m_UnloadUnusedAssets_xlua_st_(RealStatePtr L)
        {
            ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);



            try {
                {
                    UnityEngine.AsyncOperation __cl_gen_ret = UnityEngine.Resources.UnloadUnusedAssets(  );
                    translator.Push(L, __cl_gen_ret);



                    return(1);
                }
            } catch (System.Exception __gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e));
            }
        }
        static int _m_LoadEmptyComplete_xlua_st_(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);



                {
                    UnityEngine.AsyncOperation _operation = (UnityEngine.AsyncOperation)translator.GetObject(L, 1, typeof(UnityEngine.AsyncOperation));

                    Game.LoadManager.LoadEmptyComplete(_operation);



                    return(0);
                }
            } catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }
        }
Exemplo n.º 22
0
        static int _m_RequestUserAuthorization_xlua_st_(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);



                {
                    UnityEngine.UserAuthorization mode; translator.Get(L, 1, out mode);

                    UnityEngine.AsyncOperation __cl_gen_ret = UnityEngine.Application.RequestUserAuthorization(mode);
                    translator.Push(L, __cl_gen_ret);



                    return(1);
                }
            } catch (System.Exception __gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e));
            }
        }
Exemplo n.º 23
0
        public void __Gen_Delegate_Imp20(UnityEngine.AsyncOperation p0)
        {
#if THREAD_SAFE || HOTFIX_ENABLE
            lock (luaEnv.luaEnvLock)
            {
#endif
            RealStatePtr L = luaEnv.rawL;
            int errFunc    = LuaAPI.pcall_prepare(L, errorFuncRef, luaReference);
            ObjectTranslator translator = luaEnv.translator;
            translator.Push(L, p0);

            PCall(L, 1, 0, errFunc);



            LuaAPI.lua_settop(L, errFunc - 1);

#if THREAD_SAFE || HOTFIX_ENABLE
        }
#endif
        }
Exemplo n.º 24
0
        private async void OnRemoteVersion(UnityEngine.AsyncOperation obj)
        {
            var async = obj as UnityWebRequestAsyncOperation;
            var w     = async.webRequest;

            if (w.isNetworkError)
            {
                if (remoteVersionNetworkErrorHandler != null)
                {
                    remoteVersionNetworkErrorHandler(w.error);
                }
                w.Dispose();
            }
            else
            {
                byte[] result = w.downloadHandler.data;
                m_newVersion = System.Text.Encoding.UTF8.GetString(result);
                m_newVersion = m_newVersion.TrimEnd();
                m_newVersion = m_newVersion.Replace("\n", "");
                UnityEngine.Debug.Log("remoteVersion:" + m_newVersion);
                if (m_localVersion == m_newVersion)
                {
                    if (downloadCompletedHandler != null)
                    {
                        downloadCompletedHandler();
                    }
                    w.Dispose();
                }
                else
                {
                    m_newVersionStr = m_newVersion.Replace('.', '_');
                    w.Dispose();
                    await CheckRootInfos();
                }
            }
        }
        static int _m_UpdateNavMeshDataAsync_xlua_st_(RealStatePtr L)
        {
            ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);



            try {
                {
                    UnityEngine.AI.NavMeshData          data = (UnityEngine.AI.NavMeshData)translator.GetObject(L, 1, typeof(UnityEngine.AI.NavMeshData));
                    UnityEngine.AI.NavMeshBuildSettings buildSettings; translator.Get(L, 2, out buildSettings);
                    System.Collections.Generic.List <UnityEngine.AI.NavMeshBuildSource> sources = (System.Collections.Generic.List <UnityEngine.AI.NavMeshBuildSource>)translator.GetObject(L, 3, typeof(System.Collections.Generic.List <UnityEngine.AI.NavMeshBuildSource>));
                    UnityEngine.Bounds localBounds; translator.Get(L, 4, out localBounds);

                    UnityEngine.AsyncOperation __cl_gen_ret = UnityEngine.AI.NavMeshBuilder.UpdateNavMeshDataAsync(data, buildSettings, sources, localBounds);
                    translator.Push(L, __cl_gen_ret);



                    return(1);
                }
            } catch (System.Exception __gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e));
            }
        }
Exemplo n.º 26
0
 public AsyncOperation(UnityEngine.AsyncOperation asyncOperation)
 {
     _asyncOperation = asyncOperation;
 }
Exemplo n.º 27
0
 private void OnRequestCompleted(UnityEngine.AsyncOperation obj)
 {
     continuation();
 }
Exemplo n.º 28
0
 private void OnCompleted(UnityEngine.AsyncOperation operation)
 {
     SetValue(s_assetPropertyKey, ((UnityEngine.ResourceRequest)operation).asset);
     SetValue(s_isDonePropertyKey, operation.isDone);
 }
Exemplo n.º 29
0
 private static void LoadedStartScene(string _key, object _object)
 {
     sNowLoadingScene          = _key.Replace(".unity", "");
     SceneManager.sceneLoaded += LoadSceneCall;
     UnityEngine.AsyncOperation topert = SceneManager.LoadSceneAsync(sNowLoadingScene);
 }