void UpdateList() { foreach (GameObject go in optionObjects) { Destroy(go); } container.sizeDelta = new Vector2(0f, 28f * contents.Count); int i = 0; foreach (EnumMask content in contents) { GameObject go = Instantiate(contentPrefab, container, false); EnumMaskOption options = go.GetComponent <EnumMaskOption> (); options.enumController = this; options.label.text = content.label; content.toggle = options.toggle; content.toggle.isOn = content.state; RectTransform rt = (RectTransform)go.transform; rt.localPosition = new Vector2(0f, -28f * i); go.SetActive(true); i++; } active = true; }
public void SelectOption(int index, EnumMaskOption options, bool state) { active = false; if (options.label.text == noneLabel) { if (!state) { options.toggle.isOn = true; } else { SetStates(0, true); } label.text = noneLabel; } else if (options.label.text == allLabel) { if (allowNone) { SetStates(0, false); } else { SetStates(-1, false); } label.text = allLabel; } else { if (mask) { CheckStates(state, index); } else { SetStates(index, true); } } UpdateSelections(); active = true; }