lunar-unity-console
lunar-unity-console copied to clipboard
Setup Variables at runtime, and document it.
To create Variables at runtime I did this. It should be mentioned in the docs.
public class SettingsConsoleVariables : MonoBehaviour
{
public Settings settings;
public static CVar factor;
private void Start() // Note: setup on Start not Awake
{
LunarConsole console = GetComponent<LunarConsole>();
factor = new CVar("factor", settings.factor);
factor.AddDelegate(OnFactorUpdate);
console.registry.Register(factor);
// would be nice to say: factor = LunarConsole.Register("factor", settings.factor, OnFactorUpdate);
}
void OnFactorUpdate(CVar cvar)
{
settings.factor = cvar;
}
}
@geekrelief, unfortunately, it didn't end up as a quick fix. I have to think about better variables handling. Stay tuned...