Esempio n. 1
0
        private IDisposable LoadAndRun(ReactScript script, bool disableWarnings = false)
        {
            dispatcher = Application.isPlaying ? RuntimeDispatcher.Create() as IDispatcher : new EditorDispatcher();
            runner = new ReactUnityRunner();
            var watcherDisposable = script.GetScript((code, isDevServer) =>
            {
                ctx = new UGUIContext(Root, Globals, script, dispatcher, new UnityScheduler(dispatcher), isDevServer, Render);
                runner.RunScript(code, ctx, BeforeStart, AfterStart);
            }, dispatcher, true, disableWarnings);

            return watcherDisposable;
        }
Esempio n. 2
0
        private IDisposable LoadAndRun(ReactScript script, List <TextAsset> preload, Action callback = null, bool disableWarnings = false)
        {
            dispatcher = Application.isPlaying ? RuntimeDispatcher.Create() as IDispatcher : new EditorDispatcher();
            runner     = new ReactUnityRunner();
            var watcherDisposable = script.GetScript((code, isDevServer) =>
            {
                ctx = new UGUIContext(Root, Globals, script, dispatcher, new UnityScheduler(dispatcher), isDevServer, Restart);
                runner.RunScript(code, ctx, preload, callback);
            }, dispatcher, true, disableWarnings);

            return(watcherDisposable);
        }
Esempio n. 3
0
        public void Restart()
        {
            int debounce = -1;

            ScriptWatchDisposable = Script.GetScript((script) =>
            {
                if (debounce >= 0)
                {
                    MainThreadDispatcher.StopDeferred(debounce);
                }
                debounce = MainThreadDispatcher.Timeout(() => RunScript(script), 0.5f);
            }, out var result);
            RunScript(result);
        }
Esempio n. 4
0
        private void LoadAndRun(ReactScript script, List <TextAsset> preload, Action callback = null, bool disableWarnings = false)
        {
            MainThreadDispatcher.Initialize();
            int debounce = -1;

            ScriptWatchDisposable = script.GetScript((code, isDevServer) =>
            {
                if (debounce >= 0)
                {
                    MainThreadDispatcher.StopDeferred(debounce);
                }
                debounce = MainThreadDispatcher.Timeout(() => RunScript(code, isDevServer, script, preload, callback), 0.5f);
            }, out var result, true, disableWarnings);
            RunScript(result, false, script, preload, callback);
        }