Class OnixSettingFloat
- Namespace
- OnixRuntime.Api.OnixClient.Settings
- Assembly
- OnixRuntime.dll
Represents a float setting in Onix, allowing configuration of value, default, min, and max.
public sealed class OnixSettingFloat : OnixSetting, IDisposable
- Inheritance
-
OnixSettingFloat
- Implements
- Inherited Members
Constructors
OnixSettingFloat(OnixModule?, string, float, float, float, string, SettingChangedDelegate?)
Initializes a new instance of the OnixSettingFloat class with the specified module, name, default value, min, max, description, and change callback.
public OnixSettingFloat(OnixModule? mod, string name, float defaultValue, float min, float max, string description = "", OnixSetting.SettingChangedDelegate? changeCallback = null)
Parameters
mod
OnixModuleThe Onix module.
name
stringThe name of the setting.
defaultValue
floatThe default float value.
min
floatThe minimum allowed value.
max
floatThe maximum allowed value.
description
stringThe description of the setting.
changeCallback
OnixSetting.SettingChangedDelegateThe callback to invoke when the setting changes.
OnixSettingFloat(OnixModule?, string, string, float, float, float, string, SettingChangedDelegate?)
Initializes a new instance of the OnixSettingFloat class with the specified module, name, default value, min, max, description, and change callback.
public OnixSettingFloat(OnixModule? mod, string name, string saveName, float defaultValue, float min, float max, string description = "", OnixSetting.SettingChangedDelegate? changeCallback = null)
Parameters
mod
OnixModuleThe Onix module.
name
stringThe name of the setting.
saveName
stringThe save name of the setting, this allows the name to change without losing user settings.
defaultValue
floatThe default float value.
min
floatThe minimum allowed value.
max
floatThe maximum allowed value.
description
stringThe description of the setting.
changeCallback
OnixSetting.SettingChangedDelegateThe callback to invoke when the setting changes.
Properties
Default
Gets or sets the default value of the setting.
public float Default { get; set; }
Property Value
Max
Gets or sets the maximum allowed value for the setting.
public float Max { get; set; }
Property Value
Min
Gets or sets the minimum allowed value for the setting.
public float Min { get; set; }
Property Value
Value
Gets or sets the current value of the setting.
public float Value { get; set; }
Property Value
ValueInit
Gets or sets the current value of the setting. This variant will call the on setting changed with the isInit flag set to true.
public float ValueInit { get; set; }
Property Value
Methods
Load(JsonNode)
Loads the setting from json. If the value was null this will not get called so what you're getting is whatever the last value you returned in Save() was. Read it lazily like there is no tomorrow, every setting is in its own try-catch. If you change what you save make sure to have migration code in place.
public override void Load(JsonNode root)
Parameters
root
JsonNodeThe json you last saved.
Save()
Saves the setting to json for persistent storage.
public override JsonNode? Save()
Returns
- JsonNode
The json or null if there is nothing to save.
ToString()
Returns a string that represents the current object.
public override string ToString()
Returns
- string
A string that represents the current object.