diff --git a/CHANGELOG.md b/CHANGELOG.md index f7a4669..fd7419e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - [#351] Fix issue where ObjectRegistry contents are not properly inherited across filter node refreshes. +- [#354] Fix "rendering stopped" errors on Mac editors ### Changed diff --git a/Editor/PreviewSystem/Rendering/ProxyObjectController.cs b/Editor/PreviewSystem/Rendering/ProxyObjectController.cs index 5e85daa..d84c4da 100644 --- a/Editor/PreviewSystem/Rendering/ProxyObjectController.cs +++ b/Editor/PreviewSystem/Rendering/ProxyObjectController.cs @@ -126,7 +126,7 @@ private void SetupRendererMonitoring(Renderer r) OnInvalidate = Task.WhenAny(_monitorRenderer.OnInvalidate, _monitorMaterials.OnInvalidate, _monitorMesh.OnInvalidate); } - + internal bool OnPreFrame() { if (_replacementRenderer == null || _originalRenderer == null) @@ -146,8 +146,8 @@ internal bool OnPreFrame() _pickingOffOriginal = SceneVisibilityManager.instance.IsPickingDisabled(original.gameObject); _visibilityOffOriginal = SceneVisibilityManager.instance.IsHidden(original.gameObject); } - - target.enabled = original.enabled && original.gameObject.activeInHierarchy; + + target.enabled = false; bool shouldDisablePicking = _pickingOffOriginal || _visibilityOffOriginal; @@ -192,6 +192,8 @@ internal bool OnPreFrame() } } + target.enabled = original.enabled && original.gameObject.activeInHierarchy; + _replacementRenderer.sharedMaterials = _originalRenderer.sharedMaterials; @@ -229,7 +231,20 @@ internal bool OnPreFrame() internal void FinishPreFrame(bool isSceneViewCamera) { - if (_replacementRenderer != null) _replacementRenderer.enabled &= !(isSceneViewCamera && _visibilityOffOriginal); + if (_replacementRenderer != null) + { + var shouldEnable = _replacementRenderer.enabled & !(isSceneViewCamera && _visibilityOffOriginal); + Mesh currentSharedMesh = null; + + if (_replacementRenderer is SkinnedMeshRenderer smr) + currentSharedMesh = smr.sharedMesh; + else if (_replacementRenderer is MeshRenderer mr) + currentSharedMesh = mr.GetComponent().sharedMesh; + + if (currentSharedMesh != _initialSharedMesh) _replacementRenderer.enabled = false; + + _replacementRenderer.enabled = shouldEnable; + } } private void CreateReplacementObject()