Skip to content

Commit a869cfb

Browse files
SamCYuEvergreen
authored andcommitted
Fixed custom function node extension case sensitivity validation
1 parent 1c2f829 commit a869cfb

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Packages/com.unity.shadergraph/Editor/Data/Nodes/Utility/CustomFunctionNode.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ enum SourceFileStatus
6060
};
6161

6262
// With ShaderInclude asset type, it should no longer be necessary to soft-check the extension.
63-
public static string[] s_ValidExtensions = { ".hlsl", ".cginc", ".cg" };
63+
public static HashSet<string> s_ValidExtensions = new HashSet<string>() { ".hlsl", ".cginc", ".cg" };
6464
const string k_InvalidFileType = "Source file is not a valid file type. Valid file extensions are .hlsl, .cginc, and .cg";
6565
const string k_MissingFile = "Source file does not exist. A valid .hlsl, .cginc, or .cg file must be referenced";
6666
const string k_MissingOutputSlot = "A Custom Function Node must have at least one output slot";
@@ -367,7 +367,7 @@ static bool IsValidFunction(HlslSourceType sourceType, string functionName, stri
367367
if (string.IsNullOrEmpty(path))
368368
path = functionSource;
369369

370-
string extension = Path.GetExtension(path);
370+
string extension = Path.GetExtension(path).ToLower();
371371
return s_ValidExtensions.Contains(extension);
372372
}
373373
}
@@ -417,7 +417,7 @@ public override void ValidateNode()
417417
string path = AssetDatabase.GUIDToAssetPath(functionSource);
418418
if (!string.IsNullOrEmpty(path) && AssetDatabase.LoadAssetAtPath<UnityEngine.Object>(path) != null)
419419
{
420-
string extension = path.Substring(path.LastIndexOf('.'));
420+
string extension = path.Substring(path.LastIndexOf('.')).ToLower();
421421
if (!s_ValidExtensions.Contains(extension))
422422
{
423423
fileStatus = SourceFileStatus.Invalid;

0 commit comments

Comments
 (0)