- Home /
AddComponent is making Unity crash
timer = new GameObject("moveTimer"); timer.AddComponent(MovementTimer);
Hi, I'm using the code above to add a script to a new GameObject. but the "addcomponent" line seems to make Unity freeze during runtime. I really don't have a clue what could be causing this as there is no error message. Has this ever happened to anyone before?
It would help to see the code of "$$anonymous$$ovementTimer". I guess you created an infinite loop in that script which will of course crash Unity.
If there's something in the Start of that script, then yeah it'd do that.
Answer by Thardus · Nov 06, 2011 at 09:15 PM
Thanks guys, I just realized I had an infinite loop in my start method for MovementTimer
Answer by Jehos · Nov 07, 2011 at 11:16 AM
I didn't mean to mark my answer as the correct one, if that's what you mean. I merely mean to mark this question as answered overall.
I (and probably others), browse in here a few times and in a very limited time a day. I try to help with whatever I can, the same way others have (and do) help me constantly.
When I come here, I filter by unanswered questions and I've been finding a lot of questions already answered that are not marked as answered, and it's a waste of valuable time that could get someone unstuck with a problem.
I could care less about having answered questions or badges or any other stuff. I do this to give back to a community that has constantly helped me selflessly.
Then add a comment that tells one of the other commenters to convert his comment to an answer, that may then be marked as the right answer. :P
You're right.
I didn't know the difference between comment and answer.
I though comment was like a quick reply and answer was like a formatted one. I see now this forum has this karma useless thing implemented.
It's my first time in here.
Well... You're kind of right. An answer IS a more formatted reply. The problem is that the powers that be wanted a Q&A board with searchable questions and attached answers, but have seen fit to implement something that looks like a forum and is therefore treated like a forum by its users. And so, desperate for precious order, the powers that be tirelessly work to inflict Q&A behavior on the users ins$$anonymous$$d of designing the board so that it follows naturally. ;) Wonderful, don't you think?
$$anonymous$$arma isn't entirely useless. It bestows certain moderator powers on the users so the more advanced ones can help improve the board.
I absolutely agree.
Also, purely in terms of design and pragmatic use of the board, it's much harder to find the small "add comment" button than the big "Post your answer" :) (for me at least, as a new user).
I just answered in another Q&A forum and did the same thing. But I learned! Edited and answered as comment.