Пример #1
0
    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);
        }
    }