- Home /
Unity Editor Crashes On Play Because of Import Script
I'm building an importer in C# that's meant to parse through the text of an FBX ASCII file, and build a model based on what it finds. However, whenever I try to execute the main function, the unity editor stops responding.
The main hangup I have is that the first statement of the function is a Debug.log() call, but that's never executed. I know that there are multiple infinite loops in the function, but these should all have breaks/returns (or at least have debug calls in case they hang up so I can look into them).
So, any thoughts on why a script would crash before executing the first statement? I hesitate to post the code because it's 600 lines, and no one part seems to have a special impact since I can't actually get anywhere in the execution anyway.
As a bit more context, the editor will run fine, even with references to the script (attached to an object, assigned as a variable in another script), just as long as I don't call it's main function.
For those interested here's a link to the code. Also to clarify, ImportAllFBX() is called from a different script.
It seems you have many function, but you are not calling any of them?
Sorry I should have clarified. ImportAllFBX() is called from a different script.
Answer by vividhelix · Jul 22, 2013 at 04:21 PM
To narrow the problem down, add a return statement after the Debug.Log(). If that makes it stop hanging, you know the problem is in your script. You can work with moving the return statement around to pinpoint where your problem is (basically executing just parts of your code).
Okay, so I did what radlemur said (push return statements at various lines to find when the code breaks) which lead me to the problem. The top while(true) loop didn't have an escape. I forgot to break when I hit the end of the file.