Hi, I’m trying to use a ContractAnnotation to halt execution and it’s not working.
UnityEngine.Assertions.Assert.IsTrue(condition, message) has a ContractAnnotation to halt that does work, and I’m trying to do the same thing.
I’ve used the same annotation and tried others such as [ContractAnnotation(“=>halt”)] but it doesn’t seem to work.
I’m using Unity 6000.0.40f1 on Windows 11 and only running it in the editor(I don’t need it to run outside of the editor). I think I read somewhere that Unity has a version of the Jetbrains code in a UnityEngine.CoreModule.dll but I didn’t really understand what it meant.
In the following code, replacing the CustomAssert call with the Unity version prevents the second log message. That’s what I’m trying to do with my function.
Any help would be appreciated.
[ContractAnnotation("condition:false=>halt")]
public static void CustomAssert(bool condition)
{
...
}
SomeFunction()
{
Debug.Log("first message that should log");
CustomAssert(1 == 2);
Debug.Log("second message that should not be shown");
}