public static void RemoveSpriteFromAtlas(string assetPath) { if (!LoadSettings(out AtlasGeneratorSettings generatorSettings, out AtlasGeneratorAtlasSettings atlasSettings)) { return; } var dirty = TryGetMatchedRule(assetPath, generatorSettings, out var matchedRule); if (!dirty) { return; } AtlasGenerator.RemoveFromAtlas(matchedRule, null, assetPath); AssetDatabase.SaveAssets(); }
public static bool ApplyGenerationRule( string assetPath, string movedFromAssetPath) { var dirty = false; var generatorSettings = AtlasGeneratorSettings.Asset; var atlasSettings = AtlasGeneratorAtlasSettings.Asset; if (!string.IsNullOrEmpty(movedFromAssetPath) && TryGetMatchedRule(movedFromAssetPath, generatorSettings, out var oldMatchedRule)) { dirty |= AtlasGenerator.RemoveFromAtlas(oldMatchedRule, movedFromAssetPath, assetPath); } if (TryGetMatchedRule(assetPath, generatorSettings, out var matchedRule)) { var atlas = AtlasGenerator.CreateOrUpdateAtlas(generatorSettings, atlasSettings, matchedRule, assetPath); dirty = true; Log(LogType.Log, $"Added sprite {assetPath} to atlas {atlas.name}"); } return(dirty); }