Skip to content

Commit

Permalink
feat: support for shaders with (SoftMaskable) in the name except at…
Browse files Browse the repository at this point in the history
… the end
  • Loading branch information
mob-sakai committed Aug 10, 2024
1 parent ce20306 commit 3755656
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ internal class SoftMaskableShaderModifier : TextAssetModifier
public static Modifier Create(string path)
{
var shader = AssetDatabase.LoadAssetAtPath<Shader>(path);
if (!shader || !shader.name.Contains(" (SoftMaskable)")) return null;
if (!shader || !shader.name.Contains("(SoftMaskable)")) return null;

return new SoftMaskableShaderModifier
{
Expand Down
2 changes: 1 addition & 1 deletion Packages/src/Editor/ShaderPreProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public override void OnProcessShader(Shader shader, ShaderSnippetData snippet,
IList<ShaderCompilerData> data)
{
// If the shader is not SoftMask/SoftMaskable, do nothing.
if (shader.name != "Hidden/UI/SoftMask" && !shader.name.EndsWith(" (SoftMaskable)")) return;
if (shader.name != "Hidden/UI/SoftMask" && !shader.name.Contains("(SoftMaskable)")) return;

// Remove the 'SOFTMASK_EDITOR' shader variants.
var editor = new ShaderKeyword(shader, "SOFTMASK_EDITOR");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ internal static bool CanIncludeShader(Shader shader)
if (!shader) return false;

var name = shader.name;
return name.EndsWith(" (SoftMaskable)")
return name.Contains("(SoftMaskable)")
|| name == "Hidden/UI/SoftMask"
|| name == "Hidden/UI/TerminalMaskingShape";
}
Expand Down
2 changes: 1 addition & 1 deletion Packages/src/Runtime/Utilities/SoftMaskUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ public static Shader GetSoftMaskableShader(Shader baseShader,
for (var i = 0; i < s_SoftMaskableShaderNameFormats.Length; i++)
{
var name = string.Format(s_SoftMaskableShaderNameFormats[i], shaderName);
if (!name.EndsWith(" (SoftMaskable)", StringComparison.Ordinal)) continue;
if (!name.Contains("(SoftMaskable)", StringComparison.Ordinal)) continue;

var shader = Shader.Find(name);
if (!shader) continue;
Expand Down

0 comments on commit 3755656

Please sign in to comment.