ScrollRectPatch.cs 832 B

1234567891011121314151617181920212223242526272829303132
  1. using System;
  2. using UnityEngine;
  3. using UnityEngine.UI;
  4. namespace SRDebugger.UI.Other
  5. {
  6. [RequireComponent(typeof(ScrollRect))]
  7. [ExecuteInEditMode]
  8. public class ScrollRectPatch : MonoBehaviour
  9. {
  10. private void Awake()
  11. {
  12. ScrollRect component = base.GetComponent<ScrollRect>();
  13. component.content = this.Content;
  14. component.viewport = this.Viewport;
  15. if (this.ReplaceMask != null)
  16. {
  17. GameObject gameObject = this.ReplaceMask.gameObject;
  18. UnityEngine.Object.Destroy(gameObject.GetComponent<Graphic>());
  19. UnityEngine.Object.Destroy(gameObject.GetComponent<CanvasRenderer>());
  20. UnityEngine.Object.Destroy(this.ReplaceMask);
  21. gameObject.AddComponent<RectMask2D>();
  22. }
  23. }
  24. public RectTransform Content;
  25. public Mask ReplaceMask;
  26. public RectTransform Viewport;
  27. }
  28. }