Sliced/Tiling Controls

This is the place to post add-on scripts you have written that use EZ GUI. Please remember only to post your add-on content and not the original EZ GUI scripts.
Forum rules
Only post your own add-on content and not any of the original EZ GUI scripts.

Sliced/Tiling Controls

Postby Fes » Mon Sep 12, 2011 10:36 pm

UPDATE: Fixed handling of vertex colors. Fixes panel transitions.
UPDATE 2: Added bleed-compensation support.
UPDATE 3: Added null checks in overrides.
UPDATE 4: Fixed clipping bug. Works properly inside scroll lists now.

One of the things I liked most about UnityGUI, despite all its other failings, was how easy it was to set up a 3 or 9 slice control. EZGui didn't have this out-of-box, so the first thing I set about doing after picking it up was implementing this. This kind of control is crucial for our project, and I imagine for others as well, so I thought I'd share what I've got so far. Also, I figured that since I was writing my own anyway, I may as well add a a couple extra features that even UnityGUI controls didn't support, mainly tiling the slices instead of just stretching them.

Before we get to the code, a few high-level remarks. This implementation does not use EZGui's "layers" feature, instead opting to replace the internal spritemesh of the control with a new one constructed by this code. This could prove to be fragile going forward, since it digs deeper than using the layers feature would, and as a result might need adjusting in future versions. However, nothing in EZGui itself needs to be modified or made public to make this work; it relies entirely on protected members and overrides of the base classes, which are technically part of the public interface of a class.

A few features that regular sprites support aren't supported by this. First, these can't be used in "managed" mode because the sprite manager is built on the assumption that sprites are a single quad. Adding support for this would be much more complex, so instead it relies on Unity's own batching, for better or worse. Also, "pixel perfect" mode is disabled, since it doesn't really have meaning for this kind of sprite. 9 slice sprites don't have a "size" since they can grow to any size.

Instead, I added a "Pixel per Texel" mode that sets the world space per texel ratio of the control. This allows the sprite to have crisp pixels, while still being able to grow to any size. Alternatively, the ratios can be set manually to achieve other effects. There's a "tiling offset" setting so you can change the phase of the tiling effect if you're using tiling mode. The sprite should fully support clipping, although this support hasn't been thoroughly tested yet. Finally, the "Has Center" option disables the center slice, which is useful for controls that are meant to only be borders with a transparent center, this way they don't waste fillrate on iOS devices.

Now for the code. First, for the underlying mesh and support code:
Code: Select all
using UnityEngine;
using System.Collections.Generic;

class BorderedTilingSpriteMesh : SpriteMesh {
    IBorderedTilingSprite _btSprite;

    List<float> _hTilePoints = new List<float>();
    List<float> _vTilePoints = new List<float>();
    List<Vector3> _vertices = new List<Vector3>();
    List<Vector2> _uvs = new List<Vector2>();
    Color[] _colors = null;
    List<Vector2> _uv2s = new List<Vector2>();
    List<int> _indices = new List<int>();
    Vector2 _sizePerUV;

    void RebuildMesh () {
        if (m_mesh == null)
            CreateMesh();
        m_mesh.Clear();

        if (m_texture == null)
            return;

        Rect clipRect = new Rect();
        switch (m_sprite.plane) {
        case SpriteRoot.SPRITE_PLANE.XY:
            clipRect = Rect.MinMaxRect(m_sprite.TopLeft.x, m_sprite.BottomRight.y, m_sprite.BottomRight.x, m_sprite.TopLeft.y);
            break;
        case SpriteRoot.SPRITE_PLANE.YZ:
            clipRect = Rect.MinMaxRect(m_sprite.TopLeft.z, m_sprite.BottomRight.y, m_sprite.BottomRight.z, m_sprite.TopLeft.y);
            break;
        case SpriteRoot.SPRITE_PLANE.XZ:
            clipRect = Rect.MinMaxRect(m_sprite.TopLeft.x, m_sprite.BottomRight.z, m_sprite.BottomRight.x, m_sprite.TopLeft.z);
            break;
        }
        if (clipRect.width <= 0 || clipRect.height <= 0) {
            _colors = null;
            return;
        }

        _hTilePoints.Clear();
        _vTilePoints.Clear();
        _vertices.Clear();
        _uvs.Clear();
        _uv2s.Clear();
        _indices.Clear();

        Rect uvRect = _btSprite.UnclippedUVRect;
        Vector2 topLeftBorder = _btSprite.TopLeftBorder;
        Vector2 bottomRightBorder = _btSprite.BottomRightBorder;
        topLeftBorder.x /= m_texture.width;
        topLeftBorder.y /= m_texture.height;
        bottomRightBorder.x /= m_texture.width;
        bottomRightBorder.y /= m_texture.height;

        if (_btSprite.PixelPerTexel)
            _btSprite.SizePerTexel = new Vector2(_btSprite.SizePerPixel, _btSprite.SizePerPixel);
        _sizePerUV = _btSprite.SizePerTexel;
        _sizePerUV.x *= m_texture.width;
        _sizePerUV.y *= m_texture.height;

        Rect rect = Rect.MinMaxRect(
            m_sprite.UnclippedTopLeft.x, m_sprite.UnclippedBottomRight.y,
            m_sprite.UnclippedBottomRight.x, m_sprite.UnclippedTopLeft.y
        );
        Rect centerRect = Rect.MinMaxRect(
            rect.x + _sizePerUV.x * topLeftBorder.x,
            rect.y + _sizePerUV.y * bottomRightBorder.y,
            rect.xMax - _sizePerUV.x * bottomRightBorder.x,
            rect.yMax - _sizePerUV.y * topLeftBorder.y
        );

        Vector2 tileSizeInUV = new Vector2(uvRect.width - topLeftBorder.x - bottomRightBorder.x, uvRect.height - bottomRightBorder.y - topLeftBorder.y);
        Vector2 tileSize = new Vector2(_sizePerUV.x * tileSizeInUV.x, _sizePerUV.y * tileSizeInUV.y);

        if (!_btSprite.StretchHorizontally) {
            float x = centerRect.x - _sizePerUV.x * (_btSprite.TilingOffset.x / m_texture.width) % tileSize.x;
            _hTilePoints.Add(x);
            do {
                x += tileSize.x;
                _hTilePoints.Add(x);
            } while (x < centerRect.xMax);
        } else {
            _hTilePoints.Add(centerRect.x);
            _hTilePoints.Add(centerRect.xMax);
        }
        if (!_btSprite.StretchVertically) {
            float y = centerRect.y - _sizePerUV.y * (_btSprite.TilingOffset.y / m_texture.height) % tileSize.y;
            _vTilePoints.Add(y);
            do {
                y += tileSize.y;
                _vTilePoints.Add(y);
            } while (y < centerRect.yMax);
        } else {
            _vTilePoints.Add(centerRect.y);
            _vTilePoints.Add(centerRect.yMax);
        }

        ClipAndAddQuad(
            Rect.MinMaxRect(rect.x, rect.y, centerRect.x, centerRect.y),
            new Rect(uvRect.x, uvRect.y, topLeftBorder.x,  bottomRightBorder.y),
            clipRect
        );
        ClipAndAddQuad(
            Rect.MinMaxRect(rect.x, centerRect.yMax, centerRect.x, rect.yMax),
            new Rect(uvRect.x, uvRect.yMax - topLeftBorder.y, topLeftBorder.x, topLeftBorder.y),
            clipRect
        );
        ClipAndAddQuad(
            Rect.MinMaxRect(centerRect.xMax, centerRect.yMax, rect.xMax, rect.yMax),
            new Rect(uvRect.xMax - bottomRightBorder.x, uvRect.yMax - topLeftBorder.y, bottomRightBorder.x, topLeftBorder.y),
            clipRect
        );
        ClipAndAddQuad(
            Rect.MinMaxRect(centerRect.xMax, rect.y, rect.xMax, centerRect.y),
            new Rect(uvRect.xMax - bottomRightBorder.x, uvRect.y, bottomRightBorder.x, bottomRightBorder.y),
            clipRect
        );

        Rect sideClipRect;
        if (topLeftBorder.x > 0) {
            sideClipRect = Rect.MinMaxRect(
                Mathf.Clamp(rect.x, clipRect.x, clipRect.xMax),
                Mathf.Clamp(centerRect.y, clipRect.y, clipRect.yMax),
                Mathf.Clamp(centerRect.x, clipRect.x, clipRect.xMax),
                Mathf.Clamp(centerRect.yMax, clipRect.y, clipRect.yMax)
            );
            for (int j = 0; j < _vTilePoints.Count - 1; ++j)
                ClipAndAddQuad(
                    Rect.MinMaxRect(rect.x, _vTilePoints[j], centerRect.x, _vTilePoints[j + 1]),
                    new Rect(uvRect.x, uvRect.y + bottomRightBorder.y, topLeftBorder.x, tileSizeInUV.y),
                    sideClipRect
                );
        }
        if (topLeftBorder.y > 0) {
            sideClipRect = Rect.MinMaxRect(
                Mathf.Clamp(centerRect.x, clipRect.x, clipRect.xMax),
                Mathf.Clamp(centerRect.yMax, clipRect.y, clipRect.yMax),
                Mathf.Clamp(centerRect.xMax, clipRect.x, clipRect.xMax),
                Mathf.Clamp(rect.yMax, clipRect.y, clipRect.yMax)
            );
            for (int i = 0; i < _hTilePoints.Count - 1; ++i)
                ClipAndAddQuad(
                    Rect.MinMaxRect(_hTilePoints[i], centerRect.yMax, _hTilePoints[i + 1], rect.yMax),
                    new Rect(uvRect.x + topLeftBorder.x, uvRect.yMax - topLeftBorder.y, tileSizeInUV.x, topLeftBorder.y),
                    sideClipRect
                );
        }
        if (bottomRightBorder.x > 0) {
            sideClipRect = Rect.MinMaxRect(
                Mathf.Clamp(centerRect.xMax, clipRect.x, clipRect.xMax),
                Mathf.Clamp(centerRect.y, clipRect.y, clipRect.yMax),
                Mathf.Clamp(rect.xMax, clipRect.x, clipRect.xMax),
                Mathf.Clamp(centerRect.yMax, clipRect.y, clipRect.yMax)
            );
            for (int j = 0; j < _vTilePoints.Count - 1; ++j)
                ClipAndAddQuad(
                    Rect.MinMaxRect(centerRect.xMax, _vTilePoints[j], rect.xMax, _vTilePoints[j + 1]),
                    new Rect(uvRect.xMax - bottomRightBorder.x, uvRect.y + bottomRightBorder.y, bottomRightBorder.x, tileSizeInUV.y),
                    sideClipRect
                );
        }
        if (bottomRightBorder.y > 0) {
            sideClipRect = Rect.MinMaxRect(
                Mathf.Clamp(centerRect.x, clipRect.x, clipRect.xMax),
                Mathf.Clamp(rect.y, clipRect.y, clipRect.yMax),
                Mathf.Clamp(centerRect.xMax, clipRect.x, clipRect.xMax),
                Mathf.Clamp(centerRect.y, clipRect.y, clipRect.yMax)
            );
            for (int i = 0; i < _hTilePoints.Count - 1; ++i)
                ClipAndAddQuad(
                    Rect.MinMaxRect(_hTilePoints[i], rect.y, _hTilePoints[i + 1], centerRect.y),
                    new Rect(uvRect.x + topLeftBorder.x, uvRect.y, tileSizeInUV.x, bottomRightBorder.y),
                    sideClipRect
                );
        }

        if (_btSprite.HasCenter) {
            Rect centerClipRect = Rect.MinMaxRect(
                Mathf.Clamp(centerRect.x, clipRect.x, clipRect.xMax),
                Mathf.Clamp(centerRect.y, clipRect.y, clipRect.yMax),
                Mathf.Clamp(centerRect.xMax, clipRect.x, clipRect.xMax),
                Mathf.Clamp(centerRect.yMax, clipRect.y, clipRect.yMax)
            );
            for (int i = 0; i < _hTilePoints.Count - 1; ++i)
                for (int j = 0; j < _vTilePoints.Count - 1; ++j)
                    ClipAndAddQuad(
                        Rect.MinMaxRect(_hTilePoints[i], _vTilePoints[j], _hTilePoints[i + 1], _vTilePoints[j + 1]),
                        new Rect(uvRect.x + topLeftBorder.x, uvRect.y + bottomRightBorder.y, tileSizeInUV.x, tileSizeInUV.y),
                        centerClipRect
                    );
        }

        _colors = new Color[_vertices.Count];
        for (int i = 0; i < _colors.Length; ++i)
            _colors[i] = m_sprite.color;

        m_mesh.vertices = _vertices.ToArray();
        m_mesh.uv = _uvs.ToArray();
        m_mesh.colors = _colors;
        m_mesh.triangles = _indices.ToArray();
        m_mesh.RecalculateBounds();
        //m_mesh.RecalculateNormals();

        if (_vertices.Count >= 300)
            Debug.LogWarning("BorderedTilingSpriteMesh: Mesh has 300 or more vertices and might not be dynamically batched!");
    }

    void ClipAndAddQuad (Rect posRect, Rect texRect, Rect clipRect) {
        Rect clippedPosRect = Rect.MinMaxRect(
            Mathf.Clamp(posRect.x, clipRect.x, clipRect.xMax),
            Mathf.Clamp(posRect.y, clipRect.y, clipRect.yMax),
            Mathf.Clamp(posRect.xMax, clipRect.x, clipRect.xMax),
            Mathf.Clamp(posRect.yMax, clipRect.y, clipRect.yMax)
        );
        if (clippedPosRect.width <= 0 || clippedPosRect.height <= 0)
            return;

        Vector2 uvPerSize = new Vector2(texRect.width / posRect.width, texRect.height / posRect.height);
        texRect = Rect.MinMaxRect(
            texRect.x + (clippedPosRect.x - posRect.x) * uvPerSize.x,
            texRect.y + (clippedPosRect.y - posRect.y) * uvPerSize.y,
            texRect.xMax - (posRect.xMax - clippedPosRect.xMax) * uvPerSize.x,
            texRect.yMax - (posRect.yMax - clippedPosRect.yMax) * uvPerSize.y
        );

        int indexOffset = _vertices.Count;
        switch (m_sprite.plane) {
        case SpriteRoot.SPRITE_PLANE.XY:
            _vertices.Add(new Vector3(clippedPosRect.x, clippedPosRect.yMax, m_sprite.offset.z));
            _vertices.Add(new Vector3(clippedPosRect.x, clippedPosRect.y, m_sprite.offset.z));
            _vertices.Add(new Vector3(clippedPosRect.xMax, clippedPosRect.y, m_sprite.offset.z));
            _vertices.Add(new Vector3(clippedPosRect.xMax, clippedPosRect.yMax, m_sprite.offset.z));
            break;
        case SpriteRoot.SPRITE_PLANE.XZ:
            _vertices.Add(new Vector3(clippedPosRect.x, m_sprite.offset.y, clippedPosRect.yMax));
            _vertices.Add(new Vector3(clippedPosRect.x, m_sprite.offset.y, clippedPosRect.y));
            _vertices.Add(new Vector3(clippedPosRect.xMax, m_sprite.offset.y, clippedPosRect.y));
            _vertices.Add(new Vector3(clippedPosRect.xMax, m_sprite.offset.y, clippedPosRect.yMax));
            break;
        case SpriteRoot.SPRITE_PLANE.YZ:
            _vertices.Add(new Vector3(m_sprite.offset.x, clippedPosRect.yMax, clippedPosRect.x));
            _vertices.Add(new Vector3(m_sprite.offset.x, clippedPosRect.y, clippedPosRect.x));
            _vertices.Add(new Vector3(m_sprite.offset.x, clippedPosRect.y, clippedPosRect.xMax));
            _vertices.Add(new Vector3(m_sprite.offset.x, clippedPosRect.yMax, clippedPosRect.xMax));
            break;
        }

        _uvs.Add(new Vector2(texRect.x, texRect.yMax));
        _uvs.Add(new Vector2(texRect.x, texRect.y));
        _uvs.Add(new Vector2(texRect.xMax, texRect.y));
        _uvs.Add(new Vector2(texRect.xMax, texRect.yMax));

        if (m_sprite.winding == SpriteRoot.WINDING_ORDER.CW) {
            _indices.Add(indexOffset + 0);
            _indices.Add(indexOffset + 3);
            _indices.Add(indexOffset + 1);

            _indices.Add(indexOffset + 3);
            _indices.Add(indexOffset + 2);
            _indices.Add(indexOffset + 1);
        } else {
            _indices.Add(indexOffset + 0);
            _indices.Add(indexOffset + 1);
            _indices.Add(indexOffset + 3);

            _indices.Add(indexOffset + 3);
            _indices.Add(indexOffset + 1);
            _indices.Add(indexOffset + 2);
        }
    }

    public override SpriteRoot sprite {
        get {
            return base.sprite;
        }
        set {
            base.sprite = value;
            _btSprite = value as IBorderedTilingSprite;
        }
    }

    public override void Init () {
        if (m_mesh == null)
            CreateMesh();
        m_mesh.Clear();

        base.Init();

        RebuildMesh();
    }

    public override void UpdateVerts () {
        if (_btSprite == null) {
            base.UpdateVerts();
            return;
        }

        RebuildMesh();
    }   

    public override void UpdateUVs () {
        if (_btSprite == null) {
            base.UpdateUVs();
            return;
        }

        RebuildMesh();
    }

    public override void UpdateColors (Color color) {
        if (_btSprite == null || m_mesh == null) {
            base.UpdateColors(color);
            return;
        } else if (_colors == null)
            return;

        for (int i = 0; i < _colors.Length; ++i)
            _colors[i] = color;
        m_mesh.colors = _colors;
    }

    public override void SetWindingOrder (SpriteRoot.WINDING_ORDER winding) {
        if (_btSprite == null || m_mesh == null) {
            base.SetWindingOrder(winding);
            return;
        }

        int[] triangles = m_mesh.triangles;
        for (int i = 0; i < triangles.Length; i += 3) {
            int swap = triangles[i + 1];
            triangles[i + 1] = triangles[i + 2];
            triangles[i + 2] = swap;
        }

        m_mesh.triangles = triangles;
    }
}

public interface IBorderedTilingSprite {
    Rect UnclippedUVRect { get; }
    float SizePerPixel { get; }

    bool StretchVertically { get; set; }
    bool StretchHorizontally { get; set; }
    Vector2 TopLeftBorder { get; set; }
    Vector2 BottomRightBorder { get; set; }
    Vector2 TilingOffset { get; set; }
    bool HasCenter { get; set; }
    Vector2 SizePerTexel { get; set; }
    bool PixelPerTexel { get; set; }
}

public class BorderedTilingControlMirror : AutoSpriteControlBaseMirror {
    public bool stretchHorizontally;
    public bool stretchVertically;
    public Vector2 topLeftBorder;
    public Vector2 bottomRightBorder;
    public Vector2 tilingOffset;
    public bool hasCenter;
    public Vector2 sizePerTexel;
    public bool pixelPerTexel;

    public override void Mirror (SpriteRoot s) {
        base.Mirror(s);

        var bts = (IBorderedTilingSprite)s;
        stretchHorizontally = bts.StretchHorizontally;
        stretchVertically = bts.StretchVertically;
        topLeftBorder = bts.TopLeftBorder;
        bottomRightBorder = bts.BottomRightBorder;
        tilingOffset = bts.TilingOffset;
        hasCenter = bts.HasCenter;
        sizePerTexel = bts.SizePerTexel;
        pixelPerTexel = bts.PixelPerTexel;
    }

    public override bool DidChange (SpriteRoot s) {
        if (base.DidChange(s))
            return true;

        var bts = (IBorderedTilingSprite)s;
        if (
            bts.StretchHorizontally != stretchHorizontally
            || bts.StretchVertically != stretchVertically
            || bts.TopLeftBorder != topLeftBorder
            || bts.BottomRightBorder != bottomRightBorder
            || bts.TilingOffset != tilingOffset
            || bts.HasCenter != hasCenter
            || bts.SizePerTexel != sizePerTexel
            || bts.PixelPerTexel != pixelPerTexel
        )
            return true;
        else
            return false;
    }

    public override bool Validate (SpriteRoot s) {
        s.managed = false;
        s.manager = null;
        s.pixelPerfect = false;
        base.Validate(s);

        var bts = (IBorderedTilingSprite)s;
        bts.TopLeftBorder = new Vector2(Mathf.Max(0, bts.TopLeftBorder.x), Mathf.Max(0, bts.TopLeftBorder.y));
        bts.BottomRightBorder = new Vector2(Mathf.Max(0, bts.BottomRightBorder.x), Mathf.Max(0, bts.BottomRightBorder.y));
        bts.SizePerTexel = new Vector2(
            Mathf.Max(0.001f, bts.SizePerTexel.x),
            Mathf.Max(0.001f, bts.SizePerTexel.y)
        );

        return true;
    }
}


Next, our BorderedTilingButton control, which implements the IBorderedTilingSprite interface above.
Code: Select all
using UnityEngine;
using System.Collections;

public class BTButton : UIButton, IBorderedTilingSprite {
    public bool stretchHorizontally;
    public bool stretchVertically;
    public Vector2 topLeftBorder;
    public Vector2 bottomRightBorder;
    public Vector2 tilingOffset;
    public bool hasCenter = true;
    public Vector2 sizePerTexel = new Vector2(1, 1);
    public bool pixelPerTexel;

    protected override void Awake () {
        managed = false;
        manager = null;
        pixelPerfect = false;

        base.Awake();

        m_spriteMesh = new BorderedTilingSpriteMesh();
        m_spriteMesh.sprite = this;
    }

    public override void Start () {
        if (!uvsInitialized) {
            InitUVs();
            uvsInitialized = true;
        }

        if (m_spriteMesh as BorderedTilingSpriteMesh == null) {
            m_spriteMesh = new BorderedTilingSpriteMesh();
            m_spriteMesh.sprite = this;
        }

        base.Start();
    }

    public override void DoMirror () {
        if (mirror == null) {
            mirror = new BorderedTilingControlMirror();
            mirror.Mirror(this);
        }

        base.DoMirror();
    }

    Rect IBorderedTilingSprite.UnclippedUVRect {
        get {
            return Rect.MinMaxRect(
                frameInfo.uvs.x + bleedCompensationUV.x, frameInfo.uvs.y + bleedCompensationUV.y,
                frameInfo.uvs.xMax + bleedCompensationUVMax.x, frameInfo.uvs.yMax + bleedCompensationUVMax.y
            );
        }
    }
    float IBorderedTilingSprite.SizePerPixel {
        get { return worldUnitsPerScreenPixel; }
    }

    bool IBorderedTilingSprite.StretchHorizontally {
        get { return stretchHorizontally; }
        set { stretchHorizontally = value; }
    }
    bool IBorderedTilingSprite.StretchVertically {
        get { return stretchVertically; }
        set { stretchVertically = value; }
    }
    Vector2 IBorderedTilingSprite.TopLeftBorder {
        get { return topLeftBorder; }
        set { topLeftBorder = value; }
    }
    Vector2 IBorderedTilingSprite.BottomRightBorder {
        get { return bottomRightBorder; }
        set { bottomRightBorder = value; }
    }
    Vector2 IBorderedTilingSprite.TilingOffset {
        get { return tilingOffset; }
        set { tilingOffset = value; }
    }
    bool IBorderedTilingSprite.HasCenter {
        get { return hasCenter; }
        set { hasCenter = value; }
    }
    Vector2 IBorderedTilingSprite.SizePerTexel {
        get { return sizePerTexel; }
        set { sizePerTexel = value; }
    }
    bool IBorderedTilingSprite.PixelPerTexel {
        get { return pixelPerTexel; }
        set { pixelPerTexel = value; }
    }
}


As a final note, to allow BTButton to be editable in the inspector like other EZGui controls, go to EZGui's editor script folder and copy the empty "UIButtonInspector" class. Change the types to BTButton and drop it into your own editor folder. You can now pick state textures as if it were a regular button. The texture you give it is the entire 9 slice texture, without any need to cut it up. Simply specify the border size in the inspector, and the mesh will be regenerated appropriately.

