Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions Packages/com.unity.inputsystem/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

### Changed

- Changed the UI for `Actions.inputactions` asset to use UI Toolkit framework.

### Added

- Support for entering the play mode with domain reload turned off (i.e. Faster Enter Playmode feature) [ISX-2411]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#if UNITY_EDITOR
using System;
using System.IO;
using UnityEngine.InputSystem.Utilities;
using UnityEditor;
using UnityEditor.AssetImporters;
using UnityEngine.UIElements;
using UnityEditor.UIElements;

////TODO: support for multi-editing

Expand All @@ -15,90 +16,215 @@
[CustomEditor(typeof(InputActionImporter))]
internal class InputActionImporterEditor : ScriptedImporterEditor
{
public override void OnInspectorGUI()
public override VisualElement CreateInspectorGUI()
{
var root = new VisualElement();
root.styleSheets.Add(AssetDatabase.LoadAssetAtPath<StyleSheet>(

Check warning on line 22 in Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs#L21-L22

Added lines #L21 - L22 were not covered by tests
InputActionsEditorConstants.PackagePath +
"/InputSystem/Editor/AssetImporter/InputActionImporterEditor.uss"));
var inputActionAsset = GetAsset();

// ScriptedImporterEditor in 2019.2 now requires explicitly updating the SerializedObject
// like in other types of editors.
serializedObject.Update();

EditorGUILayout.Space();

if (inputActionAsset == null)
EditorGUILayout.HelpBox("The currently selected object is not an editable input action asset.",
MessageType.Info);
{
root.Add(new HelpBox(

Check warning on line 33 in Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs#L32-L33

Added lines #L32 - L33 were not covered by tests
"The currently selected object is not an editable input action asset.",
HelpBoxMessageType.Info));
}

Check warning on line 36 in Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs#L36

Added line #L36 was not covered by tests

var editButton = new Button(() => OpenEditor(inputActionAsset))

Check warning on line 38 in Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs#L38

Added line #L38 was not covered by tests
{
text = GetOpenEditorButtonText(inputActionAsset)
};
editButton.AddToClassList("input-action-importer-editor__edit-button");
editButton.SetEnabled(inputActionAsset != null);
root.Add(editButton);

Check warning on line 44 in Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs#L42-L44

Added lines #L42 - L44 were not covered by tests

var projectWideContainer = new VisualElement();
projectWideContainer.AddToClassList("input-action-importer-editor__project-wide-container");
root.Add(projectWideContainer);
BuildProjectWideSection(projectWideContainer, inputActionAsset);

Check warning on line 49 in Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs#L46-L49

Added lines #L46 - L49 were not covered by tests

BuildCodeGenerationSection(root, inputActionAsset);

Check warning on line 51 in Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs#L51

Added line #L51 was not covered by tests

root.Add(new IMGUIContainer(() =>
{
serializedObject.ApplyModifiedProperties();
ApplyRevertGUI();
}));

Check warning on line 57 in Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs#L53-L57

Added lines #L53 - L57 were not covered by tests

return root;
}

Check warning on line 60 in Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs#L59-L60

Added lines #L59 - L60 were not covered by tests

private void BuildProjectWideSection(VisualElement container, InputActionAsset inputActionAsset)
{
container.Clear();

Check warning on line 64 in Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs#L63-L64

Added lines #L63 - L64 were not covered by tests

// Button to pop up window to edit the asset.
using (new EditorGUI.DisabledScope(inputActionAsset == null))
var currentActions = InputSystem.actions;

Check warning on line 66 in Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs#L66

Added line #L66 was not covered by tests

if (currentActions == inputActionAsset)

Check warning on line 68 in Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs#L68

Added line #L68 was not covered by tests
{
if (GUILayout.Button(GetOpenEditorButtonText(inputActionAsset), GUILayout.Height(30)))
OpenEditor(inputActionAsset);
container.Add(new HelpBox(

Check warning on line 70 in Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs#L70

Added line #L70 was not covered by tests
"These actions are assigned as the Project-wide Input Actions.",
HelpBoxMessageType.Info));
return;

Check warning on line 73 in Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs#L73

Added line #L73 was not covered by tests
}

EditorGUILayout.Space();
var message = "These actions are not assigned as the Project-wide Input Actions for the Input System.";
if (currentActions != null)
{
var currentPath = AssetDatabase.GetAssetPath(currentActions);
if (!string.IsNullOrEmpty(currentPath))
message += $" The actions currently assigned as the Project-wide Input Actions are: {currentPath}. ";
}

Check warning on line 82 in Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs#L76-L82

Added lines #L76 - L82 were not covered by tests

// Project-wide Input Actions Asset UI.
InputAssetEditorUtils.DrawMakeActiveGui(InputSystem.actions, inputActionAsset,
inputActionAsset ? inputActionAsset.name : "Null", "Project-wide Input Actions",
(value) => InputSystem.actions = value, !EditorApplication.isPlayingOrWillChangePlaymode);
container.Add(new HelpBox(message, HelpBoxMessageType.Warning));

Check warning on line 84 in Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs#L84

Added line #L84 was not covered by tests

EditorGUILayout.Space();
var assignButton = new Button(() =>
{
InputSystem.actions = inputActionAsset;
BuildProjectWideSection(container, inputActionAsset);
})

Check warning on line 90 in Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs#L86-L90

Added lines #L86 - L90 were not covered by tests
{
text = "Assign as the Project-wide Input Actions"
};
assignButton.AddToClassList("input-action-importer-editor__assign-button");
assignButton.SetEnabled(!EditorApplication.isPlayingOrWillChangePlaymode);
container.Add(assignButton);
}

Check warning on line 97 in Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs#L94-L97

Added lines #L94 - L97 were not covered by tests

// Importer settings UI.
var generateWrapperCodeProperty = serializedObject.FindProperty("m_GenerateWrapperCode");
EditorGUILayout.PropertyField(generateWrapperCodeProperty, m_GenerateWrapperCodeLabel);
if (generateWrapperCodeProperty.boolValue)
private void BuildCodeGenerationSection(VisualElement root, InputActionAsset inputActionAsset)
{
var generateField = new PropertyField(

Check warning on line 101 in Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs#L100-L101

Added lines #L100 - L101 were not covered by tests
serializedObject.FindProperty("m_GenerateWrapperCode"), "Generate C# Class");
root.Add(generateField);

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

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs#L103

Added line #L103 was not covered by tests

var codeGenContainer = new VisualElement();
root.Add(codeGenContainer);

Check warning on line 106 in Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs#L105-L106

Added lines #L105 - L106 were not covered by tests

// File path with browse button
string defaultFileName = "";
if (inputActionAsset != null)

Check warning on line 110 in Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs#L109-L110

Added lines #L109 - L110 were not covered by tests
{
var wrapperCodePathProperty = serializedObject.FindProperty("m_WrapperCodePath");
var wrapperClassNameProperty = serializedObject.FindProperty("m_WrapperClassName");
var wrapperCodeNamespaceProperty = serializedObject.FindProperty("m_WrapperCodeNamespace");
var assetPath = AssetDatabase.GetAssetPath(inputActionAsset);
defaultFileName = Path.ChangeExtension(assetPath, ".cs");
}

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

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs#L112-L114

Added lines #L112 - L114 were not covered by tests

var pathRow = new VisualElement();
pathRow.AddToClassList("input-action-importer-editor__path-row");
codeGenContainer.Add(pathRow);

Check warning on line 118 in Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs#L116-L118

Added lines #L116 - L118 were not covered by tests

EditorGUILayout.BeginHorizontal();
var pathField = new TextField("C# Class File") { bindingPath = "m_WrapperCodePath" };
pathField.AddToClassList("input-action-importer-editor__path-field");
pathField.AddToClassList(BaseField<string>.alignedFieldUssClassName);
SetupPlaceholder(pathField, defaultFileName);
pathRow.Add(pathField);

Check warning on line 124 in Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs#L120-L124

Added lines #L120 - L124 were not covered by tests

string defaultFileName = "";
if (inputActionAsset != null)
var browseButton = new Button(() =>
{
var fileName = EditorUtility.SaveFilePanel("Location for generated C# file",

Check warning on line 128 in Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs#L126-L128

Added lines #L126 - L128 were not covered by tests
Path.GetDirectoryName(defaultFileName),
Path.GetFileName(defaultFileName), "cs");
if (!string.IsNullOrEmpty(fileName))

Check warning on line 131 in Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs#L131

Added line #L131 was not covered by tests
{
var assetPath = AssetDatabase.GetAssetPath(inputActionAsset);
defaultFileName = Path.ChangeExtension(assetPath, ".cs");
if (fileName.StartsWith(Application.dataPath))
fileName = "Assets/" + fileName.Substring(Application.dataPath.Length + 1);

Check warning on line 134 in Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs#L133-L134

Added lines #L133 - L134 were not covered by tests

var prop = serializedObject.FindProperty("m_WrapperCodePath");
prop.stringValue = fileName;
serializedObject.ApplyModifiedProperties();

Check warning on line 138 in Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs#L136-L138

Added lines #L136 - L138 were not covered by tests
}
})

Check warning on line 140 in Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs#L140

Added line #L140 was not covered by tests
{
text = "…"
};
browseButton.AddToClassList("input-action-importer-editor__browse-button");
pathRow.Add(browseButton);

Check warning on line 145 in Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs#L144-L145

Added lines #L144 - L145 were not covered by tests

wrapperCodePathProperty.PropertyFieldWithDefaultText(m_WrapperCodePathLabel, defaultFileName);
// Class name
string typeName = inputActionAsset != null

Check warning on line 148 in Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs#L148

Added line #L148 was not covered by tests
? CSharpCodeHelpers.MakeTypeName(inputActionAsset.name)
: null;

if (GUILayout.Button("…", EditorStyles.miniButton, GUILayout.MaxWidth(20)))
{
var fileName = EditorUtility.SaveFilePanel("Location for generated C# file",
Path.GetDirectoryName(defaultFileName),
Path.GetFileName(defaultFileName), "cs");
if (!string.IsNullOrEmpty(fileName))
{
if (fileName.StartsWith(Application.dataPath))
fileName = "Assets/" + fileName.Substring(Application.dataPath.Length + 1);

wrapperCodePathProperty.stringValue = fileName;
}
}
EditorGUILayout.EndHorizontal();
var classNameField = new TextField("C# Class Name") { bindingPath = "m_WrapperClassName" };
classNameField.AddToClassList(BaseField<string>.alignedFieldUssClassName);
SetupPlaceholder(classNameField, typeName ?? "<Class name>");
codeGenContainer.Add(classNameField);

Check warning on line 155 in Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs#L152-L155

Added lines #L152 - L155 were not covered by tests

string typeName = null;
if (inputActionAsset != null)
typeName = CSharpCodeHelpers.MakeTypeName(inputActionAsset?.name);
wrapperClassNameProperty.PropertyFieldWithDefaultText(m_WrapperClassNameLabel, typeName ?? "<Class name>");
var classNameError = new HelpBox("Must be a valid C# identifier", HelpBoxMessageType.Error);
codeGenContainer.Add(classNameError);

Check warning on line 158 in Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs#L157-L158

Added lines #L157 - L158 were not covered by tests

if (!CSharpCodeHelpers.IsEmptyOrProperIdentifier(wrapperClassNameProperty.stringValue))
EditorGUILayout.HelpBox("Must be a valid C# identifier", MessageType.Error);
var classNameProp = serializedObject.FindProperty("m_WrapperClassName");
classNameError.style.display = !CSharpCodeHelpers.IsEmptyOrProperIdentifier(classNameProp.stringValue)

Check warning on line 161 in Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs#L160-L161

Added lines #L160 - L161 were not covered by tests
? DisplayStyle.Flex : DisplayStyle.None;

wrapperCodeNamespaceProperty.PropertyFieldWithDefaultText(m_WrapperCodeNamespaceLabel, "<Global namespace>");
classNameField.RegisterValueChangedCallback(evt =>
{
classNameError.style.display = !CSharpCodeHelpers.IsEmptyOrProperIdentifier(evt.newValue)

Check warning on line 166 in Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs#L164-L166

Added lines #L164 - L166 were not covered by tests
? DisplayStyle.Flex : DisplayStyle.None;
});

Check warning on line 168 in Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs#L168

Added line #L168 was not covered by tests

if (!CSharpCodeHelpers.IsEmptyOrProperNamespaceName(wrapperCodeNamespaceProperty.stringValue))
EditorGUILayout.HelpBox("Must be a valid C# namespace name", MessageType.Error);
}
// Namespace
var namespaceField = new TextField("C# Class Namespace") { bindingPath = "m_WrapperCodeNamespace" };
namespaceField.AddToClassList(BaseField<string>.alignedFieldUssClassName);
SetupPlaceholder(namespaceField, "<Global namespace>");
codeGenContainer.Add(namespaceField);

Check warning on line 174 in Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs#L171-L174

Added lines #L171 - L174 were not covered by tests

var namespaceError = new HelpBox("Must be a valid C# namespace name", HelpBoxMessageType.Error);
codeGenContainer.Add(namespaceError);

Check warning on line 177 in Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs#L176-L177

Added lines #L176 - L177 were not covered by tests

// Using ApplyRevertGUI requires calling Update and ApplyModifiedProperties around the serializedObject,
// and will print warning messages otherwise (see warning message in ApplyRevertGUI implementation).
serializedObject.ApplyModifiedProperties();
var namespaceProp = serializedObject.FindProperty("m_WrapperCodeNamespace");
namespaceError.style.display = !CSharpCodeHelpers.IsEmptyOrProperNamespaceName(namespaceProp.stringValue)

Check warning on line 180 in Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs#L179-L180

Added lines #L179 - L180 were not covered by tests
? DisplayStyle.Flex : DisplayStyle.None;

ApplyRevertGUI();
namespaceField.RegisterValueChangedCallback(evt =>
{
namespaceError.style.display = !CSharpCodeHelpers.IsEmptyOrProperNamespaceName(evt.newValue)

Check warning on line 185 in Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs#L183-L185

Added lines #L183 - L185 were not covered by tests
? DisplayStyle.Flex : DisplayStyle.None;
});

Check warning on line 187 in Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs#L187

Added line #L187 was not covered by tests

// Show/hide code gen fields based on toggle
var generateProp = serializedObject.FindProperty("m_GenerateWrapperCode");
codeGenContainer.style.display = generateProp.boolValue ? DisplayStyle.Flex : DisplayStyle.None;

Check warning on line 191 in Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs#L190-L191

Added lines #L190 - L191 were not covered by tests

generateField.RegisterValueChangeCallback(evt =>
{
codeGenContainer.style.display = evt.changedProperty.boolValue

Check warning on line 195 in Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs#L193-L195

Added lines #L193 - L195 were not covered by tests
? DisplayStyle.Flex : DisplayStyle.None;
});
}

Check warning on line 198 in Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs#L197-L198

Added lines #L197 - L198 were not covered by tests

private static void SetupPlaceholder(TextField textField, string placeholder)
{
if (string.IsNullOrEmpty(placeholder))
return;

Check warning on line 203 in Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs#L201-L203

Added lines #L201 - L203 were not covered by tests

var placeholderLabel = new Label(placeholder);
placeholderLabel.pickingMode = PickingMode.Ignore;
placeholderLabel.AddToClassList("input-action-importer-editor__placeholder");

Check warning on line 207 in Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs#L205-L207

Added lines #L205 - L207 were not covered by tests

textField.RegisterCallback<GeometryChangedEvent>(_ =>
{
var textInput = textField.Q("unity-text-input");
if (textInput != null && placeholderLabel.parent != textInput)
{
textInput.Add(placeholderLabel);
UpdatePlaceholder(textField, placeholderLabel);
}
});

Check warning on line 217 in Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs#L209-L217

Added lines #L209 - L217 were not covered by tests

textField.RegisterValueChangedCallback(_ => UpdatePlaceholder(textField, placeholderLabel));
textField.RegisterCallback<FocusInEvent>(_ => placeholderLabel.style.display = DisplayStyle.None);
textField.RegisterCallback<FocusOutEvent>(_ => UpdatePlaceholder(textField, placeholderLabel));
}

