Skip to content

Commit b0d75b7

Browse files
committed
Fix missing check in SpritePostProcessor
1 parent 513663e commit b0d75b7

2 files changed

Lines changed: 14 additions & 7 deletions

File tree

Assets/SpriteAssist/Editor/Import/SpritePostProcessor.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@ namespace SpriteAssist
55
{
66
public class SpritePostProcessor : AssetPostprocessor
77
{
8-
private void OnPostprocessSprites(Texture2D _, Sprite[] sprites)
8+
private void OnPostprocessSprites(Texture2D tex, Sprite[] sprites)
99
{
10+
string path = AssetDatabase.GetAssetPath(tex);
11+
if(!SpriteAssistSettings.instance.ShouldProcessSprite(path)) return;
12+
1013
SpriteInspector.isSpriteReloaded = true;
1114

1215
TextureImporter textureImporter = assetImporter as TextureImporter;

Assets/SpriteAssist/Editor/Settings/SpriteAssistSettings.cs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,12 @@ public bool ShouldProcessSprite(Sprite s)
4545
{
4646
return false;
4747
}
48-
4948
string path = AssetDatabase.GetAssetPath(s);
49+
return ShouldProcessSprite(path);
50+
}
51+
52+
public bool ShouldProcessSprite(string path)
53+
{
5054
if(string.IsNullOrEmpty(path) || !path.StartsWith("Assets"))
5155
{
5256
return false;
@@ -57,17 +61,17 @@ public bool ShouldProcessSprite(Sprite s)
5761
Regex r = GetRegex(glob);
5862
if(r.IsMatch(path))
5963
{
60-
Debug.Log($"[SpriteAssistSettings] {path} matches {glob}!");
64+
// Debug.Log($"[SpriteAssistSettings] {path} matches {glob}!");
6165
// return true if explicit inclusion is selected, otherwise false for explicit exclusion
6266
return inclusionMode == SpriteAssistInclusionMode.Include;
6367
}
6468
else
6569
{
66-
Debug.Log($"[SpriteAssistSettings] {path} does not match {glob}");
70+
// Debug.Log($"[SpriteAssistSettings] {path} does not match {glob}");
6771
}
6872
}
6973
// fallthru: return true if "include by default", otherwise false
70-
Debug.Log($"[SpriteAssistSettings] No match for {path} found");
74+
// Debug.Log($"[SpriteAssistSettings] No match for {path} found");
7175
return inclusionMode == SpriteAssistInclusionMode.Exclude;
7276
}
7377

@@ -92,11 +96,11 @@ private Regex GetRegex(string glob)
9296
private Regex CompileGlob(string glob)
9397
{
9498
glob = "Assets/" + glob;
95-
Debug.Log($"[SpriteAssistSettings] compiling `${glob}`");
99+
// Debug.Log($"[SpriteAssistSettings] compiling `${glob}`");
96100
return new Regex(
97101
"^" + Regex.Escape(glob).Replace(@"\*", ".*").Replace(@"\?", ".") + "$",
98102
RegexOptions.IgnoreCase | RegexOptions.Singleline | RegexOptions.Compiled
99103
);
100104
}
101105
}
102-
}
106+
}

0 commit comments

Comments
 (0)