#if GRAPH_DESIGNER /// --------------------------------------------- /// Behavior Designer /// Copyright (c) Opsive. All Rights Reserved. /// https://www.opsive.com /// --------------------------------------------- namespace Opsive.BehaviorDesigner.Runtime.Tasks.Actions.SaveLoad { using Opsive.GraphDesigner.Runtime.Variables; using UnityEngine; /// /// Sets a PlayerPrefs string value. /// [Opsive.Shared.Utility.Category("Save/Load")] [Opsive.Shared.Utility.Description("Sets a PlayerPrefs string value.")] public class SetPlayerPrefsString : Action { [Tooltip("The PlayerPrefs key.")] [SerializeField] protected SharedVariable m_Key; [Tooltip("The string value to set.")] [SerializeField] protected SharedVariable m_Value; [Tooltip("Should PlayerPrefs.Save() be called after setting the value?")] [SerializeField] protected bool m_Save = true; /// /// Executes the action logic. /// /// The status of the action. public override TaskStatus OnUpdate() { if (string.IsNullOrEmpty(m_Key.Value)) { return TaskStatus.Success; } PlayerPrefs.SetString(m_Key.Value, m_Value.Value); if (m_Save) { PlayerPrefs.Save(); } return TaskStatus.Success; } } } #endif