Check warning on line 222 in Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs#L219-L222

Added lines #L219 - L222 were not covered by tests

private static void UpdatePlaceholder(TextField textField, Label placeholder)
{
placeholder.style.display = string.IsNullOrEmpty(textField.value)

Check warning on line 226 in Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs#L225-L226

Added lines #L225 - L226 were not covered by tests
? DisplayStyle.Flex : DisplayStyle.None;
}

private InputActionAsset GetAsset()
Expand Down Expand Up @@ -131,7 +257,6 @@

private static void OpenEditor(InputActionAsset asset)
{
// Redirect to Project-settings Input Actions editor if this is the project-wide actions asset
if (IsProjectWideActionsAsset(asset))
{
SettingsService.OpenProjectSettings(InputSettingsPath.kSettingsRootPath);
Expand All @@ -140,11 +265,6 @@

InputActionsEditorWindow.OpenEditor(asset);
}

private readonly GUIContent m_GenerateWrapperCodeLabel = EditorGUIUtility.TrTextContent("Generate C# Class");
private readonly GUIContent m_WrapperCodePathLabel = EditorGUIUtility.TrTextContent("C# Class File");
private readonly GUIContent m_WrapperClassNameLabel = EditorGUIUtility.TrTextContent("C# Class Name");
private readonly GUIContent m_WrapperCodeNamespaceLabel = EditorGUIUtility.TrTextContent("C# Class Namespace");
}
}
#endif // UNITY_EDITOR
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
.input-action-importer-editor__edit-button {
min-height: 30px;
margin-top: 4px;
margin-bottom: 4px;
white-space: normal;
overflow: hidden;
}

.input-action-importer-editor__assign-button {
white-space: normal;
overflow: hidden;
}

.input-action-importer-editor__project-wide-container {
margin-top: 6px;
margin-bottom: 6px;
}

.input-action-importer-editor__path-row {
flex-direction: row;
align-items: center;
}

.input-action-importer-editor__path-field {
flex-grow: 1;
}

.input-action-importer-editor__browse-button {
width: 25px;
}

.input-action-importer-editor__placeholder {
position: absolute;
opacity: 0.5;
padding-left: 2px;
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading