private void ReadSheetData() { // Read all the text in the File and split it by rows into an array. string[] Rows = System.IO.File.ReadAllText(string.Format("{0}/{1}.csv", Application.dataPath, csvFile.name)).Split('\n'); List <string> EmptyLineFilterList = new List <string>(); for (int i = 0; i < Rows.Length; i++) { if (!string.IsNullOrEmpty(Rows[i]) && !string.IsNullOrWhiteSpace(Rows[i])) { if (Rows[i].Contains("Name,Colour") == false) { // Local Variables string[] split = Rows[i].Split(','); Color currentColour = Color.black; ColorUtility.TryParseHtmlString(split[1], out currentColour); // Create Data HoldVegetationObjectData data = new HoldVegetationObjectData() { BiomesColour = currentColour, type = split[2], AssetPath = split[3], }; vegetationList.Add(data); Debug.Log(data.AssetPath); PlaceObject((GameObject)AssetDatabase.LoadAssetAtPath(data.AssetPath, typeof(GameObject)), /*Placeholder for the position*/ Vector3.zero, data); // Cleanup local variables data = null; split = null; } } } Rows = null; Debug.Log("LOL!"); }
private void PlaceObject(GameObject prefab, Vector3 position, HoldVegetationObjectData data) { GameObject gameObject = Instantiate(prefab, position, Quaternion.identity); gameObject.name = data.Name; }