SceneSettings.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using System;
  2. using UnityEngine;
  3. namespace Leap.Unity
  4. {
  5. public class SceneSettings : MonoBehaviour
  6. {
  7. private void Reset()
  8. {
  9. this._shadowDistance.Value = QualitySettings.shadowDistance;
  10. this._gravity.Value = Physics.gravity;
  11. this._sleepThreshold.Value = Physics.sleepThreshold;
  12. }
  13. private void Awake()
  14. {
  15. if (this._shadowDistance.Override)
  16. {
  17. QualitySettings.shadowDistance = this._shadowDistance.Value;
  18. }
  19. if (this._gravity.Override)
  20. {
  21. Physics.gravity = this._gravity.Value;
  22. }
  23. if (this._sleepThreshold.Override)
  24. {
  25. Physics.sleepThreshold = this._sleepThreshold.Value;
  26. }
  27. }
  28. [SerializeField]
  29. private SceneSettings.ToggleFloat _shadowDistance = new SceneSettings.ToggleFloat();
  30. [SerializeField]
  31. private SceneSettings.ToggleVector3 _gravity = new SceneSettings.ToggleVector3();
  32. [SerializeField]
  33. private SceneSettings.ToggleFloat _sleepThreshold = new SceneSettings.ToggleFloat();
  34. public class ToggleValue<T>
  35. {
  36. public bool Override;
  37. public T Value;
  38. }
  39. [Serializable]
  40. public class ToggleFloat : SceneSettings.ToggleValue<float>
  41. {
  42. }
  43. [Serializable]
  44. public class ToggleVector3 : SceneSettings.ToggleValue<Vector3>
  45. {
  46. }
  47. }
  48. }