I must use this script for read a name of a object from a text file and create the objecy that i had read at runtime … but there are some errrs , help me please …
import System.IO;
import System;
import System.Text;
private var enemy : GameObject;
function Start() {
fileread("test.txt");
enemy = Instantiate(Resources.Load("line", GameObject));
}
unction fileread (filename : String) {
try {
var sr = new StreamReader( Application.dataPath+"/"+filename);
var line : String = sr.ReadLine();
//print(line);
return line;
sr.Close();
sr = null;
}
catch (e) {
Debug.Log("internal error!");
return null;
}
}
function Update () {
CreateEnemy();
}
function CreateEnemy() {
var newEnemy = Instantiate(enemy, Vector3(0,0,0), Quaternion.identity);
}
}
Thank You …