您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 

47 行
1.2 KiB

using GameplayIngredients;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[ManagerDefaultPrefab("SettingManager")]
public class SettingManager : Manager
{
public Setting[] defaultSettings;
public string OnSettingChangedMessage = "SETTINGS_CHANGED";
[System.Serializable]
public struct Setting
{
public string name;
public int defaultValue;
}
GameSaveManager m_GameSaveManger;
private void Start()
{
m_GameSaveManger = Get<GameSaveManager>();
foreach (var setting in defaultSettings)
{
SetValue(setting.name, setting.defaultValue, false);
}
Messager.Send(OnSettingChangedMessage);
}
public void SetValue(string name, int value, bool sendMessage = true)
{
m_GameSaveManger.SetInt(name, GameSaveManager.Location.System, value);
if (sendMessage)
Messager.Send(OnSettingChangedMessage);
}
public int GetValue(string name)
{
if (m_GameSaveManger == null)
m_GameSaveManger = Get<GameSaveManager>();
return m_GameSaveManger.GetInt(name, GameSaveManager.Location.System);
}
}