Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.25 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. /// <summary>
  5. /// Conditional testing statements that only function within the Editor (They get Stripped out of the iPhone Build)
  6. /// </summary>
  7. public class Assert
  8. {
  9.  
  10. /// <summary>
  11. /// Tests a Comparison, and if false, will display the message. This function only works within the Editor (it is ignored on the iPhone)
  12. /// </summary>
  13. /// <param name='comparison'>
  14. /// The comparison to test
  15. /// </param>
  16. /// <param name='message'>
  17. /// The message to Display
  18. /// </param>
  19. [System.Diagnostics.Conditional("UNITY_EDITOR")]
  20. public static void Test(bool comparison, string message)
  21. {
  22. if(!comparison)
  23. {
  24. Assert.Throw(message);
  25. }
  26. }
  27.  
  28. /// <summary>
  29. /// Tests a Comparison, and if false, will display the message. This function only works within the Editor (it is ignored on the iPhone)
  30. /// </summary>
  31. /// <param name='comparison'>
  32. /// The comparison to test
  33. /// </param>
  34. /// <param name='message'>
  35. /// The message to Display
  36. /// </param>
  37. [System.Diagnostics.Conditional("UNITY_EDITOR")]
  38. public static void Test(bool comparison, string message, Object callingObject)
  39. {
  40. if(!comparison)
  41. {
  42. Assert.Throw(message, callingObject);
  43. }
  44. }
  45.  
  46. /// <summary>
  47. /// Throw the specified message.
  48. /// </summary>
  49. /// <param name='message'>
  50. /// Message.
  51. /// </param>
  52. [System.Diagnostics.Conditional("UNITY_EDITOR")]
  53. public static void Throw(string message)
  54. {
  55. Debug.LogWarning(message);
  56. Debug.Break();
  57. }
  58.  
  59. /// <summary>
  60. /// Throw the specified message and the object that has called it.
  61. /// </summary>
  62. /// <param name='message'>
  63. /// Message.
  64. /// </param>
  65. /// <param name='callingObject'>
  66. /// Calling object.
  67. /// </param>
  68. [System.Diagnostics.Conditional("UNITY_EDITOR")]
  69. public static void Throw(string message, Object callingObject)
  70. {
  71. Debug.LogWarning(message, callingObject);
  72. Debug.Break();
  73. }
  74.  
  75. /// <summary>
  76. /// Log the specified message along with a formatted date.
  77. /// </summary>
  78. /// <param name='message'>
  79. /// Message.
  80. /// </param>
  81. [System.Diagnostics.Conditional("UNITY_EDITOR")]
  82. public static void Log(string message)
  83. {
  84. Debug.Log(string.Format("{0:HH:mm:ss FFFF} ->" + message, System.DateTime.Now));
  85. }
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement