When i load an instance with : UnityEngine.Resources.Load unity load infinite clone of the object. How to stop the load of the object? This is the code: Code (csharp): function Start() { var oggetto = new Array(); oggetto = fileread("hero.txt"); var i : int = 0; print((oggetto.length)-1); while(oggetto.length!=i+1){ print(oggetto[i]); enemy = Instantiate(UnityEngine.Resources.Load(oggetto[i])); //enemy = Instantiate(UnityEngine.Resources.Load(oggetto[i],GameObject)); i++; if(oggetto.length==i) break; } enemy = null; DestroyImmediate(enemy); } I try with enemy=null and with destroy, and this stop the loading of the objet, but unity continue to try to load the null object and return "Null Reference Expection..." Thank you! =)
Ok, resolved: i edit the function CreateEnemy() Code (csharp): function CreateEnemy() { if(oggetto.length!=j+1){ var newEnemy = Instantiate(enemy, Vector3(0,0,0), Quaternion.identity); } }