public void SaveSyncColor() { GroupModel.GroupStatus groupStatus = status.Access(GroupModel.GroupStatus.NAME) as GroupModel.GroupStatus; foreach (Block block in status.blocks) { if (!string.IsNullOrEmpty(block.color)) { continue; } GroupModel.Group group = groupStatus.groups.Find((_item) => { bool found = false; foreach (GroupModel.Section section in _item.sections) { if (block.ns.Equals(section.path)) { found = true; } } return(found); }); if (null == group) { continue; } block.color = group.color; } }
private void addGroup(GroupModel.Group _group) { GameObject clone = GameObject.Instantiate(uiBlockly.tsTempalteGroup.gameObject); clone.transform.SetParent(uiBlockly.tsTempalteGroup.parent); clone.transform.localScale = Vector3.one; clone.SetActive(true); clone.name = _group.name; Image icon = clone.transform.Find("icon").GetComponent <Image>(); icon.color = FacadeUtility.HexToColor(_group.color); UnityEngine.UI.Text name = clone.transform.Find("name").GetComponent <UnityEngine.UI.Text>(); name.text = _group.name; Toggle toggle = clone.GetComponent <Toggle>(); toggle.onValueChanged.AddListener( (_toggled) => { onGroupChanged(_toggled, toggle); } ); }