/// <summary> /// 清空引用 释放内存 /// </summary> public void Clear() { try { cop = null; } catch (Exception) { } }
private void InitComponent() { System.Type classType = this.GetType(); FieldInfo[] fields = classType.GetFields(); foreach (FieldInfo item in fields) { string name = StringUtil.ToUpper(item.Name, 0, 1); if (transform.Find(name) != null) { if (transform.Find(name).GetComponent <GUIComponentBase>() != null) { cop = transform.Find(name).GetComponent <GUIComponentBase>(); item.SetValue(this, cop); } } } }