HKI Core
String.cs
Go to the documentation of this file.
1 using UnityEngine;
2 using System.Xml;
3 using HKI.Core.Settings;
4 
5 namespace HKI.Core.Variables
6 {
12  [System.Serializable]
13  [HKIVarBasic]
14  [HKIVarSettings]
15  [CreateAssetMenu(fileName = "String", menuName = "HKI/Variables/String", order = 4)]
16  public class String : HKIVarGeneric<string>
17  {
18  // Interface functions
19  public override void Save(XmlNode parentNode)
20  {
21  XmlNode node = parentNode.OwnerDocument.CreateElement(name.Replace(" ", ""));
22  parentNode.AppendChild(node);
23 
24  XmlAttribute valueAttribute = parentNode.OwnerDocument.CreateAttribute("Value");
25  valueAttribute.Value = Value;
26  node.Attributes.Append(valueAttribute);
27  }
28 
29  public override void Load(XmlNode node)
30  {
31  if (node.Attributes == null)
32  {
33  Debug.LogError("(String) >" + name + "< Loading failed because this XmlNode has not attributes!");
34  return;
35  }
36 
37  XmlAttribute valueAttribute = node.Attributes["Value"];
38  if (valueAttribute == null)
39  {
40  Debug.LogError("(String) >" + name + "< Loading failed because this XmlNode has not an attribute with the name >Value<!");
41  return;
42  }
43 
44  SetValue = valueAttribute.Value;
45  }
46  }
47 }
override void Save(XmlNode parentNode)
Definition: String.cs:19
override void Load(XmlNode node)
Definition: String.cs:29
Implementation of a string value as a HKIVar via HKIVarGeneric.
Definition: String.cs:16
This class adds a generic implementation to HKIVar. This reduces the repetitive implementation of thi...