Repository navigation
Add PrefabDebugger - #2896
Open
dartasen wants to merge 4 commits into
Open
Add PrefabDebugger#2896dartasen wants to merge 4 commits into
dartasen wants to merge 4 commits into
Conversation
dartasen
requested review from
Measurity and
tornac1234
and
a lite review from Copilot
September 15, 2026 21:53
dartasen
marked this pull request as ready for review
September 15, 2026 22:01
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved PrefabDebugger findings include one critical spawn-lifecycle issue and six moderate correctness or usability issues.
Get a fresh assessment by requesting another Copilot review.
Review details
Suppressed comments (6)
Previously missed (2) — in code that hasn't changed since the last review.
NitroxClient/Debuggers/PrefabDebugger.cs:214
- The PR description says the prefab list includes each prefab's TechType, but each row here renders only the name and class ID. TechType is populated and shown only for the currently selected prefab after its asynchronous load, so users cannot browse the list with that advertised information. Add a cached TechType column/value to each row, or adjust the feature contract.
NitroxClient/Debuggers/PrefabDebugger.cs:450 Instantiate(..., false)creates the preview clone inactive (the same inactive-first overload used byGameObjectExtensions.InstantiateInactiveWithId), but this scan runs before the clone is activated. AMeshRendereron the root therefore hasactiveSelf == false, soHasVisibleRendererreturns false and the preview/spawn controls stay disabled for otherwise renderable prefabs. Temporarily activate the behaviour-disabled clone for this scan and deactivate it afterward, or otherwise base visibility on the intended hierarchy state.
NitroxClient/Debuggers/PrefabDebugger.cs:247
- The render texture is fixed at 640x480 (4:3), while this preview rect is sized to the debugger's remaining width and a fixed height of 540px.
StretchToFilldistorts the prefab whenever that rect is not 4:3, which is the normal layout for this 900px-wide window. Preserve the aspect ratio withScaleToFit(or compute an aspect-matched draw rect).
GUI.DrawTexture(previewRect, previewTexture, ScaleMode.StretchToFill, false);
NitroxClient/Debuggers/PrefabDebugger.cs:494
ParticleSystemRendereris also aRenderer, so this predicate marks particle-only prefabs as previewable. Since this debugger does not simulate particle systems, those prefabs can show an empty preview while still enabling the renderer-dependent actions. Exclude particle renderers from the visibility/bounds test (or explicitly simulate them).
private static bool IsRendererVisible(Renderer renderer) => renderer.enabled && renderer.gameObject.activeSelf;
NitroxClient/Debuggers/PrefabDebugger.cs:437
Instantiatecreates an active clone beforeSetLayerRecursivelyandDisablePreviewBehavioursrun. Any prefab scripts can therefore executeAwake/OnEnablewith the clone still in the game scene, so disabling them afterward cannot make this preview isolated and may cause registrations or other gameplay side effects. Use a lifecycle-safe inactive instantiation/sanitization path before exposing arbitrary prefabs to the preview.
previewObject = UnityEngine.Object.Instantiate(prefab, Vector3.zero, Quaternion.identity, false);
previewObject.name = $"[Prefab preview] {prefab.name}";
SetLayerRecursively(previewObject.transform, PREVIEW_LAYER);
DisablePreviewBehaviours(previewObject);
NitroxClient/Debuggers/PrefabDebugger.cs:265
InstantiateSelectedPrefabcan return without creating anything whenPlayer.mainor its camera is unavailable (see its guard at lines 662-665), but this unconditional tab change still leaves the explorer and hides the failure status. Return whether spawning succeeded and switch tabs only after a successful instantiation, or keep the explorer active on failure.
if (GUILayout.Button("Spawn in front of player", GUILayout.Width(240f)))
{
InstantiateSelectedPrefab();
ActiveTab = GetTab("Instantiated prefabs").Value;
}
- Files reviewed: 7/7 changed files
- Comments generated: 1
- Review effort level: Lite
Collaborator
|
Very cool feature, thanks for implementing it! A few comments after testing it:
|
dartasen
force-pushed
the
feat/add-prefabpreviewer
branch
from
October 12, 2026 12:10
86eb4ef to
7f2fd85
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of Change
Requested by @tornac1234
Introduces a new debugger that allows to fetch and explore prefabs entries (pulled from
PrefabDatabaseclass), giving the opportunity to inspect and play with those without digging in the game files or finding them in game.Also added a QoL that selects the right tab and opens the SceneDebugger when inspecting a game object (used by SceneExtraDebugger also for ray casting)
Features
3D Preview controls
PR Checklist
mainat the time of opening🤖 This code was created with the help of AI (especially for the IMGUI part which is a nightmare to write by hand)