Skip to content

Commit 6f1ad16

Browse files
authored
FIX: Address compilation warnings from Unity 6.4 and 6.5 (#2295)
1 parent aaaf3cc commit 6f1ad16

File tree

5 files changed

+40
-8
lines changed

5 files changed

+40
-8
lines changed

Packages/com.unity.inputsystem/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ however, it has to be formatted properly to pass verification tests.
1010

1111
## [Unreleased] - yyyy-mm-dd
1212

13+
### Fixed
1314

15+
- Fixed warnings being generated on Unity 6.4 and 6.5. (ISX-2395).
1416

1517
## [1.17.0] - 2025-11-25
1618

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,8 +328,13 @@ internal static IEnumerable<InputActionReference> LoadInputActionReferencesFromA
328328
[MenuItem("Assets/Create/Input Actions")]
329329
public static void CreateInputAsset()
330330
{
331+
#if UNITY_6000_4_OR_NEWER
332+
ProjectWindowUtil.CreateAssetWithTextContent("New Actions." + InputActionAsset.Extension,
333+
InputActionAsset.kDefaultAssetLayoutJson, InputActionAssetIconLoader.LoadAssetIcon());
334+
#else
331335
ProjectWindowUtil.CreateAssetWithContent("New Actions." + InputActionAsset.Extension,
332336
InputActionAsset.kDefaultAssetLayoutJson, InputActionAssetIconLoader.LoadAssetIcon());
337+
#endif
333338
}
334339

335340
// File extension of the associated asset

Packages/com.unity.inputsystem/InputSystem/Editor/PropertyDrawers/InputActionAssetSearchProvider.cs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using System.Collections.Generic;
44
using UnityEditor;
55
using UnityEditor.Search;
6-
using UnityEngine.Search;
76

87
namespace UnityEngine.InputSystem.Editor
98
{
@@ -12,8 +11,6 @@ internal static class InputActionAssetSearchProviders
1211
const string k_AssetFolderSearchProviderId = "AssetsInputActionAssetSearchProvider";
1312
const string k_ProjectWideActionsSearchProviderId = "ProjectWideInputActionAssetSearchProvider";
1413

15-
const string k_ProjectWideAssetIdentificationString = " [Project Wide Input Actions]";
16-
1714
internal static SearchProvider CreateInputActionAssetSearchProvider()
1815
{
1916
return CreateInputActionAssetSearchProvider(k_AssetFolderSearchProviderId,
@@ -101,7 +98,17 @@ private static IEnumerable<SearchItem> FilteredSearch(SearchContext context, Sea
10198

10299
if (!label.Contains(context.searchText, System.StringComparison.InvariantCultureIgnoreCase))
103100
continue; // Ignore due to filtering
104-
yield return provider.CreateItem(context, asset.GetInstanceID().ToString(), label, createItemFetchDescription(asset),
101+
102+
string itemId;
103+
104+
// 6.4 deprecated instance ids in favour of entity ids
105+
#if UNITY_6000_4_OR_NEWER
106+
itemId = asset.GetEntityId().ToString();
107+
#else
108+
itemId = asset.GetInstanceID().ToString();
109+
#endif
110+
111+
yield return provider.CreateItem(context, itemId, label, createItemFetchDescription(asset),
105112
thumbnail, asset);
106113
}
107114
}
@@ -110,7 +117,6 @@ private static IEnumerable<SearchItem> FilteredSearch(SearchContext context, Sea
110117
// consistent between CreateItem and additional fetchLabel calls.
111118
private static string FetchLabel(Object obj)
112119
{
113-
// if (obj == InputSystem.actions) return $"{obj.name}{k_ProjectWideAssetIdentificationString}";
114120
return obj.name;
115121
}
116122

Packages/com.unity.inputsystem/InputSystem/Editor/PropertyDrawers/InputActionReferenceSearchProviders.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ internal static class SearchConstants
1212
// SearchFlags: these flags are used to customize how search is performed and how search
1313
// results are displayed in the advanced object picker.
1414
// Note: SearchFlags.Packages is not currently used and hides all results from packages.
15-
internal static readonly SearchFlags PickerSearchFlags = SearchFlags.Sorted | SearchFlags.OpenPicker;
15+
internal static readonly SearchFlags PickerSearchFlags = SearchFlags.OpenPicker;
1616

1717
// Search.SearchViewFlags : these flags are used to customize the appearance of the PickerWindow.
1818
internal static readonly Search.SearchViewFlags PickerViewFlags = SearchViewFlags.DisableBuilderModeToggle
@@ -84,7 +84,17 @@ private static IEnumerable<SearchItem> FilteredSearch(SearchContext context, Sea
8484
var label = fetchObjectLabel(asset);
8585
if (!label.Contains(context.searchText, System.StringComparison.InvariantCultureIgnoreCase))
8686
continue; // Ignore due to filtering
87-
yield return provider.CreateItem(context, asset.GetInstanceID().ToString(), label, createItemFetchDescription(asset),
87+
88+
string itemId;
89+
90+
// 6.4 deprecated instance ids in favour of entity ids
91+
#if UNITY_6000_4_OR_NEWER
92+
itemId = asset.GetEntityId().ToString();
93+
#else
94+
itemId = asset.GetInstanceID().ToString();
95+
#endif
96+
97+
yield return provider.CreateItem(context, itemId, label, createItemFetchDescription(asset),
8898
null, asset);
8999
}
90100
}

Packages/com.unity.inputsystem/InputSystem/Plugins/PlayerInput/PlayerInputEditor.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,16 @@ bool CheckIfActionAssetChanged()
278278
{
279279
if (m_ActionsProperty.objectReferenceValue != null)
280280
{
281-
var assetInstanceID = m_ActionsProperty.objectReferenceValue.GetInstanceID();
281+
// 6.4 deprecates instance id in favour of entity ids (a class)
282+
// Fortunately, there is an implicit cast from entity id to an integer so we can have minimum footprint for now.
283+
int assetInstanceID;
284+
285+
#if UNITY_6000_4_OR_NEWER
286+
assetInstanceID = m_ActionsProperty.objectReferenceValue.GetEntityId();
287+
#else
288+
assetInstanceID = m_ActionsProperty.objectReferenceValue.GetInstanceID();
289+
#endif
290+
282291
// if the m_ActionAssetInstanceID is 0 the PlayerInputEditor has not been initialized yet, but the asset did not change
283292
bool result = assetInstanceID != m_ActionAssetInstanceID && m_ActionAssetInstanceID != 0;
284293
m_ActionAssetInstanceID = (int)assetInstanceID;

0 commit comments

Comments
 (0)