I have a static boolean in a script, and few seconds later the played, I see the value of boolean variable is changed from true to false by Debug.Log.
But Point is, there ISN’T any script containing value change for this static boolean.
I’m pretty sure that there isn’t any command changing its value, cuz I’ve double checked by correcting all the error messages after changing it’s variable name.
So I would like to know where on earth this value change has came from, if there’s any way to know.
Is there any way to see the change of variable? not the value itself, but which script has changed it.
I’m working with C#.
The Console already shows you the stack trace of Debug statements, so you can use that. Set your static bool as a property if it isn’t already, then do something like:
private static bool flag;
public static bool Flag {
get { return flag; }
set {
if (flag != value) {
flag = value;
Debug.LogFormat ("Changed!");
}
}
}
That should print something to the console whenever the value changes, which will have a trace back to whatever made the assignment.
[BUMP]
I need to do what the title of this thread it. I have a prefab that I instantiate, and position, and my Debug.Log indicates that it was positioned correctly, but upon the first frame it’s moved to a different location by another script. The only other script on this is a Behavior State controller from the Asset Store. I’ve looked in the main script, and I don’t see anything that moves it, so it’s probably happening in the State itself. I don’t want to keep bothering the author, so if I could see where and why the position is being changed, I might be able to work around it.
Any help tracking which script is changing the position of a transform?