It’s 1 AM and I have been trying to get this to work for some hours now. I just want to load a simple text file containing some numbers(created by a level generator), then I would use them to create a map. I am using this path: Path.Combine(Application.streamingAssetsPath, “level01.txt”) Everything works in the editor but on the android device, only the UI is loaded. I am using unity version 2018/3/0f2.
[145136-map.txt*_|145136]
Full code:
using Assets.Scripts;
using System.IO;
using UnityEngine;
public class MapGenerator : MonoBehaviour
{
public int width = 15;
public int height = 15;
public GameObject[] tileMap = new GameObject[6];
private GameObject hexPrefab;
public static int[] tileType = new int[225];
public static int[] tileAttr = new int[225];
private const float scaleMultiplyer = 5f;
private const float xOffset = 1.037f * scaleMultiplyer;
private const float zOffset = 0.896f * scaleMultiplyer;
private const float levitation = 0.5f;
private const int size = 225;
private void Start()
{
//Reading the numbers into an array
string[] asd = new string;
using (StreamReader sr = new StreamReader(Path.Combine(Application.streamingAssetsPath, "level01.txt")))
{
string line = "";
for(int I = 0; I < size; I++)
{
line = sr.ReadLine();
asd *= line;*
}
}
//This is for getting the tile from the number
for (int l = 0; l < tileType.Length; l++)
{
char[] row = asd[l].ToCharArray();
tileType[l] = int.Parse(row[0].ToString());
string newString = asd[l].Remove(0, 1);
tileAttr[l] = int.Parse(newString);
}
//I am using a hexagonal map
int i = 0;
for (int x = 0; x < width; x++)
{
for (int y = 0; y < height; y++)
{
float xPos = x * xOffset;
if (y % 2 == 1)
{
xPos += xOffset / 2f;
}
hexPrefab = tileMap[tileType*];*
hexPrefab.GetComponent().arrtibutes = tileAttr*;*
GameObject hex = Instantiate(hexPrefab, new Vector3(xPos, 0.5f, y * zOffset), Quaternion.identity);
hex.name = “Hex_” + x + “_” + y;
hex.transform.SetParent(this.transform);
i++;
}
}
}
}
_*