how to load texture from C:\ Folder at Runtime build
i use images fot the texture of the material. the images downloading from web page to Resources folder. and it works at runtime mode.
when i build windows exe, i didn't get error message at console.
if i click exe file and open game. it doesnt load the textures. how to load any images,obj models from any folder of hard drive.
Code:
private void ModelGetir()
{
Thread.Sleep(3000);
loadedObj = new OBJLoader().Load("Assets/Resources/Data/Models/" + ModelID + "/Model.obj");
Texture2D textureMain = Resources.Load("Data/Models/" + ModelID + "/Model", typeof(Texture2D)) as Texture2D;
Texture2D textureNormal = Resources.Load("Data/Models/" + ModelID + "/Model_normal", typeof(Texture2D)) as Texture2D;
mat = Resources.Load("SkinMat/Mat", typeof(Material)) as Material;
mat.SetTexture("_BaseColorMap", textureMain);
mat.SetTexture("_NormalMap", textureNormal);
// //-----------------------------------------------------
// matClay = Resources.Load("clay", typeof(Material)) as Material;
// matClay.SetTexture("_BumpMap", textureNormal);
loadedObj.transform.Find("default").GetComponent<Renderer>().material = mat;
loadedObj.layer = 9;
loadedObj.transform.Find("default").gameObject.layer = 9;
loadedObjClone = Instantiate(loadedObj);
loadedObjClone.layer = 10;
loadedObjClone.transform.Find("default").gameObject.layer = 10;
GameObject Head_mesh = loadedObj.transform.Find("default").gameObject;
if (Head_mesh)
{
Head_mesh.AddComponent<MeshCollider>();
Head_mesh.AddComponent<Make_Mesh_Sutable_for_Sculpturing>();
Head_mesh.tag = "Editable";
Debug.Log("Scupting Brush yuklendi");
}
loadingmesaj = "...";
loadingYon = "down";
SetloadedObj = true;
}
Answer by muckenhoupt · Oct 15, 2020 at 01:03 AM
I suggest downloading the images to the StreamingAssets folder instead. (Use Application.streamingAssetsPath at runtime to get its location. Standalone builds have it in a different place than the Unity editor.)
I don't know if that will fix your problem, but it's worth a try. Standalone executables definitely know how to read resources from individual files when they're under StreamingAssets.
Answer by emrexconi · Oct 15, 2020 at 06:41 AM
thank you so much muckenhoupt i'll let you know when i try this.
i have tested and it didnt work.
unity didnt see the path, what is the alternative solition for this
thank you in advance