-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLoad_External_Image.cs
More file actions
34 lines (29 loc) · 933 Bytes
/
Load_External_Image.cs
File metadata and controls
34 lines (29 loc) · 933 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Load_External_Image : MonoBehaviour
{
private string _Path = "";
[Header("JPG")]
[SerializeField] private List<Texture2D> _Images = new List<Texture2D>();
private string[] _Files_JPG;
private string pathPreFix = @"file://";
void Start()
{
_Files_JPG = System.IO.Directory.GetFiles(_Path, "*.jpg");
StartCoroutine(LoadImages());
}
private IEnumerator LoadImages()
{
//Load JPG
foreach (string tstring in _Files_JPG)
{
string pathTemp = pathPreFix + tstring;
WWW www = new WWW(pathTemp);
yield return www;
Texture2D texTmp = new Texture2D(1024, 1024, TextureFormat.DXT1, false);
www.LoadImageIntoTexture(texTmp);
_Images.Add(texTmp);
}
}
}