GetFloat.cs 871 B

12345678910111213141516171819202122232425262728293031
  1. using UnityEngine;
  2. namespace BehaviorDesigner.Runtime.Tasks.Unity.UnityPlayerPrefs
  3. {
  4. [TaskCategory("Unity/PlayerPrefs")]
  5. [TaskDescription("Stores the value with the specified key from the PlayerPrefs.")]
  6. public class GetFloat : Action
  7. {
  8. [Tooltip("The key to store")]
  9. public SharedString key;
  10. [Tooltip("The default value")]
  11. public SharedFloat defaultValue;
  12. [Tooltip("The value retrieved from the PlayerPrefs")]
  13. [RequiredField]
  14. public SharedFloat storeResult;
  15. public override TaskStatus OnUpdate()
  16. {
  17. storeResult.Value = PlayerPrefs.GetFloat(key.Value, defaultValue.Value);
  18. return TaskStatus.Success;
  19. }
  20. public override void OnReset()
  21. {
  22. key = "";
  23. defaultValue = 0;
  24. storeResult = 0;
  25. }
  26. }
  27. }