DebugViewManager.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. using UnityEngine;
  2. using System.Collections;
  3. using System;
  4. public class DebugViewManager : MonoBehaviour
  5. {
  6. public static Action OnDebugView;
  7. #if UNITY_EDITOR || DEBUG
  8. private bool _showDebug = false;
  9. private bool _isExpanded = false;
  10. #if UNITY_EDITOR || UNITY_WEBPLAYER
  11. void Start()
  12. {
  13. _showDebug = true;
  14. }
  15. #endif
  16. #if UNITY_IPHONE || UNITY_ANDROID
  17. void Update()
  18. {
  19. if (Input.touchCount == 4 && Input.touches[0].phase == TouchPhase.Ended)
  20. {
  21. _showDebug = !_showDebug;
  22. }
  23. }
  24. #endif
  25. void OnGUI()
  26. {
  27. if (_showDebug)
  28. {
  29. //if (GUILayout.Button(_isExpanded ? "Hide Debug Menu" : "Show Debug Menu", GameConstants.DebugButtonWidth, GameConstants.DebugButtonHeight))
  30. {
  31. //_isExpanded = !_isExpanded;
  32. }
  33. if (_isExpanded)
  34. {
  35. if (GUILayout.Button("Delete PlayerPrefs (Restart app suggested)", GameConstants.DebugButtonWidth, GameConstants.DebugButtonHeight))
  36. {
  37. PlayerPrefs.DeleteAll();
  38. }
  39. if (GUILayout.Button("Clean cache (asset bundles)", GameConstants.DebugButtonWidth, GameConstants.DebugButtonHeight))
  40. {
  41. Caching.ClearCache();
  42. }
  43. if (GUILayout.Button("Reset Data", GameConstants.DebugButtonWidth, GameConstants.DebugButtonHeight))
  44. {
  45. CoreNotificationCenter.Post(CoreNotificationType.ResetData);
  46. }
  47. if (OnDebugView != null)
  48. {
  49. OnDebugView();
  50. }
  51. }
  52. }
  53. }
  54. #endif
  55. }