UIUtils.cs 928 B

12345678910111213141516171819202122232425262728293031323334353637
  1. using UnityEngine;
  2. using System.Collections;
  3. public class UIUtils
  4. {
  5. public static void EnableWidgets(GameObject widgetContainer, bool isEnabled)
  6. {
  7. EnableWidgetColliders(widgetContainer, isEnabled);
  8. SetWidgetsAlpha(widgetContainer, isEnabled ? 1 : 0.5f);
  9. }
  10. public static void SetWidgetsAlpha(GameObject widgetContainer, float newAlpha)
  11. {
  12. UIWidget[] widgets = widgetContainer.GetComponentsInChildren<UIWidget>();
  13. foreach (UIWidget widget in widgets)
  14. {
  15. widget.alpha = newAlpha;
  16. }
  17. }
  18. public static void EnableWidgetColliders(GameObject widgetContainer, bool isEnabled)
  19. {
  20. Collider[] colliders = widgetContainer.GetComponentsInChildren<Collider>();
  21. foreach (Collider collider in colliders)
  22. {
  23. collider.enabled = isEnabled;
  24. }
  25. }
  26. public static string FormatSeconds(int totalSeconds)
  27. {
  28. int seconds = totalSeconds % 60;
  29. int min = totalSeconds / 60;
  30. return min+":"+seconds.ToString("00");
  31. }
  32. }