I hope this is helpful to others. Enjoy!
Last edited by Fes on Fri Oct 14, 2011 9:09 pm, edited 4 times in total.
Fes
 
Posts: 10
Joined: Fri Sep 09, 2011 11:46 pm

Re: Sliced/Tiling Controls

Postby SpaceCadet » Tue Sep 13, 2011 9:37 am

Thank you so much for posting this, Fes! I just get two errors when trying this:

Firstly, CreateMesh() isn't defined, apparently - was this supposed to be implemented within BorderedTilingSpriteMesh?
Secondly, in BTButton, uvsInitialized isn't defined either?

Look forward to trying this! Thank you.
SpaceCadet
 
Posts: 12
Joined: Mon Sep 12, 2011 11:39 am

Re: Sliced/Tiling Controls

Postby Fes » Tue Sep 13, 2011 9:55 am

Not sure why that's not working. Are you using the latest ezgui?

CreateMesh and uvsInitialized are inherited from SpriteMesh and SpriteRoot respectively, so it should work. Might double check that nothign got mangled when copy/pasting it from the post. Let me know if it still doesn't work and I'll take a closer look.
Fes
 
Posts: 10
Joined: Fri Sep 09, 2011 11:46 pm

Re: Sliced/Tiling Controls

Postby SpaceCadet » Tue Sep 13, 2011 11:59 am

Ah ha, this brought to light that I indeed hadn't updated EZGui properly last time, and was instead using an older version! Thanks, now I've updated EZGui to 1.07, this works brilliantly.

Thank you once again!
SpaceCadet
 
Posts: 12
Joined: Mon Sep 12, 2011 11:39 am

Re: Sliced/Tiling Controls

Postby Brady » Tue Sep 13, 2011 9:59 pm

Thanks for posting, Fes! I'll try to give this a look shortly.
Brady
 
Posts: 5361
Joined: Tue Jul 06, 2010 11:33 pm

Re: Sliced/Tiling Controls

Postby chirhotec » Mon Oct 03, 2011 6:37 pm

Im getting null reference errors on the UpdateColor function. Seems that the mesh filter is getting replaced with one that has 0 verts.
chirhotec
 
Posts: 7
Joined: Tue Nov 30, 2010 7:39 pm

Re: Sliced/Tiling Controls

Postby Fes » Mon Oct 03, 2011 7:36 pm

I've added a few extra null checks in some of the overrides that should hopefully guard against that. Let me know if it works. If not I'll take another look.
Fes
 
Posts: 10
Joined: Fri Sep 09, 2011 11:46 pm

Re: Sliced/Tiling Controls

Postby Fes » Sat Oct 15, 2011 1:44 am

Pretty major update to this. I've fixed some important bugs, primarily fixing clipping support. These controls should now work properly in scroll lists or any other clipped environment.
Fes
 
Posts: 10
Joined: Fri Sep 09, 2011 11:46 pm

Re: Sliced/Tiling Controls

Postby funkyfreshcecil » Thu May 03, 2012 9:31 pm

This looks great... I'd love to include it in my project.

What are your licensing terms for using this?

I imagine it doesn't fall under the EZGUI license, since you wrote it, not Above and Beyond.



thanks!
Funky Swadling
A.C.R.O.N.Y.M. Games, Inc.
www.acronymgames.com
funkyfreshcecil
 
Posts: 1
Joined: Thu May 03, 2012 9:28 pm

Re: Sliced/Tiling Controls

Postby qholmes » Fri Jun 15, 2012 6:28 pm

Hey this is pretty cool.. Now i have not managed to get it to work quite right... I dont get how to set the Border corners to get what i want.. my texture is 32x32 circle.. if i set all the numbers to 16 i get the corners but no center.. if i change them to something else like 15 then it goes crazy?

Q
qholmes
 
Posts: 128
Joined: Tue Apr 19, 2011 8:03 am

Next

Return to EZ GUI Add-ons

Who is online

Users browsing this forum: No registered users and 5 guests

cron