Skip to content

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

@hunterhunted

Description

@hunterhunted

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions