- Home /
"MonoBehaviour with new" warning has no line number
I'm getting the "You are trying to create a MonoBehaviour using the 'new' keyword." error, but it doesn't tell me what file/line this is happening. My project is huge by this point, it could be anywhere.
Edit: I know why the warning is being shown. But the problem is unlike other warnings/errors, Unity doesn't show the class or line number where it's occurring.
We have 10,000+ lines of code and somebody just noticed this. We can look through every line with new
or where we've subclassed MonoBehaviour
but I was wondering if there was a quicker way.
Does anyone know how to find the source of these warnings?
Answer by Riagan · Jul 18, 2013 at 06:21 AM
This might be a repeat... try this link:
Thanks for the quick reply. I know why the warning is being shown. But the problem is unlike other warnings/errors, Unity doesn't show the class or line number where it's occurring. We have 10,000+ lines of code and somebody just noticed this. We can look through every instance of "new" or where we've subclassed $$anonymous$$onoBehaviour but I was wondering if there was a quicker way.
Answer by Jamora · Jul 18, 2013 at 06:35 AM
You should be able to double click on errors/warnings/log messages in the console to open your IDE at the correct line. At least Mono opens the file at the line the message was sent from after double clicking on the console message.
That usually works for me, but nothing happens when I click on this particular type of error message. There is no filename or line number either.
Your answer
Follow this Question
Related Questions
Error trying to createMonoBehaviour using the 'new' keyword in cSharp script 4 Answers
You are trying to create a MonoBehaviour using the 'new' keyword. This is not allowed. 2 Answers
MonoBehaviours can only be added using AddComponent(). Alternatively. 1 Answer
Unity - UI Dropdown uses constructor for DropDownItem 0 Answers
Unity 2D rotation speeds problem 1 Answer