CopyLogsOnResizeButtonClick.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. using System.Collections;
  2. using UnityEngine;
  3. using UnityEngine.EventSystems;
  4. namespace IngameDebugConsole
  5. {
  6. public class CopyLogsOnResizeButtonClick : MonoBehaviour, IPointerClickHandler
  7. {
  8. [SerializeField]
  9. private int maxLogCount = int.MaxValue;
  10. [SerializeField]
  11. private float maxElapsedTime = float.PositiveInfinity;
  12. void IPointerClickHandler.OnPointerClick(PointerEventData eventData)
  13. {
  14. if (!eventData.dragging && eventData.eligibleForClick && DebugLogManager.Instance.copyAllLogsOnResizeButtonClick)
  15. {
  16. GUIUtility.systemCopyBuffer = DebugLogManager.Instance.GetAllLogs(maxLogCount, maxElapsedTime);
  17. StartCoroutine(ScaleAnimationCoroutine());
  18. }
  19. }
  20. private IEnumerator ScaleAnimationCoroutine()
  21. {
  22. for (float t = 0f; t < 1f; t += Time.unscaledDeltaTime * 3f)
  23. {
  24. transform.localScale = Vector3.one * (1f + Mathf.PingPong(t, 0.5f));
  25. yield return null;
  26. }
  27. transform.localScale = Vector3.one;
  28. }
  29. }
  30. }