Advertisement
Guest User

Untitled

a guest
Jun 1st, 2023
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. namespace Kamgam.SettingsGenerator
  6. {
  7. public class SettingTest : MonoBehaviour, IQualityChangeReceiver
  8. {
  9. public SettingsProvider provider;
  10. public string Id;
  11. public float floatVar;
  12.  
  13. private void Start()
  14. {
  15. var settings = provider.Settings;
  16. addFloatVariableHook(settings);
  17. }
  18.  
  19. protected void addFloatVariableHook(Settings settings)
  20. {
  21. var connection = new GetSetConnection<float>(
  22. getter: getFloatValue, // executed if connection.Get() is called.
  23. setter: setFloatValue // executed if connection.Set(value) is called.
  24. );
  25.  
  26. var floatSettings = settings.GetOrCreateFloat(
  27. id: Id,
  28. connection: connection
  29. );
  30. }
  31.  
  32. protected float getFloatValue()
  33. {
  34. return floatVar;
  35. }
  36.  
  37. // This simply sets the local field and logs the new value.
  38. protected void setFloatValue(float value)
  39. {
  40. floatVar = value;
  41. }
  42.  
  43. public void OnQualityChanged(int qualityLevel)
  44. {
  45. Debug.Log("OnQualityChanged on SettingTest.cs");
  46. }
  47. }
  48. }
  49.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement