Skip to content

Commit 4df0345

Browse files
committed
feat: add migration warning banner and dialog for legacy package users
1 parent 296a2da commit 4df0345

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

UnityMcpBridge/Editor/Windows/MCPForUnityEditorWindow.cs

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ private void OnEnable()
7171
// Load validation level setting
7272
LoadValidationLevelSetting();
7373

74+
// Show one-time migration dialog
75+
ShowMigrationDialogIfNeeded();
76+
7477
// First-run auto-setup only if Claude CLI is available
7578
if (autoRegisterEnabled && !string.IsNullOrEmpty(ExecPath.ResolveClaude()))
7679
{
@@ -170,6 +173,9 @@ private void OnGUI()
170173
{
171174
scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition);
172175

176+
// Migration warning banner (non-dismissible)
177+
DrawMigrationWarningBanner();
178+
173179
// Header
174180
DrawHeader();
175181

@@ -1573,6 +1579,65 @@ private void CheckClaudeCodeConfiguration(McpClient mcpClient)
15731579
}
15741580
}
15751581

1582+
private void ShowMigrationDialogIfNeeded()
1583+
{
1584+
const string dialogShownKey = "MCPForUnity.LegacyMigrationDialogShown";
1585+
if (EditorPrefs.GetBool(dialogShownKey, false))
1586+
{
1587+
return; // Already shown
1588+
}
1589+
1590+
int result = EditorUtility.DisplayDialogComplex(
1591+
"Migration Required",
1592+
"This is the legacy UnityMcpBridge package.\n\n" +
1593+
"Please migrate to the new MCPForUnity package to receive updates and support.\n\n" +
1594+
"Migration takes just a few minutes.",
1595+
"View Migration Guide",
1596+
"Remind Me Later",
1597+
"I'll Migrate Later"
1598+
);
1599+
1600+
if (result == 0) // View Migration Guide
1601+
{
1602+
Application.OpenURL("https://github.com/CoplayDev/unity-mcp/blob/main/docs/v5_MIGRATION.md");
1603+
EditorPrefs.SetBool(dialogShownKey, true);
1604+
}
1605+
else if (result == 2) // I'll Migrate Later
1606+
{
1607+
EditorPrefs.SetBool(dialogShownKey, true);
1608+
}
1609+
// result == 1 (Remind Me Later) - don't set the flag, show again next time
1610+
}
1611+
1612+
private void DrawMigrationWarningBanner()
1613+
{
1614+
// Warning banner - not dismissible, always visible
1615+
EditorGUILayout.Space(5);
1616+
Rect bannerRect = EditorGUILayout.GetControlRect(false, 50);
1617+
EditorGUI.DrawRect(bannerRect, new Color(1f, 0.6f, 0f, 0.3f)); // Orange background
1618+
1619+
GUIStyle warningStyle = new GUIStyle(EditorStyles.boldLabel)
1620+
{
1621+
fontSize = 13,
1622+
alignment = TextAnchor.MiddleLeft,
1623+
richText = true
1624+
};
1625+
1626+
// Use Unicode warning triangle (same as used elsewhere in codebase at line 647, 652)
1627+
string warningText = "\u26A0 <color=#FF8C00>LEGACY PACKAGE:</color> Please migrate to MCPForUnity for updates and support.";
1628+
1629+
Rect textRect = new Rect(bannerRect.x + 15, bannerRect.y + 8, bannerRect.width - 180, bannerRect.height - 16);
1630+
GUI.Label(textRect, warningText, warningStyle);
1631+
1632+
// Button on the right
1633+
Rect buttonRect = new Rect(bannerRect.xMax - 160, bannerRect.y + 10, 145, 30);
1634+
if (GUI.Button(buttonRect, "View Migration Guide"))
1635+
{
1636+
Application.OpenURL("https://github.com/CoplayDev/unity-mcp/blob/main/docs/v5_MIGRATION.md");
1637+
}
1638+
EditorGUILayout.Space(5);
1639+
}
1640+
15761641
private bool IsPythonDetected()
15771642
{
15781643
try

0 commit comments

Comments
 (0)