Using Unity’s TextGenerator.verts

TextGenerator.verts is meant to give the position information of every character in a given string. This is useful in Unity if you need to align something with exactly where some particular text is occuring, if for some reason you are not already using TextMeshPro.

Older Unity versions created 4 verts for every character, which made life easy. But now many non-rendering characters don’t have verts generated for them, and the relationship between verts and characters is undocumented. I’ve reverse engineered it, as best as I can tell:

int? GetVertForPosition(int position, string text, TextGenerator textGenerator)
    var c = 0;
    var vert = 0;
    for (var i = 0; i < position; i++)
        if (textGenerator.characters.Count <= c)
            return null;
        if (!char.IsWhiteSpace(text[i]) && textGenerator.characters[c].charWidth > 0)
            vert += 4;
        if (text[i] != '\n')
    return vert;

New Discord Server

Let’s face it, running your own WordPress blog is a sign you are woefully out of date. I can see plenty of readers, but never hear from them.

So I’ve created a Discord server. Feel free to log on and ask me support questions about my projects, suggest new article ideas, or just to hang out.

Don’t worry, the blog isn’t going anwhere. I think the jump might kill me if I leaped fully into the 21st century.

X Gems of AS3 Language Design

Ok, so AS3 has its fair share of problems. It is slow, it has next to no support for templates/generics and somewhat sparse standard library. And yet still I love using it.

Why? It has managed to pull together some of the rarer features that I think every language should have. Language designers, take note of the following.

Continue reading

Release of Box2DFlash 2.1a

I’m releasing an alpha version of Box2D Flash 2.1. It’s got a shiny new website, too. It has may features that were lacking before, but you’ll have to discover most of them for yourself.

This move is prompted mainly by the announcement of Erin that Box2D 2.1 itself is going to be delayed for more features. Also, the wiki got wiped out, so documentation is at an all time low (frankly, I’m glad the wiki’s gone. I sunk much work into it, but it was still a useless reference source).

Code is still alpha quality, which means a) bugs, b) no guarantees for changes in syntax. The big stuff is out of the way though. If you find a bug, or have a complaint, please post it to the forum as a new thread starting, or the sourceforge issue tracker. Do not post it as a comment here. A comment amongst other comments is too easily lost.Bear in mind that I will almost certainly ask for a testbed demonstrating the bug.

BTW, I’m going away for a couple of days for TIGJam:UK, so don’t expect issues to be treated immediately.

Announcement on forums