private void InitData() { ClearChilds(); for (int i = 0; i < GOs.Count; i++) { if (GOs[i] == null) { CLog.Error("有的GO为null"); } } UControl[] ts = GOs.Where(go => go != null).Select(go => go.GetComponent <UControl>()).ToArray(); for (int i = 0; i < ts.Length; i++) { if (ts[i] == null) { CLog.Error(string.Format("取出组件为null, type={0},如果想要忽略,请添加IgnoreElement组件", typeof(UControl))); break; } else { if (AddDynamicChild(ts[i])) { ts[i].SetIndex(i); ts[i].SetDataIndex(i); ts[i].PDupplicate = this; } } } }
public TP[] GetGOs <TP, TD>(TD data = null) where TP : Presenter <TD> where TD : PresenterData, new() { if (data == null) { data = new TD(); } for (int i = 0; i < GOs.Count; i++) { if (GOs[i] == null) { CLog.Error("有的GO为null"); } } TP[] ts = GOs.Where(go => go != null).Select(go => go.GetComponent <TP>()).ToArray(); for (int i = 0; i < ts.Length; i++) { if (ts[i] == null) { CLog.Error(string.Format("取出组件为null, type={0}", typeof(TP))); break; } else { ts[i].SetIndex(i); ts[i].BaseDupplicate = this; AddChild(ts[i], true); if (data != null) { ts[i].Init(data); } } } return(ts); }
private TP[] InitData <TP, TD>(TD[] data) where TP : UPresenter <TD> where TD : UPresenterData, new() { ClearChilds(); for (int i = 0; i < GOs.Count; i++) { if (GOs[i] == null) { CLog.Error("有的GO为null"); } } TP[] ts = GOs.Where(go => go != null).Select(go => go.GetComponent <TP>()).ToArray(); for (int i = 0; i < ts.Length; i++) { if (ts[i] == null) { CLog.Error(string.Format("取出组件为null, type={0},如果想要忽略,请添加IgnoreElement组件", typeof(TP))); break; } else { if (AddDynamicChild(ts[i])) { ts[i].SetIndex(i); ts[i].SetDataIndex(i); ts[i].PDupplicate = this; } //if ( // Data.OnRefresh == null && // Data.OnFixedRefresh == null) { if (data != null) { if (i < data.Length) { ts[i].Init(data[i]); } } else { ts[i].Init(new TD()); } } } } return(ts); }