Hi unity developers.
Really need your help on this matter.
I am rather new on Unity development but after searching for the solution online I couldn’t find anything on this.
I am saving a screenshot as a png file to save a model greated in my game.
Then to reload the model I create a list of buttons with the picture of each model inside it.
The problem is when I have saved a model with a greek name (“τεστ”) the button does not show the image but a small question mark, like is not finding the picture “τεστ.png”.
I read the directory of the saved models and save each picure in an array using the following code:
var info = new DirectoryInfo(Application.dataPath+"/Resources/ModelsLibrary/");
var fileInfo = info.GetFiles("*.png");
libraryModelImages = new Texture2D[0];
libraryModelNames = new String[0];
for (file in fileInfo){
var texName:String = file.Name.Substring(0,file.Name.Length-4);
var compositeName = modelsDirectory+texName;
//var aTexture:Texture2D = Resources.Load(compositeName,Texture2D);
var aTexture:Texture2D = startupScript.loadTex(Application.dataPath+"/Resources/"+modelsDirectory+file.Name);
aTexture.name = texName;
libraryModelImages += [aTexture];
Debug.Log("Model name: "+libraryModelImages.name);
libraryModelNames += [texName];
}
where "Debug.Log("Model name: “+libraryModelImages.name);” shows the name in greek just fine and later show the list of model with pictures on buttons like this:
var modelButtonRect:Rect = Rect(25,25,128,64);
for (idx=0;idx<libraryModelImages.length;idx++){
Debug.Log("model name:"+libraryModelImages[idx]);
//MODELS BUTTONS
if (GUI.Button(modelButtonRect,libraryModelImages[idx])){
selectedModelIdx = idx;
textFieldString = libraryModelNames[selectedModelIdx];
//Debug.Log("dblClick:"+dblClick);
if(dblClick){
var allPieces = GameObject.FindGameObjectsWithTag("Piece");
for (var piece in allPieces){
startupScript.destroyPiece(piece);
}
loadModel(false,null);
modelsLibraryWindow = false;
}
}
//adjust button rectangles for rows and columns
modelButtonRect.x += 135;
if (modelButtonRect.x> 500){
modelButtonRect.x = 25;
modelButtonRect.y += 71;
}
}
In the above code “Debug.Log(“model name:”+libraryModelImages[idx]);” also shows the grek name of the file, but it does load it.
So what am I doing wrong? Can I fix it?