Ignition / Config

Namespace Playniax.Ignition

Class or component can be found in Assets/Playniax/Framework/Ignition/Framework/Scripts/Config.cs

Class Config

Description

The Config class can load data from and read data from a config file or store it temporarily to memory.

Config files usually contain data to configure parameters and initial settings for your app.

Public MethodsDescription
Config(string source, string splitter = "\n")Creates Config object from string.
void Clear()Removes all settings.
int Find(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 scene can be found in Assets/Playniax/Framework/Ignition/Examples/01 - Framework/Config.unity

Example script can be found in Assets/Playniax/Framework/Ignition/Examples/01 - Framework/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); } }