Last active
February 11, 2026 02:30
-
-
Save xiaobin83/b1e788b16f6444cb26ad9cb8eb58f01a to your computer and use it in GitHub Desktop.
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
| using System.Collections.Generic; | |
| using UnityEngine; | |
| using UnityEditor; | |
| namespace Bandigo.Core.Editor.Tools | |
| { | |
| public static class MiscTool | |
| { | |
| [BandigoEditorTool("Sync Trae!", Type = ToolType.Button, Tips = "Sync Project Files with Visual Studio Code (Used by Trae)")] | |
| public static void SyncSolution() | |
| { | |
| var paths = Unity.CodeEditor.CodeEditor.Editor.GetFoundScriptEditorPaths(); | |
| var visualStudioCodePath = string.Empty; | |
| foreach (var p in paths) | |
| { | |
| if (p.Key.Contains("Visual Studio Code")) | |
| { | |
| visualStudioCodePath = p.Key; | |
| } | |
| } | |
| if (string.IsNullOrEmpty(visualStudioCodePath)) | |
| { | |
| return; | |
| } | |
| var path = Unity.CodeEditor.CodeEditor.CurrentEditorPath; | |
| Unity.CodeEditor.CodeEditor.Editor.SetCodeEditor(visualStudioCodePath); | |
| AssetDatabase.Refresh(); | |
| Unity.CodeEditor.CodeEditor.Editor.CurrentCodeEditor.SyncAll(); | |
| AssetDatabase.Refresh(); | |
| Unity.CodeEditor.CodeEditor.Editor.SetCodeEditor(path); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment