Skip to content

Instantly share code, notes, and snippets.

@qapquiz
Last active May 28, 2019 10:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save qapquiz/d8545db0e5e74a496ef084e95c6348af to your computer and use it in GitHub Desktop.
Save qapquiz/d8545db0e5e74a496ef084e95c6348af to your computer and use it in GitHub Desktop.
use for assert some data and print log in Unity3d (extract from FPSSample)
using System;
public class ApplicationException : Exception {
public ApplicationException(string message) : base(message) { }
}
public static class GameDebug {
public static void Assert(bool condition) {
if (!condition)
throw new ApplicationException("GAME ASSERT FAILED");
}
public static void Assert(bool condition, string msg) {
if (!condition)
throw new ApplicationException("GAME ASSERT FAILED : " + msg);
}
public static void Assert<T>(bool condition, string format, T arg1) {
if (!condition)
throw new ApplicationException("GAME ASSERT FAILED : " + string.Format(format, arg1));
}
public static void Assert<T1, T2>(bool condition, string format, T1 arg1, T2 arg2) {
if (!condition)
throw new ApplicationException("GAME ASSERT FAILED : " + string.Format(format, arg1, arg2));
}
public static void Assert<T1, T2, T3>(bool condition, string format, T1 arg1, T2 arg2, T3 arg3) {
if (!condition)
throw new ApplicationException("GAME ASSERT FAILED : " + string.Format(format, arg1, arg2, arg3));
}
public static void Assert<T1, T2, T3, T4>(bool condition, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4) {
if (!condition)
throw new ApplicationException("GAME ASSERT FAILED : " + string.Format(format, arg1, arg2, arg3, arg4));
}
public static void Assert<T1, T2, T3, T4, T5>(bool condition, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5) {
if (!condition)
throw new ApplicationException("GAME ASSERT FAILED : " + string.Format(format, arg1, arg2, arg3, arg4, arg5));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment