HKI Core
FrameRateAndVSyncMode.cs
Go to the documentation of this file.
1 using UnityEngine;
2 using System.Xml;
3 using HKI.Core.Variables;
4 
5 namespace HKI.Core.Settings
6 {
10  [System.Serializable]
11  [HKIVarSettings]
12  public class FrameRateAndVSyncMode : HKIVarGeneric<FrameRateAndVSyncModes>
13  {
14  // Interface functions
15  public override void Save(XmlNode parentNode)
16  {
17  XmlNode node = parentNode.OwnerDocument.CreateElement(name.Replace(" ", ""));
18  parentNode.AppendChild(node);
19 
20  XmlAttribute valueAttribute = parentNode.OwnerDocument.CreateAttribute("Value");
21  valueAttribute.Value = ((int)Value).ToString();
22  node.Attributes.Append(valueAttribute);
23  }
24 
25  public override void Load(XmlNode node)
26  {
27  if (node.Attributes == null)
28  {
29  Debug.LogError("(FrameRateAndVSyncMode) >" + name + "< Loading failed because this XmlNode has not attributes!");
30  return;
31  }
32 
33  XmlAttribute valueAttribute = node.Attributes["Value"];
34  if (valueAttribute == null)
35  {
36  Debug.LogError("(FrameRateAndVSyncMode) >" + name + "< Loading failed because this XmlNode has not an attribute with the name >Value<!");
37  return;
38  }
39 
40  int parsedValue;
41  if (int.TryParse(valueAttribute.Value, out parsedValue))
42  SetValue = (FrameRateAndVSyncModes)parsedValue;
43  else
44  Debug.LogError("(FrameRateAndVSyncMode) >" + name + "< Loading failed because parsing of >" + valueAttribute.Value + "< failed!");
45  }
46  }
47 }
Special Variable enables the use of the FrameRateAndVSyncModes data type as a variable of the setting...
override void Save(XmlNode parentNode)
FrameRateAndVSyncModes
All possible settings for frame rate and VSync.
This class adds a generic implementation to HKIVar. This reduces the repetitive implementation of thi...