Skip to content

Conversation

@boobhsi
Copy link

@boobhsi boobhsi commented Apr 14, 2025

This pull request addresses an issue where File.ReadAllText in SetKeywordDeclareType throws a FileNotFoundException when handling .hlsl files that are not specified with an absolute path. This is particularly important for users who utilize relative paths or a special path which consists of Packages and the package name (e.g. Package/com.unity.render-pipelines.universal) to include files in Unity Package Manager.

To enhance flexibility, SetKeywordDeclareType should accommodate file includes specified by absolute paths, relative paths, and package paths.

Changes

  • PackagePathResolver: Added a utility class to retrieve the absolute path for a specified package name.

  • ReadFromAnyPath: Updated the file reading logic to:

    1. Initially attempt to read the included file using the relative path.
    2. Fallback to reading the file using its absolute path if the relative path fails.
    3. As a final resort, extract the package name and resolve its absolute path using PackagePathResolver, then attempt to read the file.

@boobhsi boobhsi changed the title Fix included path resolving for kinds of includes. Enhance Path Resolution for HLSL File Includes Apr 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant