12345678910111213141516171819202122232425262728293031323334353637 |
- using UnityEngine;
- using System.Collections;
- public class UIUtils
- {
- public static void EnableWidgets(GameObject widgetContainer, bool isEnabled)
- {
- EnableWidgetColliders(widgetContainer, isEnabled);
- SetWidgetsAlpha(widgetContainer, isEnabled ? 1 : 0.5f);
- }
- public static void SetWidgetsAlpha(GameObject widgetContainer, float newAlpha)
- {
- UIWidget[] widgets = widgetContainer.GetComponentsInChildren<UIWidget>();
- foreach (UIWidget widget in widgets)
- {
- widget.alpha = newAlpha;
- }
- }
- public static void EnableWidgetColliders(GameObject widgetContainer, bool isEnabled)
- {
- Collider[] colliders = widgetContainer.GetComponentsInChildren<Collider>();
- foreach (Collider collider in colliders)
- {
- collider.enabled = isEnabled;
- }
- }
- public static string FormatSeconds(int totalSeconds)
- {
- int seconds = totalSeconds % 60;
- int min = totalSeconds / 60;
- return min+":"+seconds.ToString("00");
- }
- }
|