private void OnPreprocessAtlas(string path) { if (!ArtAssetPath.CheckValidAssetPath(path)) { return; } var atlas = context.mainObject as SpriteAtlas; if (atlas != null) { EditorToolSet.AtlasRenamePrefix(assetPath); if (atlas.name.Contains(Rank1TextureSubName)) { spriteAtlasSetting.maxTextureSize = Rank1TextureMaxSize; } else if (atlas.name.Contains(Rank2TextureSubName)) { spriteAtlasSetting.maxTextureSize = Rank2TextureMaxSize; } else if (atlas.name.Contains(Rank3TextureSubName)) { spriteAtlasSetting.maxTextureSize = Rank3TextureMaxSize; } else { spriteAtlasSetting.maxTextureSize = Rank1TextureMaxSize; } atlas.SetPlatformSettings(spriteAtlasSetting); } }
private static void RemoveInvalidPrefix(string goPath, string prefix) { if (!ArtAssetPath.CheckValidAssetPath(goPath)) { return; } var fileName = Path.GetFileNameWithoutExtension(goPath); if (fileName.StartsWith(prefix)) { var length = prefix.Length; var newName = fileName.Remove(0, length); AssetDatabase.RenameAsset(goPath, newName); } }
private static void RenamePrefix(string filePath, string prefix) { if (!ArtAssetPath.CheckValidAssetPath(filePath)) { return; } var fileName = Path.GetFileNameWithoutExtension(filePath); if (string.IsNullOrEmpty(fileName)) { return; } if (fileName.StartsWith(prefix)) { return; } var newName = prefix + fileName; AssetDatabase.RenameAsset(filePath, newName); }