简体   繁体   中英

(Unity Web) How to show Debug.Log in browser inspector rather then '~/Library/Logs/Unity'?

I wonder how to show Debug.Log in browser inspector rather then '~/Library/Logs/Unity'. Since i am developing a multi-player game, now when I open two browsers, the logs are displayed in the same log file, all in a mess!

btw, I see there is an option 'script debugging' in build settings but no luck.

the way I've done this is to make a call out from Unity to the browser

(have a look at http://docs.unity3d.com/Manual/UnityWebPlayerandbrowsercommunication.html )

So in my Unity c# script I call

Application.ExternalCall( "BrowserLog", "my log message" );

Ad in my host page javascript I have a function

<script type="text/javascript" language="javascript">
<!--
function BrowserLog( msg)
{
    // logthe message
    console.log( msg);
}
-->
</script>

Garrett's answer works fine. As an improvement you can also code like this avoiding the extra javascript function:

Application.ExternalCall( "console.log", "my log message" );

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM