Beispiel #1
0
        void DrawInputFoldout(ReInput input)
        {
            if (!input.Validate())
            {
                foldoutStyle.normal.textColor = Color.red;
            }
            else
            {
                foldoutStyle.normal.textColor = Color.blue;
            }

            using (new GUILayout.HorizontalScope())
            {
                string foldoutName = $"{input.Name} {(settings.FoldoutToggles[input] ? " ↓" : " →")}";
                if (GUILayout.Button(foldoutName))
                {
                    settings.FoldoutToggles[input] = !settings.FoldoutToggles[input];
                }

                if (GUILayout.Button(ContentHelpers.RemoveButtonLabel, EditorStyles.miniButtonLeft))
                {
                    inputToRemove = input;
                }
                if (GUILayout.Button(ContentHelpers.CopyButtonLabel, EditorStyles.miniButtonMid))
                {
                    var copy = input.DeepCopy();
                    ((ReInputMap)target).InputMap.Add(copy);
                    wasAdded = true;
                }
                if (GUILayout.Button(ContentHelpers.MoveDownButtonLabel, EditorStyles.miniButtonMid))
                {
                    int indexOf = targetAs.InputMap.IndexOf(input);
                    if (indexOf == -1 || indexOf == targetAs.InputMap.Count - 1)
                    {
                        return;
                    }

                    targetAs.InputMap[indexOf]     = targetAs.InputMap[indexOf + 1];
                    targetAs.InputMap[indexOf + 1] = input;
                    wasAdded = true;
                }
                if (GUILayout.Button(ContentHelpers.MoveUpButtonLabel, EditorStyles.miniButtonRight))
                {
                    int indexOf = targetAs.InputMap.IndexOf(input);
                    if (indexOf == -1 || indexOf == 0 || targetAs.InputMap.Count == 0)
                    {
                        return;
                    }

                    targetAs.InputMap[indexOf]     = targetAs.InputMap[indexOf - 1];
                    targetAs.InputMap[indexOf - 1] = input;
                    wasAdded = true;
                }
            }
        }