private void CollectElements() { m_elementList.Clear(); m_staticElementList.Clear(); m_dynamicElementList.Clear(); for (int i = 0; i < transform.childCount; i++) { Transform child = rectTransform.GetChild(i); if (!child.gameObject.activeInHierarchy) { continue; } UILayoutGroupElement element = child.GetComponent <UILayoutGroupElement>(); if (element == null) { continue; } m_elementList.Add(element); UILayoutGroupElementStatic staticElement = element as UILayoutGroupElementStatic; if (staticElement != null) { m_staticElementList.Add(staticElement); } UILayoutGroupElementDynamic dynamicElement = element as UILayoutGroupElementDynamic; if (dynamicElement != null) { m_dynamicElementList.Add(dynamicElement); } } }
public bool ContainsStaticIndex(int index) { for (int i = 0; i < m_elementList.Count; ++i) { UILayoutGroupElementStatic staticElement = m_elementList[i] as UILayoutGroupElementStatic; if (staticElement != null && staticElement.index == index) { return(true); } } return(false); }
private void RefreshCustomStaticElements() { for (int i = 0; i < m_staticElementList.Count; ++i) { UILayoutGroupElementStatic staticElement = m_staticElementList[i]; if (staticElement.indexType == UILayoutGroupElementStatic.EIndexType.Custom) { int index = staticElement.index; RecordIndex(index); } } }
public override void OnInspectorGUI() { UILayoutGroupElementStatic staticElement = target as UILayoutGroupElementStatic; EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(serializedObject.FindProperty("m_indexType")); if (staticElement.indexType == UILayoutGroupElementStatic.EIndexType.Custom) { EditorGUILayout.PropertyField(serializedObject.FindProperty("m_index")); } if (EditorGUI.EndChangeCheck()) { serializedObject.ApplyModifiedProperties(); staticElement.SetDirty(); } }
private void RefreshHeadStaticElements(out int indexCursor) { indexCursor = 0; for (int i = 0; i < m_staticElementList.Count; ++i) { UILayoutGroupElementStatic staticElement = m_staticElementList[i]; if (staticElement.indexType == UILayoutGroupElementStatic.EIndexType.Head) { indexCursor = GetUnUsedIndex(indexCursor); int index = indexCursor; indexCursor++; staticElement.index = index; RecordIndex(index); } } }
private void RefreshTailStaticElements() { int indexCursor = m_maxIndex + 1; for (int i = 0; i < m_staticElementList.Count; ++i) { UILayoutGroupElementStatic staticElement = m_staticElementList[i]; if (staticElement.indexType == UILayoutGroupElementStatic.EIndexType.Tail) { indexCursor = GetUnUsedIndex(indexCursor); int index = indexCursor; indexCursor++; staticElement.index = indexCursor; RecordIndex(index); } } }