void OnDisable() { if (_root != null) { _root.Dispose(); _root = null; } }
void OnErrorOccurred(Exception e) { Log.ErrorException(e); // If we are continually getting errors every frame then just give up completely // To avoid freezing the unity editor if (_consecutiveUpdateErrorCount > 5 || _consecutiveGuiErrorCount > 5) { _root = null; // Try again next assembly reload _hasInitialized = false; } // If a one-off error occurred that doesn't repeat, display it as a popup if (_root != null) { _root.DisplayError(e); } }
void Initialize() { bool isFirstLoad = false; if (!_hasInitialized) { isFirstLoad = true; _model = new PmModel(); _viewModel = new PmView.Model(); for (int i = 0; i < (int)DragListTypes.Count; i++) { _viewModel.ListModels.Add(new DragList.Model()); } } _root = new PmCompositionRoot(_model, _viewModel, isFirstLoad); _root.Initialize(); // Put the _hasInitialized here so that if it fails to initialize it will try again next assembly reload // Otherwise it might serialize half-initialized data _hasInitialized = true; }
void OnEnable() { bool isFirstLoad = false; if (!_hasInitialized) { _hasInitialized = true; isFirstLoad = true; Assert.IsNull(_model); Assert.IsNull(_viewModel); _model = new PmModel(); _viewModel = new PmView.Model(); for (int i = 0; i < (int)DragListTypes.Count; i++) { _viewModel.ListModels.Add(new DragList.Model()); } } _root = new PmCompositionRoot(_model, _viewModel, isFirstLoad); _root.Initialize(); }
void OnDisable() { Assert.IsNotNull(_root); _root.Dispose(); _root = null; }