void Start() { XMLUI.Run(); TestView = XMLUI.CreateView <TestView>(); testButton.onClick.AddListener(OnTestButtonClicked); }
internal void InitializeButton(XmlNode _xmlNode, XmlNode _styleXml) { string methodName = _xmlNode.GetStringValue("OnClick"); if (string.IsNullOrEmpty(methodName) == false) { MethodInfo = ReflectionUtility.FindMethod(this, methodName); } UpSprite = Image.sprite; var downImgName = _xmlNode.GetStringValue("Down", _styleXml); if (string.IsNullOrEmpty(downImgName) == false) { DownSprite = Resources.Load <Sprite>(downImgName); } else { DownSprite = Image.sprite; } string param = _xmlNode.GetStringValue("Text", _styleXml); if (string.IsNullOrEmpty(param) == false) { var styleId = "Default"; var style = _xmlNode.GetStringValue("Style"); if (string.IsNullOrEmpty(style) == false) { styleId = style; } var styleXml = XMLUI.GetStyleXml("Text", styleId + "_ButtonLabel"); styleXml.Attributes["Text"].Value = param; var view = XMLUI.CreateView <Text>(ClassRoot, styleXml); view.Parent = this; Labels.Add(view); } }
public static void ReadLayoutXmlDocument(XmlDocument _layoutXml, UIView _rootUIView, bool _root, UIView _classRoot, XmlNode _styleXml) { XmlElement layoutXmlRoot = _layoutXml.DocumentElement; List <XmlNode> layoutXmlNodes = layoutXmlRoot.GetAllChildrenXMLNodesRecursively(); Dictionary <XmlNode, UIView> viewByNodes = new Dictionary <XmlNode, UIView>(); viewByNodes.Add(layoutXmlRoot, _rootUIView); _rootUIView.ClassRoot = _classRoot ?? _rootUIView; if (_root) { ApplyLayoutXmlNode(layoutXmlRoot, _rootUIView, _styleXml); } foreach (XmlNode childLayoutXmlNode in layoutXmlNodes) { if (childLayoutXmlNode.NodeType == XmlNodeType.Comment) { continue; } XmlNode parentNode = childLayoutXmlNode.ParentNode; UIView childUIView = XMLUI.CreateView(childLayoutXmlNode.Name); childUIView.ClassRoot = _classRoot ?? _rootUIView; if (parentNode == layoutXmlRoot) { childUIView.Parent = _rootUIView; } else { childUIView.Parent = viewByNodes[parentNode]; } viewByNodes.Add(childLayoutXmlNode, childUIView); ApplyLayoutXmlNode(childLayoutXmlNode, childUIView, _styleXml); } }