FairyGUI.Utils.HtmlPageContext.CreateObject C# (CSharp) Method

CreateObject() public method

public CreateObject ( RichTextField owner, HtmlElement element ) : IHtmlObject
owner RichTextField
element HtmlElement
return IHtmlObject
        public virtual IHtmlObject CreateObject(RichTextField owner, HtmlElement element)
        {
            IHtmlObject ret = null;
            if (element.type == HtmlElementType.Image)
            {
                if (_imagePool.Count > 0 && Application.isPlaying)
                    ret = _imagePool.Pop();
                else
                    ret = new HtmlImage();
            }
            else if (element.type == HtmlElementType.Link)
            {
                if (_linkPool.Count > 0 && Application.isPlaying)
                    ret = _linkPool.Pop();
                else
                    ret = new HtmlLink();
            }
            else if (element.type == HtmlElementType.Input)
            {
                string type = element.GetString("type");
                if (type != null)
                    type = type.ToLower();
                if (type == "button" || type == "submit")
                {
                    if (_buttonPool.Count > 0 && Application.isPlaying)
                        ret = _buttonPool.Pop();
                    else
                        ret = new HtmlButton();
                }
                else
                {
                    if (_inputPool.Count > 0 && Application.isPlaying)
                        ret = _inputPool.Pop();
                    else
                        ret = new HtmlInput();
                }
            }
            else if (element.type == HtmlElementType.Select)
            {
                if (_selectPool.Count > 0 && Application.isPlaying)
                    ret = _selectPool.Pop();
                else
                    ret = new HtmlSelect();
            }

            if (ret != null)
            {
                ret.Create(owner, element);
                if (ret.displayObject != null)
                    ret.displayObject.home = owner.cachedTransform;
            }

            return ret;
        }

Usage Example

Example #1
0
 static public int CreateObject(IntPtr l)
 {
     try {
         FairyGUI.Utils.HtmlPageContext self = (FairyGUI.Utils.HtmlPageContext)checkSelf(l);
         FairyGUI.RichTextField         a1;
         checkType(l, 2, out a1);
         FairyGUI.Utils.HtmlElement a2;
         checkType(l, 3, out a2);
         var ret = self.CreateObject(a1, a2);
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }