UIEffect_Demo_PropertyControl.cs 659 B

12345678910111213141516171819202122232425
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.Events;
  5. using UnityEngine.UI;
  6. public class UIEffect_Demo_PropertyControl : MonoBehaviour
  7. {
  8. [SerializeField] private string m_PropertyName;
  9. [SerializeField] private Object[] m_Objects;
  10. public void ChangeValue(int value)
  11. {
  12. foreach (var o in m_Objects)
  13. {
  14. if (!o) continue;
  15. var p = o.GetType().GetProperty(m_PropertyName);
  16. Debug.LogFormat("{0} {1} {2}", o.GetType(), m_PropertyName, p);
  17. if (p == null) continue;
  18. p.SetValue(o, value, new object[0]);
  19. }
  20. }
  21. }