Beispiel #1
0
    void Update()
    {
        if (changed && compiler != null)
        {
            // we have new html text, so compile it
            compiler.Compile(html, maxLineWidth > 0 ? maxLineWidth : Screen.width);

            // destroy old widgets.
            foreach (Transform childTr in transform)
            {
                Destroy(childTr.gameObject);
            }

            // generate the widgets.
            currentDepth = depth;
            compiler.Draw(Time.deltaTime, transform);

            // release changed flag
            changed = false;

            if (autoScroll != AutoScrollType.MANUAL)
            {
                StartCoroutine(updateAutoScroll());
            }
        }
    }
Beispiel #2
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            HtmlDevice.Content       = Content;
            HtmlDevice.Context       = spriteBatch;
            HtEngine.DefaultFontFace = "Arial";
            HtEngine.DefaultFontSize = 14;
            HtEngine.RegisterDevice(new HtmlDevice());

            compiler = HtEngine.GetCompiler();
            compiler.Compile(demo, GraphicsDevice.Viewport.Width);
        }
Beispiel #3
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            HtmlDevice.Content = Content;
            HtmlDevice.Context = spriteBatch;
            HtEngine.DefaultFontFace = "Arial";
            HtEngine.DefaultFontSize = 14;
            HtEngine.RegisterDevice(new HtmlDevice());

            compiler = HtEngine.GetCompiler();
            compiler.Compile(demo, GraphicsDevice.Viewport.Width);
        }
        private void Update()
        {
            _changed = false;

            int w = (int)this.width;

            if (w > 0)
            {
                _compiler.Compile(_text, w);
                _textHeight = _compiler.CompiledHeight;
            }
            else
            {
                _textHeight = 0;
            }
        }
Beispiel #5
0
 public void Parse(IEnumerator <HtmlChunk> source, int width, string id = null, HtFont font = null, HtColor color = default(HtColor), TextAlign align = TextAlign.Left, VertAlign valign = VertAlign.Bottom)
 {
     compiled.Compile(source, width, id, font, color, align, valign);
     offsetApplied = false;
 }
Beispiel #6
0
    /*
     * internal void onLinkClicked(GameObject senderGo)
     * {
     * var nguiLinkText = senderGo.GetComponent<NGUILinkText>();
     * if (nguiLinkText != null)
     * {
     *    //Debug.Log("xxx " + nguiLinkText.linkText);
     * }
     * }*/

    void IUpdate()
    {
        if (changed && compiler != null)
        {
            // link hover color.
            HtEngine.LinkHoverColor = HtColor.RGBA(
                (byte)(LinkHoverColor.r * 255),
                (byte)(LinkHoverColor.g * 255),
                (byte)(LinkHoverColor.b * 255),
                (byte)(LinkHoverColor.a * 255)
                );
            // link pressed factor.
            HtEngine.LinkPressedFactor = LinkPressedFactor;

            //设置字体列表
            NGUIFont.FontList = fonts;

            NGUIImage.imgs = imgs;

            //设置填充图集
            NGUIDevice.Fillatlas = Fillatlas;

            UIWidget cmWidget = gameObject.GetComponent <UIWidget>();

            // we have new html text, so compile it
            compiler.Compile(html, cmWidget != null ? cmWidget.width : Screen.width);

            //根据本控件的对齐方式,进行偏移修正
            {
                switch (cmWidget.pivot)
                {
                case UIWidget.Pivot.Center:
                    compiler.Offset(-cmWidget.width / 2, -cmWidget.height / 2);
                    break;

                case UIWidget.Pivot.Top:
                    compiler.Offset(-cmWidget.width / 2, 0);
                    break;

                case UIWidget.Pivot.Left:
                    compiler.Offset(0, -cmWidget.height / 2);
                    break;

                case UIWidget.Pivot.TopRight:
                    compiler.Offset(-cmWidget.width, 0);
                    break;

                case UIWidget.Pivot.Right:
                    compiler.Offset(-cmWidget.width, -cmWidget.height / 2);
                    break;

                case UIWidget.Pivot.BottomLeft:
                    compiler.Offset(0, -cmWidget.height);
                    break;

                case UIWidget.Pivot.Bottom:
                    compiler.Offset(-cmWidget.width / 2, -cmWidget.height);
                    break;

                case UIWidget.Pivot.BottomRight:
                    compiler.Offset(-cmWidget.width, -cmWidget.height);
                    break;
                }
            }



            // destroy old widgets.
            foreach (Transform childTr in transform)
            {
                Destroy(childTr.gameObject);
            }

            // generate the widgets.
            compiler.Draw(Time.deltaTime, transform);

            // release changed flag
            changed = false;

            if (autoScroll != AutoScrollType.MANUAL)
            {
                StartCoroutine(updateAutoScroll());
            }
        }
    }
 public void Parse(IEnumerator <HtmlChunk> source, int width, TextAlign align = TextAlign.Left, VertAlign valign = VertAlign.Bottom)
 {
     compiled.Compile(source, width, align, valign);
     offsetApplied = false;
 }