My script isnt working, altough I cant find error that is causing it.

Hello friends, I am working on file reading app (.pdf, .doc…). Currently I was working on the main menu for the app. In this menu should be shown some buttons that are generated by foreach statement via template (foreach file found there is created a button), buttons are composed of some images, text… so the user gets basic info about file. It sounds great but my autogenerate script seems not to work, I am not able to figure out whats wrong, thanks for help :slight_smile:

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, Sprites.GetSprite(Sprites.TypeOfFile.pdf), SplitImage);
        }
    }

    public void CreateFileButton(System.IO.FileInfo f, Sprite TypeOfDoc, Image splitImage)
    {
        Transform FileLinkTemplate = Instantiate(Template, Parent);
        RectTransform TemplateRectTransform = FileLinkTemplate.GetComponent<RectTransform>();


        FileLinkTemplate.Find("NameOfFile").GetComponent<TextMeshProUGUI>().SetText(f.Name);
        FileLinkTemplate.Find("InfoText").GetComponent<TextMeshProUGUI>().SetText(f.CreationTime.ToString("MM dd, yyyy, hh:mm:ss"));
        FileLinkTemplate.Find("TypeOfDoc").GetComponent<Image>().sprite = TypeOfDoc;
        FileLinkTemplate.Find("SplitImage").GetComponent<Image>();

    }
}

Isn’t this the same post as the following where you’ve not replied?

Yes it is, but I dont really know what is the problem, there are no errors in console but nothing happens when I run the game. This is problem that I am short to solve.

Okay so more directly, please don’t just repeat the same posts. You could in the very least reply to devs who are trying to help you.

Yes, I understand.