static public void DrawElements(ref Element[] elements) { for (int i = 0; i < elements.Length;) { if (StateElementDraw.DrawElement(elements[i])) { ArrayRemove <Element>(ref elements, i); } else { ++i; } } }
private void OnDrawElement(StateRoot target) { EditorGUI.indentLevel++; EditorGUILayout.BeginVertical("box"); m_ShowElement = EditorGUILayout.Foldout(m_ShowElement, "元素"); if (m_ShowElement) { EditorGUI.indentLevel++; if (target.elements != null) { for (int i = 0; i < target.elements.Count;) { if (StateElementDraw.DrawElement(target.elements[i])) { RegisterUndo(); target.RemoveElement(target.elements[i]); } else { ++i; } } } //增加按钮 int idx = StateElementDraw.DrawType(); if (idx != -1) { RegisterUndo(); target.AddElement((Type)idx); } EditorGUI.indentLevel--; } EditorGUI.indentLevel--; EditorGUILayout.EndVertical(); EditorGUILayout.Space(); }