- Home /
Is there a way to force Debug.Log(string, object) to ALWAYS draw the context?
I'm outputting many lines using calls to Debug.Log(string, object), and in unity, I'm relying on the feature of drawing a highlighting outline around the context GameObject in the hierarchy tab when I click on a log item in the console tab.
However, the way unity currently highlights the context GameObject is that it draws a rounded rectangle around it in the Hierarchy tab, which later fades out. The strange behaviour I'm seeing is that the highlight doesn't get redrawn if the context of the newly-clicked-on log item is the same as the context of the previously-clicked-on log item.
This is causing me problems because some of the context GameObjects for log items are invalid (ie not in the scene anymore) and thus, really SHOULDN'T be getting a highlight drawn in the hierarchy tab, so it's becoming a real pain to figure out whether the log item I clicked on has an invalid context GameObject, or if it's just the SAME context GameObject as the previously clicked on log item.
The only workaround I've found is to have a "dummy" log item with a known context GameObject (that will never be the context for any other log item), and I have to click on that log item in between clicking any other log items in the console tab, to force unity to redraw the highlighting outline in the hierarchy tab. This is a real nuisance, especially when I have hundreds of log items I need to be looking thru and comparing context GameObjects for.
So is there a setting somewhere that I can change, or some code-accessible internal variable/method that will allow me to "reset" the most recent context Unity drew a highlight for, or something?
Hey, just reached this when searching how to highlight a gameObject from the console. I want my singleton player code to highlight the object I collided with. Did you ever find the answer to this problem? Can you share if you did?
No, I never found an answer :( But this was quite a while ago, so perhaps it's been fixed since? It's been a really long time since I have worked on that project at all, let alone that particular piece of debugging code.
Hey, found the answer after a while. thanks for replying.
Can you share the answer here for others who also come across this post, please?
Answer by TheGameLearner · Jan 19, 2021 at 11:25 AM
I used the code from here link text to highlight a context.
I added it manually when I selected a Context.
Your answer
Follow this Question
Related Questions
Prevent editor-prev.log file from getting too big 1 Answer
How can I find editor log file? 5 Answers
Generic Debug Message 1 Answer
How do I keep Debug.Log in archive/release iOS builds? 0 Answers
Debug.Log() remove callstack ? 1 Answer