4 namespace HKI.Core.Variables
13 [CreateAssetMenu(fileName =
"Vector2", menuName =
"HKI/Variables/Vector2", order = 5)]
17 public override void Save(XmlNode parentNode)
19 XmlNode node = parentNode.OwnerDocument.CreateElement(name.Replace(
" ",
""));
20 parentNode.AppendChild(node);
22 XmlAttribute valueXAttribute = parentNode.OwnerDocument.CreateAttribute(
"ValueX");
23 valueXAttribute.Value = Value.x.ToString();
24 node.Attributes.Append(valueXAttribute);
26 XmlAttribute valueYAttribute = parentNode.OwnerDocument.CreateAttribute(
"ValueY");
27 valueYAttribute.Value = Value.y.ToString();
28 node.Attributes.Append(valueYAttribute);
31 public override void Load(XmlNode node)
33 if(node.Attributes == null)
35 Debug.LogError(
"(Vector2) >" + name +
"< Loading failed because this XmlNode has not attributes!");
39 XmlAttribute valueXAttribute = node.Attributes[
"ValueX"];
40 if(valueXAttribute == null)
42 Debug.LogError(
"(Vector2) >" + name +
"< Loading failed because this XmlNode has not an attribute with the name >ValueX<!");
46 XmlAttribute valueYAttribute = node.Attributes[
"ValueY"];
47 if(valueYAttribute == null)
49 Debug.LogError(
"(Vector2) >" + name +
"< Loading failed because this XmlNode has not an attribute with the name >ValueY<!");
54 if(!
float.TryParse(valueXAttribute.Value, out parsedXValue))
55 Debug.LogError(
"(Vector2) >" + name +
"< Loading failed because parsing of >" + valueXAttribute.Value +
"< failed!");
58 if (!
float.TryParse(valueYAttribute.Value, out parsedYValue))
59 Debug.LogError(
"(Vector2) >" + name +
"< Loading failed because parsing of >" + valueYAttribute.Value +
"< failed!");
61 SetValue =
new UnityEngine.Vector2(parsedXValue, parsedYValue);
override void Load(XmlNode node)
override void Save(XmlNode parentNode)
Implementation of a Vector2 value as a HKIVar via HKIVarGeneric.
This class adds a generic implementation to HKIVar. This reduces the repetitive implementation of thi...