Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
1
Question by Glurth · Aug 07, 2016 at 06:33 PM · customdebug.logstacktrace

How to properly call Debug.Log(string) in a custom Log function?

I’d like to create an alternate version of Debug.Log(string): ConidtionalDebugLog(string). I’d simply like to wrap the debug statement in a few conditionals, based on settings. That part works fine.

The issue I’m hitting is with the “non-string” part of the log, in particular the stack trace. As one would expect, the error in the console shows the line that the Debug.Log() function was called, both in the stack trace, and when double clicking the message to open the script file to that line.

Ideally, I would like to have the console show (and go to, on double click) the line of code that called ConditionalDebugLog(string), instead of the line of code INSIDE ConditionalDebugLog() that called Debug.Log().

I’ve tried going through the docs on the various ILogger, ILogHandler interfaces, in order to try understanding how Debug.logger works, but I’m still not clear on if this stuff can even help the objective.

Is this possible? Is it practical? If so, any suggestions? Any ideas for alternatives also welcome.

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

Answer by Eric5h5 · Aug 07, 2016 at 06:40 PM

Compile the ConditionalDebugLog code into a DLL.

Comment
Add comment · Show 11 · 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 Glurth · Aug 07, 2016 at 06:51 PM 0
Share

oh interesting! Never done that before, I guess I'll need to pass my conditional values into that DLL at startup and on change since it won't have stuff from my project in scope; is that right?

I'll start here unless you have any other suggestions: https://docs.unity3d.com/$$anonymous$$anual/UsingDLL.html

avatar image Eric5h5 Glurth · Aug 07, 2016 at 09:53 PM 0
Share

No; all code in Unity is compiled and there's no difference in code behavior in a script compared to code in a DLL. Except for the Debug.Log thing.

avatar image Glurth Eric5h5 · Aug 07, 2016 at 11:59 PM 0
Share

Hmm, I must be missing something: The instructions have me creating the CustomDebug DLL as a separate project to be compiled into the DLL. I don't see how I can reference any of the code from my Unity project, like say.. GlurthSettings.numberOfDoDadsInScene, when it's not defined in the DLL Project, without generating a compiler error (not in scope).

Then again, I have not gone very far with this so far, perhaps it will become apparent when I do.

Show more comments
avatar image Glurth · Aug 08, 2016 at 12:41 AM 0
Share

Works exactly as desired! (need to pass in the conditionals from main project to DLL, but that's easy enough.) $$anonymous$$any thanks!

avatar image SarperS Glurth · Jan 30, 2018 at 03:06 PM 0
Share

Could you please explain how it's achieved so people visiting this question can find the answer without duplicating this question? Thanks

avatar image Glurth SarperS · Jan 30, 2018 at 03:14 PM 0
Share

explain what part? how to make a DLL? The link in my first comment shows how.

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

52 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

Related Questions

No stack trace on device development build 1 Answer

WebPlayer Custom Params Inspector 0 Answers

Web Player Dimensions and Custom Loading Screen Issue 0 Answers

How to make line renderer glow like any other 3d object using custom shader? 0 Answers

Set the shader lod value yourself 1 Answer


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