3 using System.Collections.Generic;
5 namespace HKI.Core.Variables
11 [CreateAssetMenu(fileName =
"Container", menuName =
"HKI/Variables/Container", order = 0)]
15 [SerializeField] List<HKIVar> container =
new List<HKIVar>();
18 public int Count {
get {
return container.Count; } }
21 public override void Save(XmlNode parentNode)
23 XmlNode containerNode = parentNode.OwnerDocument.CreateElement(name.Replace(
" ",
""));
24 parentNode.AppendChild(containerNode);
26 for(
int i = 0; i < container.Count; i++)
27 container[i].Save(containerNode);
30 public override void Load(XmlNode node)
32 XmlNodeList childNodes = node.ChildNodes;
33 for(
int i = 0; i < childNodes.Count; i++)
35 XmlNode childNode = childNodes[i];
36 HKIVar variable = GetHKIVarByNameWithoutSpace(childNode.Name);
38 variable.
Load(childNode);
40 Debug.LogWarning(
"(Container) Loading failed in the container with the name >" + name +
"< faild to find the variables with the name given by the XmlDocument >" + childNode.Name +
"<");
46 return "This container (" + name +
") has " + container.Count +
" object(s).";
51 for(
int i = 0; i < container.Count; i++)
53 if (varName == container[i].name)
57 Debug.LogError(
"Container >" + name +
"< failed to get HKIVar by name (varName = " + varName +
")");
63 for (
int i = 0; i < container.Count; i++)
65 if (varName == container[i].name.Replace(
" ",
""))
69 Debug.LogError(
"Container >" + name +
"< failed to get HKIVar by name (varName = " + varName +
")");
75 if(index < 0 || index >= container.Count)
77 Debug.LogError(
"Container >" + name +
"< failed to get HKIVar by index (index = " + index.ToString() +
")");
81 return container[index];
HKIVar GetHKIVarByIndex(int index)
This abstract class of a ScriptableObject is provides child classes with on value changed callback ca...
override string ToString()
HKIVar GetHKIVarByNameWithoutSpace(string varName)
This container is itself a HKIVar but it purpose is to hold other HKIVars together at one place...
override void Save(XmlNode parentNode)
override void Load(XmlNode node)
abstract void Load(XmlNode node)
HKIVar GetHKIVarByName(string varName)