Ignition / Config
Namespace
Playniax.IgnitionScript can be found in
Assets/Playniax/Framework/Ignition/Framework/Core/Scripts/Config.cs
Class Config
DescriptionThe Config class provides a convenient method for managing data parameters. It can load and read data from a configuration file or store it temporarily in memory. Typically, config files contain data for configuring parameters and initializing settings for your application.
Public Methods | Description |
---|
Config(string source, string splitter = "\n") | Creates Config object from string. |
void Clear() | Removes all settings. |
int GetPosition(string key) | Returns key position (returns -1 if key is not found). |
bool GetBool(string key, bool defaultValue = false) | Returns defaultValue if key is not found. |
Color GetColor(string key, Color color = default) | Returns defaultValue if key is not found. |
float GetFloat(string key, float defaultValue = 0) | Returns defaultValue if key is not found. |
int GetInt(string key, int defaultValue = 0) | Returns defaultValue if key is not found. |
string GetString(string key, string defaultValue = "") | Returns defaultValue if key is not found. |
Vector2 GetVector2(string key, Vector2 vector = default) | Returns defaultValue if key is not found. |
Vector3 GetVector3(string key, Vector3 vector = default) | Returns defaultValue if key is not found. |
void SetBool(string key, bool value) | Sets value. |
void SetInt(string key, int value) | Sets value. |
void SetString(string key, string value) | Sets value. |
Example
Example can be found in
Assets/Playniax/Framework/Ignition/Scenes/01 - Framework/Config/Scenes/Config.unityExample script can be found in
Assets/Playniax/Framework/Ignition/Scenes/01 - Framework/Config/Scripts (MonoBehaviour)/Config_Example.cs
using UnityEngine;
using Playniax.Ignition;
public class Config_Example : MonoBehaviour
{
void Start()
{
// Create Config object.
var data = new Config();
// Fill with data.
data.SetString("name", "Tony");
data.SetInt("score", 100);
// Get data.
var output = "Player " + data.GetString("name") + " has scored " + data.GetInt("score") + " points.";
Debug.Log(output);
}
}