Skip to content

Commit 8d4943b

Browse files
committed
Create HMSModelingKitSettings.cs
1 parent 6f9d6f9 commit 8d4943b

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using System;
2+
3+
namespace HmsPlugin
4+
{
5+
public class HMSModelingKitSettings : HMSEditorSingleton<HMSModelingKitSettings>
6+
{
7+
private const string SettingsFilename = "HMSModelingKitSettings";
8+
public const string ModelingKeyAPI = "ModelingKeyAPI";
9+
10+
private SettingsScriptableObject loadedSettings;
11+
12+
private HMSSettings _settings;
13+
public HMSSettings Settings => _settings;
14+
15+
public HMSModelingKitSettings()
16+
{
17+
loadedSettings = ScriptableHelper.Load<SettingsScriptableObject>(SettingsFilename, "Assets/Huawei/Settings/Resources");
18+
19+
if (loadedSettings == null)
20+
{
21+
throw new NullReferenceException("Failed to load the " + SettingsFilename + ". Please restart Unity Editor");
22+
}
23+
_settings = loadedSettings.settings;
24+
25+
_settings.OnDictionaryChanged += _settings_OnDictionaryChanged;
26+
}
27+
28+
private void _settings_OnDictionaryChanged()
29+
{
30+
loadedSettings.Save();
31+
}
32+
33+
public void Reset()
34+
{
35+
_settings.Dispose();
36+
_instance = null;
37+
}
38+
}
39+
}

0 commit comments

Comments
 (0)