[펌] NGUI-UILabel : Shadow+Outline
Unity3D/NGUI / 2024. 1. 25. 16:10
Unity 2021.3.33f1
NGUI 2023.08.01
----
NGUI-UILabel의 Effect에서 Shadow와 Outline을 같이 적용하고 싶어서 찾아보고 올려둠.
UILabel에 세 곳에 소스 추가
public class UILabel : UIWidget
{
....
[DoNotObfuscateNGUI] public enum Effect
{
None,
Shadow,
Outline,
Outline8,
ShadowAndOutline, // Add
}
....
/// <summary>
/// How many quads there are per printed character.
/// </summary>
public int quadsPerCharacter
{
get
{
if (mEffectStyle == Effect.Shadow) return 2;
else if (mEffectStyle == Effect.Outline) return 5;
else if (mEffectStyle == Effect.Outline8) return 9;
else if (mEffectStyle == Effect.ShadowAndOutline) return 9; // Add
return 1;
}
}
....
public void Fill (List<Vector3> verts, List<Vector2> uvs, List<Color> cols, List<Vector3> symbolVerts, List<Vector2> symbolUVs, List<Color> symbolCols)
{
...
// Apply an effect if one was requested
if (effectStyle != Effect.None)
{
int end = verts.Count;
var symEnd = (symbolVerts != null) ? symbolVerts.Count : 0;
pos.x = mEffectDistance.x;
pos.y = mEffectDistance.y;
ApplyShadow(verts, uvs, cols, offset, end, pos.x, -pos.y);
if (symbolVerts != null) ApplyShadow(symbolVerts, symbolUVs, symbolCols, symOffset, symEnd, pos.x, -pos.y);
#region Add ShadowAndOutline
if (effectStyle == Effect.ShadowAndOutline)
{
pos.y /= 2;
pos.x = pos.y;
offset = end;
end = verts.Count;
ApplyShadow(verts, uvs, cols, offset, end, -pos.x, pos.y);
offset = end;
end = verts.Count;
ApplyShadow(verts, uvs, cols, offset, end, pos.x, pos.y);
offset = end;
end = verts.Count;
ApplyShadow(verts, uvs, cols, offset, end, -pos.x, -pos.y);
offset = end;
end = verts.Count;
ApplyShadow(verts, uvs, cols, offset, end, -pos.x, 0);
offset = end;
end = verts.Count;
ApplyShadow(verts, uvs, cols, offset, end, pos.x, 0);
offset = end;
end = verts.Count;
ApplyShadow(verts, uvs, cols, offset, end, 0, pos.y);
offset = end;
end = verts.Count;
ApplyShadow(verts, uvs, cols, offset, end, 0, -pos.y);
}
#endregion
if ((effectStyle == Effect.Outline) || (effectStyle == Effect.Outline8))
{
...
}
}
[출처] https://gamedev.stackexchange.com/questions/151329/all-sides-shadow-outline-in-unity-ngui
반응형
'Unity3D > NGUI' 카테고리의 다른 글
[링크] NGUI, BBCode 태그 제거하기 (Replace) (0) | 2024.10.17 |
---|---|
UITexture UV Animation (0) | 2024.09.05 |
[링크] [UnityNGUI] ScrollView에 Particle Clipping하기 (0) | 2023.10.31 |
[NGUI] NGUI Atlas가 압축(Compression) 상태에서 Atlas 묶을 때 오류 없이 자동처리 하기 (1) | 2023.04.07 |
[링크] NGUI 유용한 링크 (0) | 2023.02.21 |