public void DrawBind(SerializedProperty bind, int parentIndex, int currentIndex) { SerializedProperty name = bind.FindPropertyRelative("name"); string bindName = name.stringValue; if (bindName == "") { bindName = "Bind Name"; } EditorGUILayout.BeginHorizontal(); bind.isExpanded = EditorGUILayout.Foldout(bind.isExpanded, bindName); InspectorTools.Space(2); if (bindIndex.bind == currentIndex && bindIndex.binds == parentIndex) { if (GUILayout.Button("Deselect")) { bindIndex = new BindIndex(-1, -1); } } else if (GUILayout.Button("Select")) { bindIndex = new BindIndex(currentIndex, parentIndex); } EditorGUILayout.EndHorizontal(); if (bind.isExpanded) { InspectorTools.Space(); SerializedProperty primary = bind.FindPropertyRelative("primary"); SerializedProperty secondary = bind.FindPropertyRelative("secondary"); SerializedProperty extra = bind.FindPropertyRelative("extra"); name.stringValue = EditorGUILayout.TextField("Name", name.stringValue); DrawKeyCode(primary, "Primary", new BindKeyIndex(parentIndex, currentIndex, 1)); DrawKeyCode(secondary, "Secondary", new BindKeyIndex(parentIndex, currentIndex, 2)); DrawKeyCode(extra, "Extra", new BindKeyIndex(parentIndex, currentIndex, 3)); InspectorTools.Space(); } }
public void DrawBinds(SerializedProperty bindsElement, int currentIndex) { SerializedProperty categoryName = bindsElement.FindPropertyRelative("categoryName"); SerializedProperty bindsArray = bindsElement.FindPropertyRelative("binds"); string categoryNameLabel = categoryName.stringValue; if (categoryNameLabel == "") { categoryNameLabel = "Category " + currentIndex; } EditorGUILayout.BeginHorizontal(); bindsArray.isExpanded = EditorGUILayout.Foldout(bindsArray.isExpanded, categoryNameLabel); if (bindsIndex == currentIndex) { if (GUILayout.Button("Deselect")) { bindsIndex = -1; } } else if (GUILayout.Button("Select")) { bindsIndex = currentIndex; } EditorGUILayout.EndHorizontal(); if (bindsArray.isExpanded) { InspectorTools.Space(); categoryName.stringValue = EditorGUILayout.TextField("Name", categoryName.stringValue); bindsArray.arraySize = EditorGUILayout.IntField("Size", bindsArray.arraySize); bindsArray.arraySize = InspectorTools.DrawArraySizeButtons(bindsArray.arraySize, 1, 1); if (bindIndex.bind > bindsArray.arraySize - 1 && bindIndex.binds == currentIndex) { bindIndex = new BindIndex(-1, -1); } EditorGUI.indentLevel += 2; for (int i = 0; i < bindsArray.arraySize; i++) { SerializedProperty bind = bindsArray.GetArrayElementAtIndex(i); DrawBind(bind, currentIndex, i); if (i == bindsArray.arraySize - 1) { InspectorTools.Space(1); } } EditorGUI.indentLevel -= 2; if (bindIndex.bind != -1 && bindIndex.binds == currentIndex) { int index = InspectorTools.DrawArryElementModifiers(bindIndex.bind, bindsArray.arraySize, 1, 1); if (index == -1) { bindsArray.DeleteArrayElementAtIndex(bindIndex.binds); bindIndex = new BindIndex(-1, -1); } if (index != bindIndex.bind) { bindsArray.MoveArrayElement(bindIndex.bind, index); bindIndex.bind = index; } } } }