summaryrefslogtreecommitdiff
path: root/Assets/Samples/Demo/UIEffect_Demo_PropertyControl.cs
blob: 4d6144fd4865830d41792704e4205a8633c4bd98 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

public class UIEffect_Demo_PropertyControl : MonoBehaviour
{
    [SerializeField] private string m_PropertyName;
    [SerializeField] private Object[] m_Objects;

    public void ChangeValue(int value)
    {
        foreach (var o in m_Objects)
        {
            if (!o) continue;

            var p = o.GetType().GetProperty(m_PropertyName);
            Debug.LogFormat("{0} {1} {2}", o.GetType(), m_PropertyName, p);

            if (p == null) continue;
            p.SetValue(o, value, new object[0]);
        }
    }
}