Skip to content
Open
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,217 @@
[CustomEditor(typeof(InputActionImporter))]
internal class InputActionImporterEditor : ScriptedImporterEditor
{
public override void OnInspectorGUI()
public override VisualElement CreateInspectorGUI()
{
var root = new VisualElement();

Check warning on line 21 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

Added line #L21 was not covered by tests
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 30 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#L29-L30

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

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#L33

Added line #L33 was not covered by tests

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

Check warning on line 35 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#L35

Added line #L35 was not covered by tests
{
text = GetOpenEditorButtonText(inputActionAsset)
};
editButton.style.height = 30;
editButton.style.marginTop = 4;
editButton.style.marginBottom = 4;
editButton.SetEnabled(inputActionAsset != null);
root.Add(editButton);

Check warning on line 43 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#L39-L43

Added lines #L39 - L43 were not covered by tests

var projectWideContainer = new VisualElement();
projectWideContainer.style.marginTop = 6;
projectWideContainer.style.marginBottom = 6;
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#L45-L49

Added lines #L45 - 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.SetEnabled(!EditorApplication.isPlayingOrWillChangePlaymode);
container.Add(assignButton);
}

Check warning on line 96 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-L96

Added lines #L94 - L96 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 100 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#L99-L100

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

Check warning on line 102 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#L102

Added line #L102 was not covered by tests

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

Check warning on line 105 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#L104-L105

Added lines #L104 - L105 were not covered by tests

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

Check warning on line 109 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#L108-L109

Added lines #L108 - L109 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 113 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#L111-L113

Added lines #L111 - L113 were not covered by tests

var pathRow = new VisualElement();
pathRow.style.flexDirection = FlexDirection.Row;
pathRow.style.alignItems = Align.Center;
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#L115-L118

Added lines #L115 - L118 were not covered by tests

EditorGUILayout.BeginHorizontal();
var pathField = new TextField("C# Class File") { bindingPath = "m_WrapperCodePath" };
pathField.style.flexGrow = 1;
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.style.width = 25;
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.style.position = Position.Absolute;
placeholderLabel.style.opacity = 0.5f;
placeholderLabel.style.paddingLeft = 2;

Check warning on line 209 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-L209

Added lines #L205 - L209 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 219 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#L211-L219

Added lines #L211 - L219 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 224 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#L221-L224

Added lines #L221 - L224 were not covered by tests

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

Check warning on line 228 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#L227-L228

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

private InputActionAsset GetAsset()
Expand Down Expand Up @@ -131,7 +259,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 +267,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
Loading