- Home /
Error in Build but not in Editor - output_log.txt debug problem
UPDATE : Found what is the line that is causing the issue (updated example). Still no idea how to fix it....
So I'm executing this function on Update()
var pickUpObjectsInSightList = new List.<Transform>(); //Contains a list of all the objects the current actor can see.
function PickUpObjectsInSight (){
for(var pickUpObject : Transform in objManager.pickUpObjectList){
var objectCenter : Vector3;
objectCenter = pickUpObject.renderer.bounds.center;
}
}
Now when I'm in the editor everything works fine but, when I do a build I start to get errors on the log that change the behaviour. I can't figure out what the problem is. It's my first time actually learning about the output_log...
NullReferenceException
at (wrapper managed-to-native) UnityEngine.Transform:INTERNAL_get_position (UnityEngine.Vector3&)
at UnityEngine.Transform.get_position () [0x00000] in <filename unknown>:0
at Player_Properties.PickUpObjectsInSight () [0x00000] in <filename unknown>:0
at Script_Wife.Update () [0x00000] in <filename unknown>:0
(Filename: Line: -1)
Any help very appreciated!
Answer by castor · Mar 19, 2014 at 05:54 AM
Found the problem. It was totally my fault but I might as well share it here in case other people fall in the same trap.
I had written a piece of code to allow me to remove test object from the release build (if they have a certain flag set as true):
if (isDebugOnly && !Debug.isDebugBuild){
Destroy(gameObject);
}
But this code was written AFTER this other line:
objManager.pickUpObjectList.Add (transform);
Causing it to destroy the object AFTER it was added to the list and ONLY on the actual build!! argh!