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 brycem24 · Jul 01, 2015 at 11:42 PM · c#errorunityeditorcompilerwarning

How to check if the compiler has an error.

Is there a way through C# to detect if the compiler receives a warning or an error? I am looking for an event based way, but alternatives would work. I don't necessarily need the cause of the error just the fact that an error occurred in the first place. I imagine it's buried in UnityEditor somewhere. Any help is appreciated.

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
1
Best Answer

Answer by Dave-Carlile · Jul 02, 2015 at 12:06 AM

You can register a log handler callback and intercept the log messages. That might give you what you want? The catch is that the logging threaded so anything you do there has to be thread safe...

 Application.RegisterLogCallbackThreaded(LogHandler);


I use this to write log messages to my console...

 void LogHandler(string logString, string stackTrace, LogType type)
 {
     lock (thisLock)
     {
         Console.WriteLine(logString);
         LogInternal(logString, stackTrace, type);
     }
 }


Oh, as I write this there's a non-threaded version of this too - Application.RegisterLogCallback...

Comment
Add comment · Show 3 · 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 brycem24 · Jul 02, 2015 at 12:31 AM 0
Share

Hi Dave, I fiddled around with this for a bit and this is what I want but I am not sure how to implement it. I am using this for an editor extension to check if the user has received an error, but I am confused on how this works. Application.RegisterLogCallback in Unity 5 has become deprecated and replaced with Application.log$$anonymous$$essageReceived. This seems to be the same thing. However, since I don't intend on running the game and using this. Is there a way to use the delegate when the application isn't running. If that answer is no, it leaves me even more confused. What is the purpose of detecting errors in runtime, considering with fatals errors because the application cannot be run in the first place? To sum up a bit, I am looking for a way to check if an error occured on compile in the editor. Essentially as soon as the console sees it. Thanks for the help.

avatar image Dave-Carlile · Jul 02, 2015 at 12:40 AM 0
Share

Hah, guess I hadn't noticed it was deprecated yet - I'll have to change that. :)

You should be able to hook up the event in a script that's runs during edit mode (by using the ExecuteInEdit$$anonymous$$ode attribute)

avatar image brycem24 · Jul 02, 2015 at 03:22 PM 0
Share

Hi Dave, after some work on it and frustration. I realized that my [ExecuteInEdit$$anonymous$$ode] attribute was in the wrong place. That is why I was having issues with it being called only in-game. While it seems to be buggy with fatal errors and exceptions. It works just fine with errors occuring during runtime, and that I can deal with. Thanks for your help!

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

22 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

Related Questions

No Monobehaviour scripts in files 1 Answer

Compiler errors while switching to android 1 Answer

Problem with Mono compiler 0 Answers

Distribute terrain in zones 3 Answers

Unity Internal Compiler Error, not there in Editor 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