Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: "Rendering stopped" errors on Mac editors #354

Merged
merged 1 commit into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading