When sharing code, put it in code tags:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
using System.IO;
using System.Linq;
public class FileCreatorLinks : MonoBehaviour
{
public Transform Template;
public Transform Parent;
public Image SplitImage;
public void Start(int positionIndex, PDFExtraction pdfExtraction, Sprites sprites)
{
DirectoryInfo directory = new DirectoryInfo("Assets/Resources/");
FileInfo[] info = directory.GetFiles("*.pdf*");
foreach(FileInfo f in info)
{
CreateFileButton(f.Name, f.CreationTime, Sprites.GetSprite(Sprites.TypeOfFile.pdf), SplitImage);
}
}
public void CreateFileButton(string FileName, string FileInfo, Sprite TypeOfDoc, Image SplitImage)
{
Transform FileLinkTemplate = Instantiate(Template, Parent);
RectTransform TemplateRectTransform = FileLinkTemplate.GetComponent<RectTransform>();
FileLinkTemplate.Find("NameOfFile").GetComponent<TextMeshProUGUI>().SetText(FileName);
FileLinkTemplate.Find("InfoText").GetComponent<TextMeshProUGUI>().SetText(FileInfo);
FileLinkTemplate.Find("TypeOfDoc").GetComponent<Image>().sprite = TypeOfDoc;
FileLinkTemplate.Find("SplitImage").GetComponent<Image>();
}
}