private void AddControlAfter(int idx) { CtrlItemData itemData = new CtrlItemData(); _ctrlItemDatas.Insert(idx + 1, itemData); ControlItemDrawer drawer = new ControlItemDrawer(this, itemData); _ctrlItemDrawers.Insert(idx + 1, drawer); }
private int GetCtrlIndex(string name) { for (int i = 0, imax = ctrlItemDatas.Count; i < imax; i++) { CtrlItemData item = ctrlItemDatas[i]; if (item.name == name) { return(i); } } return(-1); }
/// <summary> /// 解除指定UI及其子节点自动绑定字段的引用 /// </summary> /// <param name="uiGo"></param> public static void UnBindUI(GameObject uiGo) { if (uiGo == null) { return; } #if DEBUG_LOG float time = Time.realtimeSinceStartup; Profiler.BeginSample("UnBindUI"); #endif uiGo.GetComponentsInChildren(true, s_tmpControlDataForUnbind); for (int i = 0, imax = s_tmpControlDataForUnbind.Count; i < imax; i++) { UIControlData controlData = s_tmpControlDataForUnbind[i]; if (controlData.bindUIRefs == null) { continue; } List <WeakReference <IBindableUI> > bindUIRefs = controlData.bindUIRefs; for (int j = 0, jmax = bindUIRefs.Count; j < jmax; j++) { WeakReference <IBindableUI> bindUIRef = bindUIRefs[j]; IBindableUI bindUI; if (!bindUIRef.TryGetTarget(out bindUI)) { continue; } CBLuaPanel luaViewRunner = bindUI as CBLuaPanel; if (luaViewRunner == null) { UIFieldsInfo fieldInfos = GetUIFieldsInfo(bindUI.GetType()); var controls = fieldInfos.controls; for (int k = 0, kmax = controls.Count; k < kmax; k++) { controls[k].SetValue(bindUI, null); } var subUIs = fieldInfos.subUIs; for (int k = 0, kmax = subUIs.Count; k < kmax; k++) { subUIs[k].SetValue(bindUI, null); } } else { LuaTable luaTable = luaViewRunner._table; if (luaTable == null) { continue; } List <CtrlItemData> ctrlItemData = controlData.ctrlItemDatas; for (int k = 0, kmax = ctrlItemData.Count; k < kmax; k++) { CtrlItemData itemData = ctrlItemData[k]; luaTable.Set <string, object>(itemData.name, null); } List <SubUIItemData> subUIItemDatas = controlData.subUIItemDatas; for (int k = 0, kmax = subUIItemDatas.Count; k < kmax; k++) { SubUIItemData subUIItemData = subUIItemDatas[k]; luaTable.Set <string, object>(subUIItemData.name, null); } } } controlData.bindUIRefs = null; } s_tmpControlDataForUnbind.Clear(); #if DEBUG_LOG Profiler.EndSample(); float span = Time.realtimeSinceStartup - time; if (span > 0.002f) { Debug.LogWarningFormat("UnBindUI {0} 耗时{1}ms", uiGo.Name, span * 1000f); } #endif }
public ControlItemDrawer(UIControlDataEditor container, CtrlItemData item) { _container = container; _itemData = item; }