UIEvent UI u3d学习总结笔记本

1.通过代码获取UI控件操作

public GameObject btnGameObject;
public GameObject sliderGamebject;
public GameObject dropDownGameObject;
public GameObject toggleGameObject;
//传入方法
btnGameObject.GetComponent<Button>().onClick.AddListener(this.but001);//在UnityEvent中添加一个非持续性侦听器。
sliderGamebject.GetComponent<Slider>().onValueChanged.AddListener(this.OnSliderChanged);

dropDownGameObject.GetComponent<Dropdown>().onValueChanged.AddListener(this.OnDropDownChanged);
toggleGameObject.GetComponent<Toggle>().onValueChanged.AddListener(this.OnToggelechanged);

2.修改颜色透明度

public Image DianJi;

Color colorD = DianJi.color;	
colorD.a = Mathf.PingPong(Time.time/1.5f,1f);
DianJi.color = colorD;

猜你喜欢

转载自blog.csdn.net/qq_40346899/article/details/82710407