AnimatedWidget.cs 468 B

123456789101112131415161718192021222324252627
  1. using System;
  2. using UnityEngine;
  3. [ExecuteInEditMode]
  4. public class AnimatedWidget : MonoBehaviour
  5. {
  6. private void OnEnable()
  7. {
  8. this.mWidget = base.GetComponent<UIWidget>();
  9. this.LateUpdate();
  10. }
  11. private void LateUpdate()
  12. {
  13. if (this.mWidget != null)
  14. {
  15. this.mWidget.width = Mathf.RoundToInt(this.width);
  16. this.mWidget.height = Mathf.RoundToInt(this.height);
  17. }
  18. }
  19. public float width = 1f;
  20. public float height = 1f;
  21. private UIWidget mWidget;
  22. }