Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by OlliIllustrator · Aug 25, 2018 at 10:11 AM · debugmonobehaviournewwarning

Is there a way to find out where this warning was triggered? "You are trying to create a MonoBehaviour using the 'new' keyword. "

I am sitting in front of a complex project where I get the Monebehavior new warning.

 You are trying to create a MonoBehaviour using the 'new' keyword.  This is not allowed.  MonoBehaviours can only be added using AddComponent().  Alternatively, your script can inherit from ScriptableObject or no base class at all

Unfortunately the warning does not mention the script that does this.

i know what this means ,that there is a script trying to instantiate a Monebehavior up with "new", but the error message does not give a hint where to start looking and the project runs fine otherwise. The project has gone through some years of experiments and I must have overlooked the warning all the years-- I know I made a decision at more than point to use Monobehaviors instead of class objects and rewrote the classes , might have been I have forgotten a script that still tries to create those-- but where to start looking? Makes no sense to wade through all scripts using the new keyword, that would take forever.

Does anyone know a trick how to find out where this warning is being triggered?

Thanks in advance:-)

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image tormentoarmagedoom · Aug 25, 2018 at 10:19 AM 0
Share

Comence disabling scripts, 1 by 1 until you see the error disapear to detect whicch script is.

avatar image OlliIllustrator · Aug 25, 2018 at 12:32 PM 0
Share

Okay, I am commenting this myself since I have found a way to deal with this:

You can enable full strack trace logging for warnings in the console window in Unity (tiny icon on the right, three parallel lines). When this is enabled Unity gave me the necessary information to find the script that gave me the error.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by OlliIllustrator · Aug 25, 2018 at 10:43 AM

Edit: found a solution: Okay, I am commenting this myself since I have found a way to deal with this:

You can enable full strack trace logging for warnings in the console window in Unity (tiny icon on the right, three parallel lines). When this is enabled Unity gave me the necessary information to find the script that gave me the error.

//****OLD text

Thanks for the idea--- but Hmm-- disabling my scripts one after the other will very soon lead to errors stopping the runtime. Also components that do not use "Start" or "Update" cannot be disabled. I was hoping for some way to make Unity give me more information about where the warning is being triggered.

I might try to simply disable groups of Objects to see if the error goes away, hoping the script resides on an object that is not interlinked with others too much to break execution, but that is also not really a reliable and methodically clean way to find the cause---

I read somewhere you can force Unity to treat warnings as errors-- I will give that a try, see if that gives more info.

*EDIT: I created the file mcs.rsp at theroot of the asset directory and added the line "-warnaserror+" to it. It worked and stopped my build with several errors that were warnings before, but unfortunately not the one I am hunting :-(

tormentoarmagedoom · vor 6 minutes 0

Comence disabling scripts, 1 by 1 until you see the error disapear to detect whicch script is.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

153 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

You are trying to create a MonoBehaviour using the 'new' keyword. This is not allowed. 0 Answers

mistyping MonoBehaviour functions 0 Answers

2.5D look at mouse 1 Answer

3D Objects disappear when running the build 0 Answers

Debugging on an Android device which I don't have 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges