示例#1
0
 public void OnGUI()
 {
     if (m_EditableParametersForEachListItem == null || m_EditableParametersForEachListItem.Length == 0)
     {
         using (var scope = new EditorGUI.DisabledScope(true))
         {
             EditorGUI.indentLevel++;
             EditorGUILayout.LabelField($"No {itemName}s have been added.");
             EditorGUI.indentLevel--;
         }
     }
     else
     {
         for (var i = 0; i < m_EditableParametersForEachListItem.Length; i++)
         {
             var editableParams = m_EditableParametersForEachListItem[i];
             EditorGUILayout.BeginHorizontal();
             if (editableParams.hasUIToShow)
             {
                 editableParams.visible = EditorGUILayout.Foldout(editableParams.visible, editableParams.name, Styles.s_FoldoutStyle);
             }
             else
             {
                 GUILayout.Space(16);
                 EditorGUILayout.LabelField(editableParams.name, EditorStyles.boldLabel);
             }
             GUILayout.FlexibleSpace();
             using (var scope = new EditorGUI.DisabledScope(i == 0))
             {
                 if (GUILayout.Button(m_UpButton, Styles.s_UpDownButtonStyle))
                 {
                     SwapEntry(i, i - 1);
                 }
             }
             using (var scope = new EditorGUI.DisabledScope(i == m_EditableParametersForEachListItem.Length - 1))
             {
                 if (GUILayout.Button(m_DownButton, Styles.s_UpDownButtonStyle))
                 {
                     SwapEntry(i, i + 1);
                 }
             }
             if (GUILayout.Button(m_DeleteButton, EditorStyles.label))
             {
                 ArrayHelpers.EraseAt(ref m_ParametersForEachListItem, i);
                 ArrayHelpers.EraseAt(ref m_EditableParametersForEachListItem, i);
                 m_Apply();
                 GUIUtility.ExitGUI();
             }
             EditorGUILayout.EndHorizontal();
             if (editableParams.visible)
             {
                 EditorGUI.indentLevel++;
                 editableParams.OnGUI();
                 EditorGUI.indentLevel--;
             }
             GUIHelpers.DrawLineSeparator();
         }
     }
 }