FairyGUI.Utils.HtmlImage.Create C# (CSharp) Method

Create() public method

public Create ( RichTextField owner, HtmlElement element ) : void
owner RichTextField
element HtmlElement
return void
        public void Create(RichTextField owner, HtmlElement element)
        {
            _owner = owner;
            _element = element;

            int width = element.GetInt("width", 0);
            int height = element.GetInt("height", 0);

            NTexture texture = owner.htmlPageContext.GetImageTexture(this);
            if (texture != null)
            {
                if (width == 0)
                    width = texture.width;
                if (height == 0)
                    height = texture.height;

                loader.SetSize(width, height);
                loader.texture = texture;
                _externalTexture = true;

            }
            else
            {
                string src = element.GetString("src");
                if (src != null && (width == 0 || height == 0))
                {
                    PackageItem pi = UIPackage.GetItemByURL(src);
                    if (pi != null)
                    {
                        width = pi.width;
                        height = pi.height;
                    }
                }

                if (width == 0)
                    width = 5;
                if (height == 0)
                    height = 10;

                loader.SetSize(width, height);
                loader.url = src;
                _externalTexture = false;
            }
        }

Usage Example

Ejemplo n.º 1
0
 static public int Create(IntPtr l)
 {
     try {
         FairyGUI.Utils.HtmlImage self = (FairyGUI.Utils.HtmlImage)checkSelf(l);
         FairyGUI.RichTextField   a1;
         checkType(l, 2, out a1);
         FairyGUI.Utils.HtmlElement a2;
         checkType(l, 3, out a2);
         self.Create(a1, a2);
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }