StackTracing

Updated on December 8, 2017 in [A] C# .Net
Share on Facebook0Tweet about this on TwitterShare on Google+0Share on Reddit0
2 on December 1, 2017

Hey all,

I’ve got a question about stacktracing, wich is best explained using pseudo code:

public class A : NetworkBehaviour //yes its over a network, this is why im asking this in the first place
{
//code code code
void DoSomething()
{
CmdInvokeSomething();
}
[Command]
void CmdInvokeSomething()
{
FindObjectOfClass<B>().InvokeThis();
}
}
public class B : NetworkBehaviour
{
public void InvokeThis()
{
Debug.Log("Hello");
}
}

now this code will run and invoke the Cmd wich will start calling stuff on the lower levels of unity.
I don’t want this to show up in my debugs.

(yes its a very shitty debug but i feel like this would be a fun little fiddle..)

anyway, now that this example is out of the way lets go into more verbose stuff.

so i’ve got a class A and a class B wich are part of my project, as in, I wrote them.
A.CmdInvokeSomething() invokes not just the Cmd on the server but goes through a bunch of functions before getting there. Now I don’t want to show all this, I’d want to see a debug like:

(server) “Hello” in B.InvokeThis invoked by (client) B.CmdInvokeSomething invoked by B.DoSomething

this would be handy for me.
please help
thank you in advance
regards
-pre

  • Liked by
Reply
0 on December 1, 2017

Why do you need to know two levels of what invoked what?

Why not just debug log yourself when you need?

  • Liked by
Reply
Cancel
0 on December 8, 2017

I would suggest writing Debug.Log() in every method:

public class A : NetworkBehaviour 
{
 void DoSomething()
 { 
 Debug.Log(this.name + " : DoSomething()");
 CmdInvokeSomething();
 }
[Command]
 void CmdInvokeSomething()
 { 
 Debug.Log(this.name + " :CmdInvokeSomething()");
 FindObjectOfClass<B>().InvokeThis();
 }
}
public class B : NetworkBehaviour
{
 public void InvokeThis()
 {
 Debug.Log(this.name + " :InvokeThis()"); 
 } 
}

 

  • Liked by
Reply
Cancel