Skip to content

Commit

Permalink
Create HMSModelingKitSettings.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
alihan98ersoy committed Dec 5, 2023
1 parent 6f9d6f9 commit 8d4943b
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions Assets/Huawei/Scripts/Settings/HMSModelingKitSettings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System;

namespace HmsPlugin
{
public class HMSModelingKitSettings : HMSEditorSingleton<HMSModelingKitSettings>
{
private const string SettingsFilename = "HMSModelingKitSettings";
public const string ModelingKeyAPI = "ModelingKeyAPI";

private SettingsScriptableObject loadedSettings;

private HMSSettings _settings;
public HMSSettings Settings => _settings;

public HMSModelingKitSettings()
{
loadedSettings = ScriptableHelper.Load<SettingsScriptableObject>(SettingsFilename, "Assets/Huawei/Settings/Resources");

if (loadedSettings == null)
{
throw new NullReferenceException("Failed to load the " + SettingsFilename + ". Please restart Unity Editor");
}
_settings = loadedSettings.settings;

_settings.OnDictionaryChanged += _settings_OnDictionaryChanged;
}

private void _settings_OnDictionaryChanged()
{
loadedSettings.Save();
}

public void Reset()
{
_settings.Dispose();
_instance = null;
}
}
}

0 comments on commit 8d4943b

Please sign in to comment.