- Home /
Debug.Assert vs Assertions.Assert
I am wondering, what is the diference betwen Debug.Assert and Assertions.Assert. When to use what? Debug,Assert allows to track the object, where assertion is failed, can I find failed object with Assertions.Assert?
Answer by Tomek-Paszek · Jan 04, 2016 at 11:04 AM
@Deadcow_ Debug.Assert was added before Assertions.Assert but the latter is conditionally compiled out in non development builds. In 5.3 Assertions.Assert got overloads for passing objects so you can track the objects as well.
Strange. In 5.3.0 changelog all I see about assertions is "Debug.Assert got new overloads and Debug.LogAssert was added". Nothing about Assertions.Assert.
I'm currently on 5.3 (installing 5.3.1 right now) and most of Assertions.Assert functions got two overloads — with discriptoon (string) or without it.
Ah, sorry, my bad! I'm still getting back on track after the x-mas break :) I double checked it and you are right: Debug.Assert is conditionally compiled out. Debug.Assert got object overloads. Assertions.Assert didn't get object overloads (i see no reason for not adding them).
Sorry for confusion
so whats the actual difference then, apart from $$anonymous$$or API discrepancies? Is Debug.Assert being phased out in the near future?
Debug.Assert will assert the condition and call Debug.LogAssert if it fails.
Debug.LogAssert will log a message with type LogType.Assert.
Assertions.Assert is just small library for asserting different types in runtime. It's wrapping around Debug.Assert
thanks $$anonymous$$ek-Paszek for pointing this out one more time!