46 lines
1.3 KiB
C#
46 lines
1.3 KiB
C#
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using UnityEngine;
|
||
|
using TMPro;
|
||
|
using RPGCreationKit;
|
||
|
using System.IO;
|
||
|
|
||
|
namespace RPGCreationKit
|
||
|
{
|
||
|
public class AvatarFolderName : MonoBehaviour
|
||
|
{
|
||
|
[SerializeField] public TextMeshProUGUI AvatarName;
|
||
|
[SerializeField] public string FolderPath;
|
||
|
[SerializeField] private GameObject ImagePrefab;
|
||
|
[SerializeField] public Transform ImagesContainer;
|
||
|
[SerializeField] List<GameObject> CreatedImagePrefab;
|
||
|
[SerializeField] public GameObject MyGalleryGO;
|
||
|
|
||
|
|
||
|
public void GetFolderImages() {
|
||
|
|
||
|
MyGallery MyGO = MyGalleryGO.GetComponent<MyGallery>();
|
||
|
for (int i = 0; i < MyGO.CreatedImagePrefab.Count; i++) {
|
||
|
MyGO.CreatedImagePrefab[i].SetActive(false);
|
||
|
}
|
||
|
MyGO.CreatedImagePrefab.Clear();
|
||
|
|
||
|
|
||
|
DirectoryInfo dir = new DirectoryInfo(FolderPath);
|
||
|
FileInfo[] info = dir.GetFiles("*.*");
|
||
|
|
||
|
foreach (FileInfo f in info) {
|
||
|
var NewImage = Instantiate(ImagePrefab, ImagesContainer);
|
||
|
MyGO.CreatedImagePrefab.Add(NewImage);
|
||
|
ScreenShotContent SScon = NewImage.GetComponent<ScreenShotContent>();
|
||
|
SScon.LoadCurrentImage(f.ToString());
|
||
|
SScon.MyGalleryGO = MyGalleryGO;
|
||
|
SScon.FileDir = f.ToString();
|
||
|
SScon.DeleteButton.source = MyGO.source;
|
||
|
SScon.Image.source = MyGO.source;
|
||
|
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|