Skip to content

Commit 14d3e18

Browse files
authored
NEW: Added Regenerate Precompiled Layouts for internal FastXXX layouts to QA menu. (#2258)
1 parent 84b8fb3 commit 14d3e18

File tree

9 files changed

+94
-2
lines changed

9 files changed

+94
-2
lines changed

Assets/Editor/AddScenesToBuild.cs.meta

Lines changed: 0 additions & 2 deletions
This file was deleted.
File renamed without changes.
File renamed without changes.

Assets/Tools/AddScenesToBuild.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
using System;
2+
using System.IO;
3+
using UnityEditor;
4+
using UnityEngine;
5+
using UnityEngine.InputSystem;
6+
using UnityEngine.InputSystem.Editor;
7+
8+
namespace Editor
9+
{
10+
internal static class RegeneratePrecompiledLayouts
11+
{
12+
private static void GeneratePrecompiledLayout(string path, string layoutName)
13+
{
14+
var filePath = Path.Combine(path, "Fast" + layoutName + ".cs");
15+
if (!File.Exists(filePath))
16+
{
17+
Debug.Log($"Cannot generate precompiled layout for: '{filePath}', only existing files may be updated.");
18+
return;
19+
}
20+
var code = InputLayoutCodeGenerator.GenerateCodeFileForDeviceLayout(layoutName, filePath, prefix: "Fast");
21+
var existingContent = File.ReadAllText(filePath);
22+
if (string.Compare(existingContent, code, StringComparison.InvariantCulture) == 0)
23+
{
24+
Debug.Log($"Skipped updating precompiled layout: '{filePath}'. No difference.");
25+
return;
26+
}
27+
28+
try
29+
{
30+
File.WriteAllText(filePath, code);
31+
}
32+
catch (Exception e)
33+
{
34+
Debug.LogException(e);
35+
return;
36+
}
37+
38+
Debug.Log($"Updated precompiled layout: '{filePath}'.");
39+
}
40+
41+
private static void GeneratePrecompiledLayouts(string path)
42+
{
43+
GeneratePrecompiledLayout(path, nameof(Keyboard));
44+
GeneratePrecompiledLayout(path, nameof(Mouse));
45+
GeneratePrecompiledLayout(path, nameof(Touchscreen));
46+
}
47+
48+
[MenuItem("QA Tools/Regenerate Precompiled Layouts", priority = 20)]
49+
private static void GeneratePrecompiledLayouts()
50+
{
51+
GeneratePrecompiledLayouts("Packages/com.unity.inputsystem/InputSystem/Devices/Precompiled");
52+
}
53+
}
54+
}

Assets/Tools/RegeneratePrecompiledLayouts.cs.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "Unity.InputSystem.EditorDevelopmentTools",
3+
"rootNamespace": "",
4+
"references": [
5+
"GUID:75469ad4d38634e559750d17036d5f7c"
6+
],
7+
"includePlatforms": [
8+
"Editor"
9+
],
10+
"excludePlatforms": [],
11+
"allowUnsafeCode": false,
12+
"overrideReferences": false,
13+
"precompiledReferences": [],
14+
"autoReferenced": true,
15+
"defineConstraints": [],
16+
"versionDefines": [],
17+
"noEngineReferences": false
18+
}

Assets/Tools/Unity.InputSystem.EditorDevelopmentTools.asmdef.meta

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Packages/com.unity.inputsystem/InputSystem/AssemblyInfo.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
[assembly: InternalsVisibleTo("Unity.InputSystem.IntegrationTests")]
1010
[assembly: InternalsVisibleTo("Unity.InputSystem.ForUI")] // To avoid minor bump
1111
[assembly: InternalsVisibleTo("Unity.AI.Assistant.Editor")]
12+
[assembly: InternalsVisibleTo("Unity.InputSystem.EditorDevelopmentTools")]
1213

1314
namespace UnityEngine.InputSystem
1415
{

0 commit comments

Comments
 (0)