/// <summary> /// 设置变灰 /// </summary> /// <param name="bTrue"></param> /// <param name="obj"></param> public static void SetItemIsGray(bool bTrue, GameObject obj) { UIGray gray3 = obj.GetComponent <UIGray>(); if (gray3 == null) { gray3 = obj.AddComponent <UIGray>(); } gray3.gameObject.SetActiveNew(bTrue); }
/// <summary> /// 设置按钮变灰 及可点击 /// </summary> /// <param name="obj"></param> /// <param name="isGray">true变灰</param> /// <param name="isActive">true 可点击</param> public static void SetGray(GameObject obj, bool isGray, bool isActive = false) { if (isActive) { UIGray.Get(obj).SetGrayButActive(isGray); } else { UIGray.Get(obj).SetGray(isGray, isActive); } }
public static UIGray Get(GameObject go) { UIGray load = go.GetComponent <UIGray>(); if (load != null) { load.Start(); } else { load = go.AddComponent <UIGray>(); load.Start(); } return(load); }