All codes below are base on NGUI v2.0.7c.
OK, so edit your UIFont & UILable like this:
In UIFont.cs
1. Alter function Print(), add two variable at the end:
UILabel.Effect effect, Color effectColor
2. At the 3rd line of Print(), mReplacement.Print() should modify to:
mReplacement.Print(...origin..., effect, effectColor);
3. At the if block of "if (glyph.channel == 0 || glyph.channel == 15)"
origin should be like:
if ()
{
for()
}
else
{
//comments
Color col = color;
originCodes;
for();
}
modify like this:
Color col = color;
Color colEff = effectColor;
if ()
{
//for()
}
else
{
//comments
//Color col = color;
originCodes;
colEff *= 0.49f;
switch (glyph.channel)
{
case 1: colEff.b += 0.51f; break;
case 2: colEff.g += 0.51f; break;
case 4: colEff.r += 0.51f; break;
case 8: colEff.a += 0.51f; break;
}
//for();
}
if (effect != UILabel.Effect.None)
{
for (int b = 0; b < 4; ++b) cols.Add(colEff);
if (effect == UILabel.Effect.Outline)
for (int b = 0; b < 12; ++b) cols.Add(colEff);
}
for (int b = 0; b < 4; ++b) cols.Add(col);
4. before " verts.add()... uvs.add()..." add the code below:
if (effect != UILabel.Effect.None && symbol == null)
{
float pixel = 1f / this.size;
verts
.Add(new Vector3
(v1
.x + pixel, v0
.y - pixel
)); verts
.Add(new Vector3
(v1
.x + pixel, v1
.y - pixel
)); verts
.Add(new Vector3
(v0
.x + pixel, v1
.y - pixel
)); verts
.Add(new Vector3
(v0
.x + pixel, v0
.y - pixel
));
uvs
.Add(new Vector2
(u1
.x, u0
.y)); uvs
.Add(new Vector2
(u1
.x, u1
.y)); uvs
.Add(new Vector2
(u0
.x, u1
.y)); uvs
.Add(new Vector2
(u0
.x, u0
.y));
if (effect == UILabel.Effect.Outline)
{
verts
.Add(new Vector3
(v1
.x - pixel, v0
.y + pixel
)); verts
.Add(new Vector3
(v1
.x - pixel, v1
.y + pixel
)); verts
.Add(new Vector3
(v0
.x - pixel, v1
.y + pixel
)); verts
.Add(new Vector3
(v0
.x - pixel, v0
.y + pixel
));
uvs
.Add(new Vector2
(u1
.x, u0
.y)); uvs
.Add(new Vector2
(u1
.x, u1
.y)); uvs
.Add(new Vector2
(u0
.x, u1
.y)); uvs
.Add(new Vector2
(u0
.x, u0
.y));
verts
.Add(new Vector3
(v1
.x + pixel, v0
.y + pixel
)); verts
.Add(new Vector3
(v1
.x + pixel, v1
.y + pixel
)); verts
.Add(new Vector3
(v0
.x + pixel, v1
.y + pixel
)); verts
.Add(new Vector3
(v0
.x + pixel, v0
.y + pixel
));
uvs
.Add(new Vector2
(u1
.x, u0
.y)); uvs
.Add(new Vector2
(u1
.x, u1
.y)); uvs
.Add(new Vector2
(u0
.x, u1
.y)); uvs
.Add(new Vector2
(u0
.x, u0
.y));
verts
.Add(new Vector3
(v1
.x - pixel, v0
.y - pixel
)); verts
.Add(new Vector3
(v1
.x - pixel, v1
.y - pixel
)); verts
.Add(new Vector3
(v0
.x - pixel, v1
.y - pixel
)); verts
.Add(new Vector3
(v0
.x - pixel, v0
.y - pixel
));
uvs
.Add(new Vector2
(u1
.x, u0
.y)); uvs
.Add(new Vector2
(u1
.x, u1
.y)); uvs
.Add(new Vector2
(u0
.x, u1
.y)); uvs
.Add(new Vector2
(u0
.x, u0
.y)); }
}
In UILable.cs
1. Remove codes in OnFill() below this comment:
// Apply an effect if one was requested
2. for any Print() call of UIFont in OnFill(), just add two variable at the end, like this:
mFont.Print(...origin...,effectStyle, effectColor);
Done