No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CompensateDirectionProcessor.cs 1.1KB

12345678910111213141516171819202122232425262728293031
  1. using System.ComponentModel;
  2. using UnityEngine.InputSystem.LowLevel;
  3. namespace UnityEngine.InputSystem.Processors
  4. {
  5. [DesignTimeVisible(false)]
  6. internal class CompensateDirectionProcessor : InputProcessor<Vector3>
  7. {
  8. public override Vector3 Process(Vector3 value, InputControl control)
  9. {
  10. if (!InputSystem.settings.compensateForScreenOrientation)
  11. return value;
  12. var rotation = Quaternion.identity;
  13. switch (InputRuntime.s_Instance.screenOrientation)
  14. {
  15. case ScreenOrientation.PortraitUpsideDown: rotation = Quaternion.Euler(0, 0, 180); break;
  16. case ScreenOrientation.LandscapeLeft: rotation = Quaternion.Euler(0, 0, 90); break;
  17. case ScreenOrientation.LandscapeRight: rotation = Quaternion.Euler(0, 0, 270); break;
  18. }
  19. return rotation * value;
  20. }
  21. public override string ToString()
  22. {
  23. return "CompensateDirection()";
  24. }
  25. public override CachingPolicy cachingPolicy => CachingPolicy.EvaluateOnEveryRead;
  26. }
  27. }