本文整理汇总了C#中ConfigNode.ClearValues方法的典型用法代码示例。如果您正苦于以下问题:C# ConfigNode.ClearValues方法的具体用法?C# ConfigNode.ClearValues怎么用?C# ConfigNode.ClearValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConfigNode
的用法示例。
在下文中一共展示了ConfigNode.ClearValues方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RealChuteSettings
/// <summary>
/// Loads the RealChute_Settings config to memory
/// </summary>
public RealChuteSettings()
{
ConfigNode node = new ConfigNode(), settings = new ConfigNode("REALCHUTE_SETTINGS");
Debug.Log("[RealChute]: Loading settings file.");
if (!System.IO.File.Exists(RCUtils.settingsURL))
{
Debug.LogWarning("[RealChute]: RealChute_Settings.cfg is missing component. Creating new version.");
settings.AddValue("autoArm", autoArm);
settings.AddValue("jokeActivated", jokeActivated);
node.AddNode(settings);
node.Save(RCUtils.settingsURL);
}
else
{
node = ConfigNode.Load(RCUtils.settingsURL);
node.TryGetNode("REALCHUTE_SETTINGS", ref settings);
bool missing = false;
if (!settings.TryGetValue("autoArm", ref _autoArm)) { missing = true; }
if (!settings.TryGetValue("jokeActivated", ref _jokeActivated)) { missing = true; }
if (missing)
{
Debug.LogWarning("[RealChute]: RealChute_Settings.cfg is missing component. Fixing settings file.");
settings.ClearValues();
settings.AddValue("autoArm", autoArm);
settings.AddValue("jokeActivated", jokeActivated);
node.ClearData();
node.AddNode(settings);
node.Save(RCUtils.settingsURL);
}
}
}
示例2: RealChuteSettings
/// <summary>
/// Loads the RealChute_Settings config to memory
/// </summary>
public RealChuteSettings()
{
ConfigNode node = new ConfigNode(), settings = new ConfigNode("REALCHUTE_SETTINGS");
Debug.Log("[RealChute]: Loading settings file.");
if (!File.Exists(RCUtils.settingsURL))
{
Debug.LogWarning("[RealChute]: RealChute_Settings.cfg is missing. Creating new.");
settings.AddValue("autoArm", autoArm);
settings.AddValue("jokeActivated", jokeActivated);
settings.AddValue("hideIcon", hideIcon);
node.AddNode(settings);
node.Save(RCUtils.settingsURL);
}
else
{
node = ConfigNode.Load(RCUtils.settingsURL);
if (!node.TryGetNode("REALCHUTE_SETTINGS", ref settings)) { goto missing; }
if (!settings.TryGetValue("autoArm", ref _autoArm)) { goto missing; }
if (!settings.TryGetValue("jokeActivated", ref _jokeActivated)) { goto missing; }
if (settings.TryGetValue("hideIcon", ref _hideIcon)) { goto missing; }
return;
missing:
{
Debug.LogWarning("[RealChute]: RealChute_Settings.cfg is missing component. Fixing settings file.");
settings.ClearValues();
settings.AddValue("autoArm", autoArm);
settings.AddValue("jokeActivated", jokeActivated);
settings.AddValue("hideIcon", hideIcon);
node.ClearData();
node.AddNode(settings);
node.Save(RCUtils.settingsURL);
}
}
}