InputEditorUserSettings.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. using System;
  2. using System.IO;
  3. using System.Reflection;
  4. namespace Unity.RenderStreaming.InputSystem
  5. {
  6. #if UNITY_EDITOR && !INPUTSYSTEM_1_1_OR_NEWER
  7. // todo(kazuki)::Avoid to use reflection
  8. static class InputEditorUserSettings
  9. {
  10. private static Type type;
  11. private static PropertyInfo propertyLockInputToGameView;
  12. private static MethodInfo methodLoad;
  13. private static FieldInfo fieldFilePath;
  14. static InputEditorUserSettings()
  15. {
  16. type = Type.GetType("UnityEngine.InputSystem.Editor.InputEditorUserSettings, Unity.InputSystem");
  17. propertyLockInputToGameView = type.GetProperty("lockInputToGameView");
  18. methodLoad = type.GetMethod("Load",
  19. BindingFlags.NonPublic | BindingFlags.Static);
  20. fieldFilePath = type.GetField("kSavePath",
  21. BindingFlags.NonPublic | BindingFlags.Static);
  22. }
  23. public static bool lockInputToGameView
  24. {
  25. get { return (bool)propertyLockInputToGameView.GetValue(null); }
  26. set { propertyLockInputToGameView.SetValue(null, value); }
  27. }
  28. public static void Load()
  29. {
  30. methodLoad.Invoke(null, null);
  31. }
  32. public static void Delete()
  33. {
  34. string filePath = (string)fieldFilePath.GetValue(null);
  35. if(File.Exists(filePath))
  36. File.Delete(filePath);
  37. }
  38. }
  39. #endif
  40. }