public static void UpdateModels() { // Update the tree meshes Profiler.BeginSample("Flush"); try { if (!CompactHierarchyManager.Flush(s_FinishMeshUpdates)) { ChiselGeneratedComponentManager.DelayedUVGeneration(); return; // Nothing to update .. } } finally { Profiler.EndSample(); } { Profiler.BeginSample("PostUpdateModels"); PostUpdateModels?.Invoke(); Profiler.EndSample(); } }
public static void UpdateModels() { // Update the tree meshes Profiler.BeginSample("Flush"); try { if (!CSGManager.Flush()) { ChiselGeneratedComponentManager.DelayedUVGeneration(); return; // Nothing to update .. } } finally { Profiler.EndSample(); } #if UNITY_EDITOR ChiselGeneratedComponentManager.OnVisibilityChanged(); #endif for (int m = 0; m < registeredModels.Count; m++) { var model = registeredModels[m]; if (!model) { continue; } var tree = model.Node; // See if the tree has been modified if (!tree.Dirty) { continue; } Profiler.BeginSample("UpdateModelMeshDescriptions"); UpdateModelMeshDescriptions(model); Profiler.EndSample(); updateList.Add(model); } bool modifications = false; try { for (int m = 0; m < updateList.Count; m++) { var model = updateList[m]; // Generate (or re-use) components and set them up properly Profiler.BeginSample("componentGenerator.Rebuild"); componentGenerator.Rebuild(model); Profiler.EndSample(); } } finally { for (int m = 0; m < updateList.Count; m++) { var model = updateList[m]; try { modifications = true; Profiler.BeginSample("PostUpdateModel"); PostUpdateModel?.Invoke(model); Profiler.EndSample(); } catch (Exception ex) // if there's a bug in user-code we don't want to end up in a bad state { Debug.LogException(ex); } } updateList.Clear(); } if (modifications) { Profiler.BeginSample("PostUpdateModels"); PostUpdateModels?.Invoke(); Profiler.EndSample(); } }