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 tonycoculuzzi · Jul 30, 2012 at 02:42 AM · webplayerconsoledebug.logconsole.log

Is there a way to make Console events write to the web browser's console?

I'm wondering, is there a way to have Debug.Log, Debug.LogWarning and Debug.LogError write to the web browser's console when building to the web player? That way, errors and warnings will write to the web browser's console (example - chrome: console.log) in order to see where something went wrong.

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

3 Replies

· Add your reply
  • Sort: 
avatar image
3

Answer by Kryptos · Jul 30, 2012 at 08:22 AM

This might be possible. My guess would be to call a javascript function (real javascript on the HTML page) from Unity. This javascript function will be responsible for writing to the browser console.

See: Unity Web Player and browser communication

Comment
Add comment · Show 4 · 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 tonycoculuzzi · Jul 30, 2012 at 08:31 AM 0
Share

That's the idea, but it's not the problem. I know how to do that. It's done with Application.ExternalCall("webJavascriptFunctionName"), but do you know how would I got about extending the Debug class to use that function as well?

avatar image Kryptos · Jul 30, 2012 at 08:33 AM 0
Share

I don't think that you can replace the built-in Debug class.

avatar image Bunny83 · Aug 03, 2012 at 01:05 PM 0
Share

If you just browse around in the Scripting reference, you would have found this:

Application.RegisterLogCallback which allows you to get notified when a log event occurs.

avatar image tonycoculuzzi · Aug 03, 2012 at 01:10 PM 0
Share

You're assu$$anonymous$$g I didn't check the script reference. I did, immensely, but I guess I missed this. Thanks.

avatar image
1

Answer by sotirosn · May 18, 2013 at 02:32 PM

This static function works nicely:

 public static void Log(string message, Object context = null) {
 #if UNITY_EDITOR
     Debug.Log(message, context);
 #else
     Application.ExternalCall("console.log", message);
 #endif
 }
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
avatar image
0

Answer by jemonsuarez · Aug 30, 2020 at 08:50 AM

It does write all logging information (such as Debug.Log, Console.WriteLine or Unity’s internal logging) to the browser’s JavaScript console. Documentation.

Comment
Add comment · Show 2 · 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 Bunny83 · Aug 30, 2020 at 10:18 AM 1
Share

Yes, that's true for WebGL builds. However WebPlayer builds didn't do this since the WebPlayer was essentially a native code browser plugin which wrote its own log file into a seperate directory. However the [webplayer doesn't exists anymore since most browsers have dropped support for native plugins][1]. WebGL builds weren't really a thing back then.


avatar image tonialatalo Bunny83 · Aug 30, 2020 at 11:53 AM 0
Share

yah it's rather silly that this site shows questions from 2012 so pro$$anonymous$$ently

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

10 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

Related Questions

How to hide Unity Services console log spam 0 Answers

How to *not* batch console output? 1 Answer

5.4 Debug Console won't open Debug.Log on double click 3 Answers

Can I change the destination of selecting console entries 0 Answers

Redirect Unity unmanaged console 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