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; }
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); }
void Clean() { if (ScriptWatchDisposable != null) ScriptWatchDisposable.Dispose(); foreach (Transform children in Root) { DestroyImmediate(children.gameObject); } ctx?.Dispose(); dispatcher?.Dispose(); runner = null; dispatcher = null; ctx = null; ScriptWatchDisposable = null; }