dotBunny / VSCode

Unity Visual Studio Code Integration
MIT License
673 stars 180 forks source link

Files in packages folder not opened to correct path. #174

Open hunterhunted opened 5 years ago

hunterhunted commented 5 years ago

The project folder includes a 'Packages' subfolder now to see the contents of installed packages.

The path it reports with AssetDatabase.GetAssetPath isn't where the actual package items are stored, so when doubleclicking a script in a package VSCode opens a new blank file with unsaved changes instead of viewing the actual contents of the script.

To get the path where the item exists (the one that opens when you right click and choose 'Show in Explorer'), the Path.GetFullPath() method can be used as per https://docs.unity3d.com/Manual/upm-assets.html#GetFullPath

To get it working for me, I've replaced string completeFilepath = appPath + Path.DirectorySeparatorChar + AssetDatabase.GetAssetPath(selected); with string completeFilepath = Path.GetFullPath(selectedFilePath); in the OnOpenedAsset callback.