Skip to content

Commit 675f70f

Browse files
author
Rene Damm
authored
REVERT: Missing InputActionReferences when renaming actions (case 1129145, #1100, #1116).
This reverts commit 8e4e35d.
1 parent 8e4e35d commit 675f70f

File tree

4 files changed

+7
-25
lines changed

4 files changed

+7
-25
lines changed

Packages/com.unity.inputsystem/CHANGELOG.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ however, it has to be formatted properly to pass verification tests.
2020

2121
#### Actions
2222

23-
- References to `InputActionReference` objects created by the importer for `.inputactions` files are no longer broken when the action referenced by the object is renamed ([case 1229145](https://issuetracker.unity3d.com/issues/inputsystem-inputactionreference-loses-guid-when-its-action-is-moved-or-renamed-in-the-inputaction-asset)).
24-
* __THIS IS A BREAKING CHANGE__: Unfortunately, this change impacts Unity internal file IDs of `InputActionReference` objects created by the `.inputactions` file importer. This means that previously created references to `InputActionReference` objects will become missing and need to be recreated.
25-
* __HOW TO FIX BROKEN REFERENCES__: Locate the sub-object in the `.inputactions` asset for the action you are referencing and replace the now missing references with the newly created objects.
2623
- Controls are now re-resolved after adding or removing bindings from actions ([case 1218544](https://issuetracker.unity3d.com/issues/input-system-package-does-not-re-resolve-bindings-when-adding-a-new-binding-to-a-map-that-has-already-generated-its-state)).
2724
- Can now have spaces and special characters in action names when using `PlayerInput` with the `SendMessages` or `BroadcastMessages` behavior. Previously, an incorrect method name was generated (fix contributed by [BHSPitMonkey](https://github.com/BHSPitMonkey) in [#1022](https://github.com/Unity-Technologies/InputSystem/pull/1022); [case 1214519](https://issuetracker.unity3d.com/issues/player-input-send-messages-wont-trigger-when-input-action-name-contains-spaces)).
2825
- Adding a new action now sets `expectedControlType` to `Button` as expected ([case 1221015](https://issuetracker.unity3d.com/issues/input-system-default-value-of-expectedcontroltype-is-not-being-set-when-creating-a-new-action)).

Packages/com.unity.inputsystem/InputSystem/Actions/InputActionReference.cs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,6 @@
11
using System;
22
using System.Linq;
33

4-
////REVIEW: Can we somehow make this a simple struct? The one problem we have is that we can't put struct instances as sub-assets into
5-
//// the import (i.e. InputActionImporter can't do AddObjectToAsset with them). However, maybe there's a way around that. The thing
6-
//// is that we really want to store the asset reference plus the action GUID on the *user* side, i.e. the referencing side. Right
7-
//// now, what happens is that InputActionImporter puts these objects along with the reference and GUID they contain in the
8-
//// *imported* object, i.e. right with the asset. This partially defeats the whole purpose of having these objects and it means
9-
//// that now the GUID doesn't really matter anymore. Rather, it's the file ID that now has to be stable.
10-
////
11-
//// If we always store the GUID and asset reference on the user side, we can put the serialized data *anywhere* and it'll remain
12-
//// save and proper no matter what we do in InputActionImporter.
13-
144
////REVIEW: should this throw if you try to assign an action that is not a singleton?
155

166
////REVIEW: akin to this, also have an InputActionMapReference?
@@ -59,7 +49,7 @@ public InputAction action
5949
if (m_Asset == null)
6050
return null;
6151

62-
m_Action = m_Asset.FindAction(m_ActionId);
52+
m_Action = m_Asset.FindAction(new Guid(m_ActionId));
6353
}
6454

6555
return m_Action;

Packages/com.unity.inputsystem/InputSystem/Editor/AssetEditor/InputActionAssetManager.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
using System.IO;
44
using UnityEditor;
55

6-
////TODO: ensure that GUIDs in the asset are unique
7-
86
namespace UnityEngine.InputSystem.Editor
97
{
108
/// <summary>

Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporter.cs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#if UNITY_EDITOR
22
using System;
33
using System.IO;
4-
using System.Linq;
54
using UnityEditor;
65
using UnityEditor.Experimental.AssetImporters;
76
using UnityEngine.InputSystem.Utilities;
@@ -23,7 +22,7 @@ namespace UnityEngine.InputSystem.Editor
2322
[ScriptedImporter(kVersion, InputActionAsset.Extension)]
2423
internal class InputActionImporter : ScriptedImporter
2524
{
26-
private const int kVersion = 11;
25+
private const int kVersion = 10;
2726

2827
private const string kActionIcon = "Packages/com.unity.inputsystem/InputSystem/Editor/Icons/InputAction.png";
2928
private const string kAssetIcon = "Packages/com.unity.inputsystem/InputSystem/Editor/Icons/InputActionAsset.png";
@@ -91,27 +90,25 @@ public override void OnImportAsset(AssetImportContext ctx)
9190
ctx.AddObjectToAsset("<root>", asset, assetIcon);
9291
ctx.SetMainObject(asset);
9392

94-
// Make sure all the elements in the asset have GUIDs and that they are indeed unique.
93+
// Make sure all the elements in the asset have GUIDs.
9594
var maps = asset.actionMaps;
9695
foreach (var map in maps)
9796
{
9897
// Make sure action map has GUID.
99-
if (string.IsNullOrEmpty(map.m_Id) || asset.actionMaps.Count(x => x.m_Id == map.m_Id) > 1)
98+
if (string.IsNullOrEmpty(map.m_Id))
10099
map.GenerateId();
101100

102101
// Make sure all actions have GUIDs.
103102
foreach (var action in map.actions)
104103
{
105-
var actionId = action.m_Id;
106-
if (string.IsNullOrEmpty(actionId) || asset.actionMaps.Sum(m => m.actions.Count(a => a.m_Id == actionId)) > 1)
104+
if (string.IsNullOrEmpty(action.m_Id))
107105
action.GenerateId();
108106
}
109107

110108
// Make sure all bindings have GUIDs.
111109
for (var i = 0; i < map.m_Bindings.LengthSafe(); ++i)
112110
{
113-
var bindingId = map.m_Bindings[i].m_Id;
114-
if (string.IsNullOrEmpty(bindingId) || asset.actionMaps.Sum(m => m.bindings.Count(b => b.m_Id == bindingId)) > 1)
111+
if (string.IsNullOrEmpty(map.m_Bindings[i].m_Id))
115112
map.m_Bindings[i].GenerateId();
116113
}
117114
}
@@ -131,7 +128,7 @@ public override void OnImportAsset(AssetImportContext ctx)
131128
objectName = $"{map.name}/{action.name}";
132129

133130
actionReference.name = objectName;
134-
ctx.AddObjectToAsset(action.m_Id, actionReference, actionIcon);
131+
ctx.AddObjectToAsset(objectName, actionReference, actionIcon);
135132
}
136133
}
137134

0 commit comments

Comments
 (0)