2021년 4학년 1학기 기업연계프로젝트2 컴퓨터소프트웨어공학과 <원광투어팀> 팀장 : 송유진 팀원 : 김나영, 이경희, 한유진
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
2.2 KiB

5 years ago
  1. using UnityEngine;
  2. namespace Unity.FPS.Game
  3. {
  4. public static class DebugUtility
  5. {
  6. public static void HandleErrorIfNullGetComponent<TO, TS>(Component component, Component source,
  7. GameObject onObject)
  8. {
  9. #if UNITY_EDITOR
  10. if (component == null)
  11. {
  12. Debug.LogError("Error: Component of type " + typeof(TS) + " on GameObject " + source.gameObject.name +
  13. " expected to find a component of type " + typeof(TO) + " on GameObject " +
  14. onObject.name + ", but none were found.");
  15. }
  16. #endif
  17. }
  18. public static void HandleErrorIfNullFindObject<TO, TS>(UnityEngine.Object obj, Component source)
  19. {
  20. #if UNITY_EDITOR
  21. if (obj == null)
  22. {
  23. Debug.LogError("Error: Component of type " + typeof(TS) + " on GameObject " + source.gameObject.name +
  24. " expected to find an object of type " + typeof(TO) +
  25. " in the scene, but none were found.");
  26. }
  27. #endif
  28. }
  29. public static void HandleErrorIfNoComponentFound<TO, TS>(int count, Component source, GameObject onObject)
  30. {
  31. #if UNITY_EDITOR
  32. if (count == 0)
  33. {
  34. Debug.LogError("Error: Component of type " + typeof(TS) + " on GameObject " + source.gameObject.name +
  35. " expected to find at least one component of type " + typeof(TO) + " on GameObject " +
  36. onObject.name + ", but none were found.");
  37. }
  38. #endif
  39. }
  40. public static void HandleWarningIfDuplicateObjects<TO, TS>(int count, Component source, GameObject onObject)
  41. {
  42. #if UNITY_EDITOR
  43. if (count > 1)
  44. {
  45. Debug.LogWarning("Warning: Component of type " + typeof(TS) + " on GameObject " +
  46. source.gameObject.name +
  47. " expected to find only one component of type " + typeof(TO) + " on GameObject " +
  48. onObject.name + ", but several were found. First one found will be selected.");
  49. }
  50. #endif
  51. }
  52. }
  53. }