привет помоги с рефакторингом кода для Unity
 public class PdfFilesUI : MonoBehaviour
    {
        private const string PathName = "/StreamingAssets/PDF";

        [SerializeField]
        private Transform _contentButton;
        [SerializeField]
        private Transform _contentImage;
        [SerializeField]
        private PDFbutton _button;
        [SerializeField]
        private Image _image;

        private string pdfConverterPath;

        private Dictionary<Button, Image[]> buttonToImagesMapping = new Dictionary<Button, Image[]>();
        private List<Image[]> allImageGroups = new List<Image[]>();
        public void Initialized()
        {
            FindPdfFiles();
        }

        private void FindPdfFiles()
        {
            string folderPath = Application.dataPath + PathName;
            string[] pdfFiles = Directory.GetFiles(folderPath, "*.pdf", SearchOption.AllDirectories);

            pdfConverterPath = Application.dataPath + "/../Converter/pdf2img.exe";

            foreach (string file in pdfFiles)
            {
                UnityEngine.Debug.Log("Найден PDF файл: " + file);
                string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(file);
                UnityEngine.Debug.Log("файл: " + fileNameWithoutExtension);
                var button = Instantiate(_button, _contentButton);
                button.Initialized(fileNameWithoutExtension, file);

                int pageCount = 0;

                using (PdfReader reader = new PdfReader(file))
                {
                    pageCount = reader.NumberOfPages;
                }

                var imageGroup = new Image[pageCount];

                for (int pageNumber = 0; pageNumber < pageCount; pageNumber++)
                {
                    CallExternalProcess(pdfConverterPath, file + " pageRight.png " + (pageNumber).ToString());
                    var image = ApplyTextureToUI(Application.dataPath + "/../pageRight.png");
                    imageGroup[pageNumber] = image;
                }

                allImageGroups.Add(imageGroup);

                button.Button.onClick.AddListener(() => AllImagesOn(imageGroup));

                buttonToImagesMapping[button.Button] = imageGroup;
            }

            AllImagesOff();
        }

        public void AllImagesOff()
        {
            foreach (Image[] images in allImageGroups)
            {
                foreach (var image in images)
                {
                    image.gameObject.Deactive();
                }
            }
        }

        public void AllImagesOn(Image[] imageGroup)
        {
            AllImagesOff();

            foreach (Image image in imageGroup)
            {
                image.gameObject.Active();
            }
        }

        public static Texture2D LoadPNG(string filePath)
        {
            Texture2D texture = null;
            byte[] fileData;

            if (File.Exists(filePath))
            {
                fileData = File.ReadAllBytes(filePath);
                texture = new Texture2D(2, 2);
                texture.LoadImage(fileData);
            }

            return texture;
        }

        public Image ApplyTextureToUI(string filePath)
        {
            Texture2D texture = LoadPNG(filePath);

            if (texture != null)
            {
                Sprite sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f), 100.0f);

                var image = Instantiate(_image, _contentImage);
                image.sprite = sprite;
                return image;
            }
            return null;
        }

        public static void CallExternalProcess(string processPath, string arguments)
        {
            Process myProcess = new Process();
            myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
            myProcess.StartInfo.CreateNoWindow = true;
            myProcess.StartInfo.UseShellExecute = false;
            myProcess.StartInfo.FileName = processPath;

            myProcess.StartInfo.Arguments = arguments;
            myProcess.EnableRaisingEvents = true;
            myProcess.Start();
            myProcess.WaitForExit();
            int ExitCode = myProcess.ExitCode;
        }
    }