Unity-Technologies/UnityCsReference · error · InvalidOperationException
PrefabFamilyPopup is already open
Error message
PrefabFamilyPopup is already open
What it means
PrefabFamilyPopup is a Unity editor popup window that enforces single-instance behavior via a static s_Open flag. The constructor checks isOpen (which reads s_Open) and throws InvalidOperationException if a popup is already active. The flag is set to true in OnOpen() and reset to false in OnClose(), so the exception indicates the previous popup's lifecycle was not cleanly closed before constructing a new one.
Source
Thrown at Editor/Mono/Prefabs/PrefabFamilyPopup.cs:117
{
alignment = TextAnchor.MiddleRight,
fontSize = (int)(1.1f * EditorStyles.boldLabel.fontSize)
};
public static readonly GUIStyle boldNumber = new GUIStyle(EditorStyles.boldLabel)
{
fontSize = (int)(0.9f * EditorStyles.boldLabel.fontSize)
};
public static readonly GUIStyle searchFieldStyle = new GUIStyle(EditorStyles.toolbarSearchField)
{
margin = new RectOffset(5, 4, 4, 5)
};
}
internal PrefabFamilyPopup(GameObject target)
{
if (isOpen)
throw new InvalidOperationException("PrefabFamilyPopup is already open");
this.m_Target = target;
m_TargetPath = AssetDatabase.GetAssetPath(target);
m_TargetGUID = AssetDatabase.AssetPathToGUID(m_TargetPath);
k_MinNameWidth = k_MinWindowWidth - (k_TitleWidth + k_SplitWidth + k_OverridesWidth);
m_SearchFilter = new SearchFilter()
{
classNames = new string[] { "Prefab" },
searchArea = SearchFilter.SearchArea.AllAssets
};
m_Debounce = Delayer.Debounce(_ =>
{
SearchFilterChanged();
editorWindow.Repaint();
});
View on GitHub (pinned to 225b0fbdb5)
Solutions
- Check PrefabFamilyPopup.isOpen before constructing a new instance
- If already open, focus or close the existing popup before creating a new one
- Ensure the popup's OnClose is called by properly closing the EditorWindow before attempting to reopen
- In edge cases where s_Open is stuck true (e.g., after domain reload without proper cleanup), force-reset by closing any existing PrefabFamilyPopup windows first
Example fix
// before
var popup = EditorWindow.GetWindow<PrefabFamilyPopup>(true);
popup.Show(target);
// after
if (PrefabFamilyPopup.isOpen)
{
var existing = EditorWindow.GetWindow<PrefabFamilyPopup>();
existing.Close(); // triggers OnClose -> s_Open = false
}
var popup = EditorWindow.GetWindow<PrefabFamilyPopup>(true);
popup.Show(target); Defensive patterns
Strategy: validation
Validate before calling
if (PrefabFamilyPopup.isOpen)
{
Debug.LogWarning("PrefabFamilyPopup is already open. Closing existing first.");
var existing = Resources.FindObjectsOfTypeAll<PrefabFamilyPopup>();
if (existing.Length > 0) existing[0].Close();
}
// Safe to construct now Try / catch
try { /* construct PrefabFamilyPopup */ }
catch (InvalidOperationException ex) when (ex.Message == "PrefabFamilyPopup is already open")
{ Debug.LogWarning("PrefabFamilyPopup already open. Focus or close the existing window first."); } Prevention
- Always check PrefabFamilyPopup.isOpen before constructing a new popup
- Ensure popup lifecycle is managed: close before reopening
- Handle domain reload scenarios where s_Open might be stale
When it happens
Trigger: Constructing a new PrefabFamilyPopup via EditorWindow.GetWindow or ShowPopup while a previous PrefabFamilyPopup instance is still open (s_Open == true). This can happen if OnClose() was not called (e.g., the window was destroyed abnormally) or if user code tries to open a second popup without closing the first.
Common situations: Editor extensions that open PrefabFamilyPopup programmatically without checking isOpen first. Race conditions where multiple UI events trigger popup creation before the first one closes. Domain reload scenarios where s_Open was not reset (though OnClose should handle normal cases).
Related errors
- guid
- prefabInstance
- Provided GameObject is not a Prefab instance
- The inputObject is null
- Given input object is not a prefab asset
AI-assisted analysis of Unity-Technologies/UnityCsReference@225b0fbdb5 (2026-08-13).
Data as JSON: /api/errors/b681b1e14825baff.
Report an issue: GitHub.