Seven is the number.
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.

137 lines
2.1 KiB

3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
  1. using UnityEngine;
  2. using Photon.Bolt.Utils;
  3. #if UNITY_EDITOR
  4. using UnityEditor;
  5. #endif
  6. namespace Photon.Bolt.Internal
  7. {
  8. public class UnityDebugDrawer : IDebugDrawer
  9. {
  10. bool isEditor;
  11. void IDebugDrawer.IsEditor(bool isEditor)
  12. {
  13. this.isEditor = isEditor;
  14. }
  15. void IDebugDrawer.SelectGameObject(GameObject gameObject)
  16. {
  17. #if UNITY_EDITOR
  18. if (!isEditor)
  19. {
  20. Selection.activeGameObject = gameObject;
  21. }
  22. #endif
  23. }
  24. void IDebugDrawer.Indent(int level)
  25. {
  26. #if UNITY_EDITOR
  27. if (isEditor)
  28. {
  29. EditorGUI.indentLevel = level;
  30. return;
  31. }
  32. #endif
  33. }
  34. void IDebugDrawer.Label(string text)
  35. {
  36. #if UNITY_EDITOR
  37. if (isEditor)
  38. {
  39. GUILayout.Label(text);
  40. return;
  41. }
  42. #endif
  43. DebugInfo.Label(text);
  44. }
  45. void IDebugDrawer.LabelBold(string text)
  46. {
  47. #if UNITY_EDITOR
  48. if (isEditor)
  49. {
  50. GUILayout.Label(text, EditorStyles.boldLabel);
  51. return;
  52. }
  53. #endif
  54. DebugInfo.LabelBold(text);
  55. }
  56. void IDebugDrawer.LabelField(string text, object value)
  57. {
  58. #if UNITY_EDITOR
  59. if (isEditor)
  60. {
  61. EditorGUILayout.LabelField(text, value.ToString());
  62. return;
  63. }
  64. #endif
  65. DebugInfo.LabelField(text, value);
  66. }
  67. void IDebugDrawer.Separator()
  68. {
  69. #if UNITY_EDITOR
  70. if (isEditor)
  71. {
  72. EditorGUILayout.Separator();
  73. return;
  74. }
  75. #endif
  76. GUILayout.Space(2);
  77. }
  78. void IDebugDrawer.DrawObjectArray(IDebugDrawerObjectArray root)
  79. {
  80. #if UNITY_EDITOR
  81. if (isEditor)
  82. {
  83. var fields = root.GetChildren();
  84. for (int i = 0; i < fields.Length; i++)
  85. {
  86. DrawObjectArrayItem(fields[i]);
  87. }
  88. return;
  89. }
  90. #endif
  91. }
  92. private void DrawObjectArrayItem(IDebugDrawerObjectArray item)
  93. {
  94. #if UNITY_EDITOR
  95. var fields = item.GetChildren();
  96. if (fields.Length > 0)
  97. {
  98. item.IsVisible = EditorGUILayout.Foldout(item.IsVisible, item.GetName(), true);
  99. if (item.IsVisible)
  100. {
  101. EditorGUI.indentLevel++;
  102. for (int i = 0; i < fields.Length; i++)
  103. {
  104. DrawObjectArrayItem(fields[i]);
  105. }
  106. EditorGUI.indentLevel--;
  107. }
  108. }
  109. else
  110. {
  111. (this as IDebugDrawer).LabelField(item.GetName(), item.GetValue());
  112. }
  113. #endif
  114. }
  115. }
  116. }