Skip to content

Commit

Permalink
fix: "Rendering stopped" errors on Mac editors
Browse files Browse the repository at this point in the history
Closes: #348
  • Loading branch information
bdunderscore committed Aug 29, 2024
1 parent 6ea0f74 commit 59a3410
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
23 changes: 19 additions & 4 deletions Editor/PreviewSystem/Rendering/ProxyObjectController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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;

Expand Down Expand Up @@ -192,6 +192,8 @@ internal bool OnPreFrame()
}
}

target.enabled = original.enabled && original.gameObject.activeInHierarchy;

_replacementRenderer.sharedMaterials = _originalRenderer.sharedMaterials;


Expand Down Expand Up @@ -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<MeshFilter>().sharedMesh;

if (currentSharedMesh != _initialSharedMesh) _replacementRenderer.enabled = false;

_replacementRenderer.enabled = shouldEnable;
}
}

private void CreateReplacementObject()
Expand Down

0 comments on commit 59a3410

Please sign in to comment.