Hi! I have a doubt , I would like the player podesse import an image for the game ( Android ) to be the face of the character, I made a way , but it only works in " Editor of Unity " , when I export it does not work , one could help me?
IEnumerator ImportPng(string Url){
File.Copy(Url, Application.dataPath+"/Teste.Png");
string tmp = Application.dataPath+"/Teste.Png";
WWW www = new WWW("file:///" + tmp);
yield return www;
renderer.material.mainTexture = www.texture;
}
I did it! The problem was in the path of the image ! By default is : "C: \ Test \ Img.Jpg " But the Unity understood the “\ " as line break (or almost, is missing the " n” ) So what I did was do a Replace ! For everything you have "\ " turn “/” ! I’ll post here if anyone else has doubts :
IEnumerator Selecionar(string Url) {
string tmp = "file:///"+ Url; //It is necessary to have three bars (/// ) if the url is a Local file(C:/Teste/Img.jpg)
tmp=tmp.Replace(@"\", "/");//As the Unity recognizes \ as a line break (or almost) , put the @ to not give the error :)
WWW www = new WWW(tmp);
yield return www;
renderer.material.mainTexture = www.texture;
}