Skip to content

Commit

Permalink
fix: minor fixes to error report UI (#237)
Browse files Browse the repository at this point in the history
Closes: #232
  • Loading branch information
bdunderscore committed May 12, 2024
1 parent 960805b commit 73a40ed
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- Workaround VRCSDK bug where stale PhysBones state could be retained over play mode transitions (#231)
- Show object name when we're unable to find the actual GameObject, in error display UI (#224)
- Rerender error report window when leaving play mode (#237)
- Deduplicate object references in NDMF console error reports (#237)

### Changed
- Renamed `NDMF Error Report` to `NDMF Console` (#222)
Expand Down
17 changes: 12 additions & 5 deletions Editor/ErrorReporting/UI/ErrorReportWindow.cs
Original file line number Diff line number Diff line change
@@ -1,25 +1,20 @@
#region

using System;
using System.Collections.Generic;
using System.Linq;
using nadena.dev.ndmf.localization;
using nadena.dev.ndmf.runtime;
using UnityEditor;
using UnityEditor.UIElements;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UIElements;
using Object = UnityEngine.Object;

#endregion

namespace nadena.dev.ndmf.ui
{
#region

using UnityObject = Object;

#endregion

// Note: Due to historical reason, "NDMF Console" is internally called "Error Report".
Expand Down Expand Up @@ -147,11 +142,23 @@ private void OnEnable()
// GUI setup done
EditorApplication.hierarchyChanged += SetupSelector;
}

EditorApplication.playModeStateChanged += OnPlayModeStateChanged;
}

private void OnDisable()
{
EditorApplication.hierarchyChanged -= SetupSelector;
EditorApplication.playModeStateChanged -= OnPlayModeStateChanged;
}

private void OnPlayModeStateChanged(PlayModeStateChange state)
{
if (_testBuild != null && state == PlayModeStateChange.EnteredEditMode)
{
// Rerender error UI in case we can now find objects that had moved during processing...
UpdateContents();
}
}

private void OnSelectionChange()
Expand Down
5 changes: 5 additions & 0 deletions Editor/ErrorReporting/UI/SimpleErrorUI.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#region

using System.Collections.Generic;
using nadena.dev.ndmf.localization;
using UnityEditor;
using UnityEngine.UIElements;
Expand Down Expand Up @@ -88,8 +89,12 @@ private void RenderContent()
}
else
{
HashSet<ObjectReference> _refs = new HashSet<ObjectReference>();
foreach (var objRef in _error.References)
{
// dedup refs
if (!_refs.Add(objRef)) continue;

if (ObjectSelector.TryCreate(_report, objRef, out var selector))
{
objRefs.Add(selector);
Expand Down

0 comments on commit 73a40ed

Please sign in to comment.