private void SetupTemplate() { validTemplate = false; if (!m_Template) { Debug.LogError("The dropdown template is not assigned. The template needs to be assigned and must have a child GameObject with a Toggle component serving as the item.", (UnityEngine.Object)(object) this); return; } GameObject gameObject = m_Template.gameObject; gameObject.SetActive(true); Toggle componentInChildren = m_Template.GetComponentInChildren <Toggle>(); validTemplate = true; if (!(UnityEngine.Object)(object) componentInChildren || ((Component)(object)componentInChildren).transform == template) { validTemplate = false; Debug.LogError("The dropdown template is not valid. The template must have a child GameObject with a Toggle component serving as the item.", template); } else if (!(((Component)(object)componentInChildren).transform.parent is RectTransform)) { validTemplate = false; Debug.LogError("The dropdown template is not valid. The child GameObject with a Toggle component (the item) must have a RectTransform on its parent.", template); } else if ((UnityEngine.Object)(object) itemText != null && !itemText.transform.IsChildOf(((Component)(object)componentInChildren).transform)) { validTemplate = false; Debug.LogError("The dropdown template is not valid. The Item Text must be on the item GameObject or children of it.", template); } else if ((UnityEngine.Object)(object) itemImage != null && !((Component)(object)itemImage).transform.IsChildOf(((Component)(object)componentInChildren).transform)) { validTemplate = false; Debug.LogError("The dropdown template is not valid. The Item Image must be on the item GameObject or children of it.", template); } if (!validTemplate) { gameObject.SetActive(false); return; } DropdownItem dropdownItem = ((Component)(object)componentInChildren).gameObject.AddComponent <DropdownItem>(); dropdownItem.text = m_ItemText; dropdownItem.image = m_ItemImage; dropdownItem.toggle = componentInChildren; dropdownItem.rectTransform = (RectTransform)((Component)(object)componentInChildren).transform; Canvas orAddComponent = GetOrAddComponent <Canvas>(gameObject); orAddComponent.overrideSorting = true; orAddComponent.sortingOrder = 30000; TMP_Dropdown.GetOrAddComponent <GraphicRaycaster>(gameObject); GetOrAddComponent <CanvasGroup>(gameObject); gameObject.SetActive(false); validTemplate = true; }