A game about forced loneliness, made by TACStudios
1#if UNITY_EDITOR
2using System;
3using System.IO;
4using UnityEditor;
5using UnityEngine.UIElements;
6
7namespace UnityEngine.InputSystem.Editor
8{
9 internal static class InputActionsEditorWindowUtils
10 {
11 /// <summary>
12 /// Return a relative path to the currently active theme style sheet.
13 /// </summary>
14 public static StyleSheet theme => EditorGUIUtility.isProSkin
15 ? AssetDatabase.LoadAssetAtPath<StyleSheet>(InputActionsEditorConstants.PackagePath + InputActionsEditorConstants.ResourcesPath + "/InputAssetEditorDark.uss")
16 : AssetDatabase.LoadAssetAtPath<StyleSheet>(InputActionsEditorConstants.PackagePath + InputActionsEditorConstants.ResourcesPath + "/InputAssetEditorLight.uss");
17
18 // Similar to InputActionAsset.WriteFileJson but excludes the name
19 [Serializable]
20 private struct WriteFileJsonNoName
21 {
22 public InputActionMap.WriteMapJson[] maps;
23 public InputControlScheme.SchemeJson[] controlSchemes;
24 }
25
26 // Similar to InputActionAsset.ToJson() but converts to JSON excluding the name property and any additional JSON
27 // content that may be part of the file not recognized as required data.
28 public static string ToJsonWithoutName(InputActionAsset asset)
29 {
30 return JsonUtility.ToJson(new WriteFileJsonNoName
31 {
32 maps = InputActionMap.WriteFileJson.FromMaps(asset.m_ActionMaps).maps,
33 controlSchemes = InputControlScheme.SchemeJson.ToJson(asset.m_ControlSchemes),
34 }, prettyPrint: true);
35 }
36 }
37}
38#endif