protected override void InitInspector() { base.InitInspector(); // do initialization here scriptItem = (UIItem)target; if (!Application.isPlaying) { scriptItem.Init(true); } itemName = serializedObject.FindProperty("itemName"); group = serializedObject.FindProperty("group"); isItemExpanded = serializedObject.FindProperty("isItemExpanded"); }
void InitGroupItems() { if (itemType == null || itemType == "") { itemType = "UIItem"; } int i; itemsByName = new Dictionary <string, UIItem>(); // flush itemsByName dictionary // Init from children if (itemsMode == 0) { for (i = 0; i < transform.childCount; i++) { UIItem item = transform.GetChild(i).gameObject.GetComponent(itemType) as UIItem; // init and use only items with correct enabled component and active gameobject if (item != null && item.gameObject.activeSelf && item.enabled) { item.Init(); // force items initialization itemsByName[item.itemName] = item; item.group = this; } } // set items array items = new UIItem [itemsByName.Count]; i = 0; foreach (UIItem item in itemsByName.Values) { items[i] = item; i++; } } // Init items from array if (itemsMode == 1) { // remove items with wrong type List <UIItem> tempItems = new List <UIItem>(); for (i = 0; i < items.Length; i++) { UIItem item = items[i].transform.gameObject.GetComponent(itemType) as UIItem; if (item != null) { tempItems.Add(item); } } items = tempItems.ToArray(); for (i = 0; i < items.Length; i++) { // init and use only items with enabled component and active gameobject if (items[i].gameObject.activeSelf && items[i].enabled) { items[i].Init(); // force items initialization itemsByName[items[i].itemName] = items[i]; items[i].group = this; // init item group } } } }