SoftMaskToggler.cs 537 B

123456789101112131415161718
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3. namespace SoftMasking.Samples {
  4. public class SoftMaskToggler : MonoBehaviour {
  5. public GameObject mask;
  6. public bool doNotTouchImage = false;
  7. public void Toggle(bool enabled) {
  8. if (mask) {
  9. mask.GetComponent<SoftMask>().enabled = enabled;
  10. mask.GetComponent<Mask>().enabled = !enabled;
  11. if (!doNotTouchImage)
  12. mask.GetComponent<Image>().enabled = !enabled;
  13. }
  14. }
  15. }
  16. }