- Home /
Asserts not working (Debug.assert or Assertions.Assert.xxx(xx.))
Any of these is working. I read that you need to define UNITY_ASSERTIONS. I tried, it doesn't show any log or any exception even when they fail.
How is this possible?
public class NewBehaviourScript : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
Debug.Assert(1 == 10, "no");
Assert.AreEqual(1, 10, "no");
}
}
Answer by Darkgaze · Jun 17, 2020 at 08:17 AM
There is something weird going on with this, the message should be displayed without an exception, but it doesn't. So I found that you have to set this to true if you want exceptions.
UnityEngine.Assertions.Assert.raiseExceptions = true;
Thanks to this I see the message AND the exception. But if it is false, nothing happens. That, I think, Is not intended... but well.
Your answer
Follow this Question
Related Questions
Double clicking console output does not take me to the corresponding line in code. 1 Answer
FPS Measurement Issue 0 Answers
Debugging opens a new tab :( 1 Answer
Having an issue with one of my scripts 1 Answer
Generic Debug Message 1 Answer