Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
avatar image
0
Question by kushG · Sep 11, 2020 at 08:10 PM · error messagelogging

Can I disable Debug.Logerror messages in editor mode ?

I have an editor script(ProviderManager) that is trying to destroy all the components(except some) attached to a gameobject. Few of these components have "RequireComponent" attribute on them so destroying the components that are "required" by other components results in error from Unity. However to avoid this I am running this function in recursion so that the component that cannot be destroyed now will get destroyed later in next iteration. The function works perfectly as I'd want it to work but the issue is Unity prints error messages in console when component destruction is not possible. I want a way to hide these error messages when running this function since I take care of these errors and I don't want them to appear in console.

 private void RemoveAllComponents()
         {
             int length = GetComponents<Component>().Length;
             if (length<= 3)
             {
                 return;
             }
 
             foreach (var comp in GetComponents<Component>())
             {
                 //Don't remove the Transform  and SturfeeXRSession component
                 if (!(comp is Transform) && !(comp is SturfeeXRSession))
                 {
                     //Don't remove this script
                     if (!(comp is ProviderManager))
                     {
 
                         Debug.Log(" Destroying " + comp.ToString());
 
                         Debug.unityLogger.logEnabled = false;                      
                         DestroyImmediate(comp);     // prints error message in console
                         Debug.unityLogger.logEnabled = true;
                     }
                 }
             }
 
             RemoveAllComponents();
         }

alt text

screen-shot-2020-09-11-at-10910-pm.png (112.7 kB)
Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by N-8-D-e-v · Sep 12, 2020 at 10:57 AM

In the upper right corner of your screenshot, there are three icons. White, (should be yellow but its grayed out), and red. Click on the red icon with the '3' next to it to disable any error messages.

Comment
Add comment · Show 6 · 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
avatar image kushG · Sep 12, 2020 at 04:43 PM 0
Share

I meant to not have those logs appear in console at all. The code is part of a plug-in I wrote which will be used by many users. I don't want these users to get confused by looking into this error and assu$$anonymous$$g the code has bugs. I want something like try catch which in this case is catching an error thrown by Debug.LogError within Unity's code

avatar image N-8-D-e-v kushG · Sep 13, 2020 at 01:29 AM 0
Share

then you would in fact use a try catch statement https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/try-catch

avatar image kushG N-8-D-e-v · Sep 13, 2020 at 05:50 PM 0
Share

When you write something on console using Debug.Logerror it just appears on console in red. It doesn't throw any exception of any sort. If there is no exception I cannot try catch the exception and hence the issue.

Show more comments

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

136 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

Related Questions

How can i connect to the asset store? 2 Answers

Trying to read out of a website and wan't to store the value. Works perfect in Unity and Desktop Build. Any Ideas? 1 Answer

Assets/Standard Assets/CrossPlatformInput/Scripts/MobileControlRig.cs(57,37): error 0 Answers

Unable to parse file ProjectSettings/ProjectVersion.txt: - And other fun errors 2 Answers

Object reference not set to an instance of an object with Assembly-CSharp 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