0
I am making a new application and need to upload photo from a specific directory on the computer in this case c:\\Biosearchassets
for a Gui Texture in unity3d I was able to find an example but it uses the texture2D
and I want to load in 3D Gui Texture tried to change the code but get this error
Assets/Loadimage.Cs(42,29): error CS1503: Argument '#1' cannot Convert 'Unityengine.Texture' Expression to type 'Unityengine.Texture2d'
My code is
using UnityEngine;
using System.Collections;
public class LoadImage : MonoBehaviour {
GameObject[] gameObj;
Texture[] textList;
string[] files;
string pathPreFix;
// Use this for initialization
void Start () {
//Change this to change pictures folder
string path = @"C:\Biosearchassets\";
pathPreFix = @"file://";
files = System.IO.Directory.GetFiles(path, "*.jpg");
gameObj= GameObject.FindGameObjectsWithTag("Pics");
StartCoroutine(LoadImages());
}
void Update () {
}
private IEnumerator LoadImages(){
//load all images in default folder as textures and apply dynamically to plane game objects.
//6 pictures per page
textList = new Texture[files.Length];
int dummy = 0;
foreach(string tstring in files){
string pathTemp = pathPreFix + tstring;
WWW www = new WWW(pathTemp);
yield return www;
Texture texTmp = new Texture(1024, 1024, TextureFormat.DXT1, false);
www.LoadImageIntoTexture(texTmp);
textList[dummy] = texTmp;
gameObj[dummy].GetComponent<Renderer>().material.SetTexture("_MainTex", texTmp);
dummy++;
}
}
}