Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

in C# or JS... How do you close development build console log while playing ?

Discussion in 'Scripting' started by particleice, May 22, 2017.

  1. particleice

    particleice

    Joined:
    Oct 29, 2016
    Posts:
    11
    ....
     
    Last edited: Jul 12, 2017
  2. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,350
    You can right-click on the console tab and select "Close Tab". But you should probably read those errors at some point. ;)
     
  3. particlemars

    particlemars

    Joined:
    Nov 20, 2016
    Posts:
    30
    I can't... I have is "NullReferenceException: Object reference not set to an instance of an object". I don't know where the error is coming from.
     
  4. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,744
    You may be looking for try ... catch here. If the error is something that you expect to happen sometimes, you will want to enclose that block of code in try { code } catch (Exception e) { } so that the error doesn't bring the rest of your scripts to a grinding halt. This is common practice during things like loading saved games from files, since you never know when you're going to receive a bad file.

    However - and this is a crucial "however" - if you don't know what's causing them and/or didn't expect the errors - do not do that because these errors are a good thing. They give you vital information for how to fix the problem.

    If you double-click on the error, it'll open your code editing application at the exact line that is causing the error. If you need more information than that, click on the error, you'll see underneath it a "stack trace", which shows the script files and line numbers of every function call that led to this error.
     
    Ryiah likes this.