Skip to content
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System;
using System.IO;
using UnityEditor;
using UnityEngine.UIElements;

namespace UnityEngine.InputSystem.Editor
{
Expand All @@ -19,7 +20,7 @@
InvalidPath,

/// <summary>
/// The dialog was cancelled by the user and the path is invalid.
/// The dialog was canceled by the user and the path is invalid.
Comment thread
josepmariapujol-unity marked this conversation as resolved.
Comment thread
josepmariapujol-unity marked this conversation as resolved.
/// </summary>
Cancelled,

Expand Down Expand Up @@ -82,25 +83,35 @@
return asset;
}

public static void DrawMakeActiveGui<T>(T current, T target, string targetName, string entity, Action<T> apply, bool allowAssignActive = true)
public static VisualElement CreateMakeActiveGui<T>(T current, T target, string targetName, string entity, Action<T> apply, bool allowAssignActive = true)
Comment thread
josepmariapujol-unity marked this conversation as resolved.
Outdated
Comment thread
josepmariapujol-unity marked this conversation as resolved.
Outdated
where T : ScriptableObject
{
var container = new VisualElement();

Check warning on line 89 in Packages/com.unity.inputsystem/InputSystem/Editor/InputAssetEditorUtils.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/InputAssetEditorUtils.cs#L89

Added line #L89 was not covered by tests

if (current == target)
{
EditorGUILayout.HelpBox($"These actions are assigned as the {entity}.", MessageType.Info);
return;
container.Add(new HelpBox($"These actions are assigned as the {entity}.", HelpBoxMessageType.Info));
Comment thread
josepmariapujol-unity marked this conversation as resolved.
return container;

Check warning on line 94 in Packages/com.unity.inputsystem/InputSystem/Editor/InputAssetEditorUtils.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/InputAssetEditorUtils.cs#L93-L94

Added lines #L93 - L94 were not covered by tests
}

string currentlyActiveAssetsPath = null;
if (current != null)
currentlyActiveAssetsPath = AssetDatabase.GetAssetPath(current);
if (!string.IsNullOrEmpty(currentlyActiveAssetsPath))
currentlyActiveAssetsPath = $" The actions currently assigned as the {entity} are: {currentlyActiveAssetsPath}. ";
EditorGUILayout.HelpBox($"These actions are not assigned as the {entity} for the Input System. {currentlyActiveAssetsPath??""}", MessageType.Warning);
GUI.enabled = allowAssignActive;
if (GUILayout.Button($"Assign as the {entity}", EditorStyles.miniButton))
apply(target);
GUI.enabled = true;

container.Add(new HelpBox(

Check warning on line 103 in Packages/com.unity.inputsystem/InputSystem/Editor/InputAssetEditorUtils.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/InputAssetEditorUtils.cs#L103

Added line #L103 was not covered by tests
Comment thread
josepmariapujol-unity marked this conversation as resolved.
$"These actions are not assigned as the {entity} for the Input System. {currentlyActiveAssetsPath ?? ""}",
Comment thread
josepmariapujol-unity marked this conversation as resolved.
HelpBoxMessageType.Warning));

var assignButton = new Button(() => apply(target))

Check warning on line 107 in Packages/com.unity.inputsystem/InputSystem/Editor/InputAssetEditorUtils.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/InputAssetEditorUtils.cs#L107

Added line #L107 was not covered by tests
Comment thread
josepmariapujol-unity marked this conversation as resolved.
Outdated
{
text = $"Assign as the {entity}"
};
assignButton.SetEnabled(allowAssignActive);
container.Add(assignButton);

Check warning on line 112 in Packages/com.unity.inputsystem/InputSystem/Editor/InputAssetEditorUtils.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/InputAssetEditorUtils.cs#L111-L112

Added lines #L111 - L112 were not covered by tests

return container;

Check warning on line 114 in Packages/com.unity.inputsystem/InputSystem/Editor/InputAssetEditorUtils.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/InputAssetEditorUtils.cs#L114

Added line #L114 was not covered by tests
}

public static bool IsValidFileExtension(string path)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -489,17 +489,21 @@
[CustomEditor(typeof(InputSettings))]
internal class InputSettingsEditor : UnityEditor.Editor
{
public override void OnInspectorGUI()
public override VisualElement CreateInspectorGUI()
{
EditorGUILayout.Space();
var root = new VisualElement();

Check warning on line 494 in Packages/com.unity.inputsystem/InputSystem/Editor/Settings/InputSettingsProvider.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/Settings/InputSettingsProvider.cs#L494

Added line #L494 was not covered by tests

if (GUILayout.Button("Open Input Settings Window", GUILayout.Height(30)))
InputSettingsProvider.Open();
var openButton = new Button(() => InputSettingsProvider.Open())

Check warning on line 496 in Packages/com.unity.inputsystem/InputSystem/Editor/Settings/InputSettingsProvider.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/Settings/InputSettingsProvider.cs#L496

Added line #L496 was not covered by tests
{
text = "Open Input Settings Window",
style = { height = 30 }
};
root.Add(openButton);

Check warning on line 501 in Packages/com.unity.inputsystem/InputSystem/Editor/Settings/InputSettingsProvider.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/Settings/InputSettingsProvider.cs#L501

Added line #L501 was not covered by tests

EditorGUILayout.Space();
root.Add(InputAssetEditorUtils.CreateMakeActiveGui(InputSystem.settings, target as InputSettings,
target.name, "settings", (value) => InputSystem.settings = value));

Check warning on line 504 in Packages/com.unity.inputsystem/InputSystem/Editor/Settings/InputSettingsProvider.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/Settings/InputSettingsProvider.cs#L503-L504

Added lines #L503 - L504 were not covered by tests

InputAssetEditorUtils.DrawMakeActiveGui(InputSystem.settings, target as InputSettings,
target.name, "settings", (value) => InputSystem.settings = value);
return root;

Check warning on line 506 in Packages/com.unity.inputsystem/InputSystem/Editor/Settings/InputSettingsProvider.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/Settings/InputSettingsProvider.cs#L506

Added line #L506 was not covered by tests
}

protected override bool ShouldHideOpenButton()
Expand Down
Loading