/// <summary> /// 添加权限组对象 /// </summary> public void AddAuthority(AuthorityInfo info, bool b) { Logger.Instance.WriteLog("添加权限组对象"); if (tgList.ContainsKey(info.Id)) { tgList[info.Id].value = b; } else { if (authorityItem == null || !authorityItem.isUnoccupied()) { GameObject g = Instantiate(authorityPerfab) as GameObject; authorityItem = g.GetComponent <AuthorityItemControl>(); authorityItem.modify = infoModity; if (authorityItem == null) { Debug.LogError("对象缺失AuthorityItemControl脚本,创建对象失败,对象名:" + g.name); return; } g.transform.SetParent(authorityParent); g.transform.localScale = Vector3.one; UIToggle tg = authorityItem.AddLable(info); if (tg == null) { Debug.LogError("有异常判断"); } else { tgList[info.Id] = tg; tg.value = b; } } else { UIToggle tg = authorityItem.AddLable(info); if (tg == null) { Debug.LogError("有异常判断"); } else { tgList[info.Id] = tg; tg.value = b; } } authorityParent.GetComponent <UIWidget>().UpdateAnchors(); authorityParent.GetComponent <UIGrid>().repositionNow = true; } }
/// <summary> /// 初始化当前UI功能及状态 /// </summary> public void Initialize() { //初始化赋空当前权限组item脚本,并清空账户组和权限组下方的所有自对象 authorityItem = null; accountParent.DestroyChildren(); authorityParent.DestroyChildren(); if (accountPerfab == null || authorityPerfab == null) { Debug.LogError("预制体为空;accountPerfab = " + accountPerfab == null ? "null" : accountPerfab.ToString() + " authorityPerfab = " + authorityPerfab == null ? "null" : authorityPerfab.ToString()); } if (accountParent == null || authorityParent == null) { Debug.LogError("父节点为空;accountParent = " + accountParent == null ? "null" : accountParent.ToString() + " authorityParent = " + authorityParent == null ? "null" : authorityParent.ToString()); } }