Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- namespace Kamgam.SettingsGenerator
- {
- public class SettingTest : MonoBehaviour, IQualityChangeReceiver
- {
- public SettingsProvider provider;
- public string Id;
- public float floatVar;
- private void Start()
- {
- var settings = provider.Settings;
- addFloatVariableHook(settings);
- }
- protected void addFloatVariableHook(Settings settings)
- {
- var connection = new GetSetConnection<float>(
- getter: getFloatValue, // executed if connection.Get() is called.
- setter: setFloatValue // executed if connection.Set(value) is called.
- );
- var floatSettings = settings.GetOrCreateFloat(
- id: Id,
- connection: connection
- );
- }
- protected float getFloatValue()
- {
- return floatVar;
- }
- // This simply sets the local field and logs the new value.
- protected void setFloatValue(float value)
- {
- floatVar = value;
- }
- public void OnQualityChanged(int qualityLevel)
- {
- Debug.Log("OnQualityChanged on SettingTest.cs");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement