Skip to content

Commit

Permalink
fix compile error
Browse files Browse the repository at this point in the history
  • Loading branch information
mob-sakai committed Aug 10, 2024
1 parent 3755656 commit fa0abb6
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
3 changes: 2 additions & 1 deletion Packages/src/Editor/ShaderPreProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ 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.Contains("(SoftMaskable)")) return;
var name = shader.name;
if (name != "Hidden/UI/SoftMask" && !SoftMaskUtils.IsSoftMaskableShaderName(name)) 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 @@ -149,8 +149,9 @@ int ParseToInt(string s, int start, int end)
Profiler.EndSample();

return new Vector2Int(w, h);
#endif
#else
return new Vector2Int(Screen.width, Screen.height);
#endif
}
}
}
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.Contains("(SoftMaskable)")
return SoftMaskUtils.IsSoftMaskableShaderName(name)
|| name == "Hidden/UI/SoftMask"
|| name == "Hidden/UI/TerminalMaskingShape";
}
Expand Down
11 changes: 10 additions & 1 deletion Packages/src/Runtime/Utilities/SoftMaskUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,15 @@ public static Material CreateSoftMaskable(
return mat;
}

public static bool IsSoftMaskableShaderName(string name)
{
#if UNITY_2021_2_OR_NEWER
return name.Contains("(SoftMaskable)", StringComparison.Ordinal);
#else
return name.Contains("(SoftMaskable)");
#endif
}

public static Shader GetSoftMaskableShader(Shader baseShader,
UISoftMaskProjectSettings.FallbackBehavior fallback)
{
Expand All @@ -202,7 +211,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.Contains("(SoftMaskable)", StringComparison.Ordinal)) continue;
if (!IsSoftMaskableShaderName(name)) continue;

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

0 comments on commit fa0abb6

Please sign in to comment.