- Home /
Resources.load probleme
I read my txt file with Sources.Load from folder Resources:
TextAsset first_level_;
first_level_ = (TextAsset)Resources.Load ("first_level",typeof(TextAsset));
then I make a string table to have every line of txt as string variable in table
public static string[] first_level_table;
first_level_table = first_level_ .text.Split("\n"[0]);
And on computer it works again completely fine but don't work on phone with android. I read that using TextAsset making it more "Unity" so it should work on every platform... I have txt file's in Resources file, what may be wrong with it? Can Resources be a subfolder or somethink like that?
This works fine here both PC and Android Lollipop(5.1.1) using UnityEngine; using System.Collections;
public class test : $$anonymous$$onoBehaviour
{
TextAsset first_level_;
public static string[] first_level_table;
void Start() {
first_level_ = (TextAsset)Resources.Load ("asd",typeof(TextAsset));
first_level_table = first_level_.text.Split("\n"[0]);
}
void OnGUI(){
for (int i = 0; i < first_level_table.Length; i++) {
GUILayout.TextField(first_level_table[i]);
}
}
}
Answer by rakkarage · Aug 07, 2015 at 09:56 PM
why not just drag the text file to a public TextAsset property?
public TextAsset Town;
...
Debug.Log(Town.text);
Answer by DarmMan · Aug 07, 2015 at 10:10 PM
I did it 20 minutes ago and I think it works so I will let it stay this way, finally all this Unity it's only a tool that exist in our time not art to herself, thanks