Open
Description
What happened?
I implemented the DrawText3D
function in C# Mono V2, but Korean characters appear as unknown symbols when using the AddTextComponentString
native function.
In C# V1 and Lua, the same logic correctly displays Korean characters.
Test Code for C# V1 / C# Mono V2:
// (tick omitted)
string text = "테스트";
DrawText3D(228.4157f, -855.1374f, 30.93833f, text, 255, 255, 255, 255, 0.7f);
void DrawText3D(float x, float y, float z, string text, int r, int g, int b, int a, float scaleFactor)
{
float screenX = 0.0f, screenY = 0.0f;
bool onScreen = World3dToScreen2d(x, y, z, ref screenX, ref screenY);
if (!onScreen)
{
return;
}
Vector3 camCoords = GetGameplayCamCoord();
float dist = GetDistanceBetweenCoords(camCoords.X, camCoords.Y, camCoords.Z, x, y, z, true);
float scale = (1 / dist) * scaleFactor;
float fov = (1 / GetGameplayCamFov()) * 100;
scale *= fov;
RegisterFontFile("nanum");
var fontId = RegisterFontId("nanum");
SetTextScale(scale, scale);
SetTextFont(fontId);
SetTextColour(r, g, b, a);
SetTextProportional(true);
SetTextOutline();
SetTextEntry("STRING");
SetTextCentre(true);
AddTextComponentString(text);
DrawText(screenX, screenY);
}
Test Code for Lua:
CreateThread(function()
while true do
local text = "테스트"
DrawText3D(228.4157, -855.1374, 30.93833, text, 255, 255, 255, 255, 0.7)
Wait(0)
end
end)
function DrawText3D(x, y, z, text, r, g, b, a, scaleFactor)
local onScreen,screenX, screenY = World3dToScreen2d(x, y, z);
local camCoords = GetGameplayCamCoord();
local dist = GetDistanceBetweenCoords(camCoords[1], camCoords[2], camCoords[3], x, y, z, true);
local scale = (1 / dist) * scaleFactor;
local fov = (1 / GetGameplayCamFov()) * 100;
scale *= fov;
RegisterFontFile("nanum");
local fontId = RegisterFontId("nanum");
if onScreen then
SetTextScale(scale, scale);
SetTextFont(fontId);
SetTextColour(r, g, b, a);
SetTextProportional(true);
SetTextOutline();
SetTextEntry("STRING");
SetTextCentre(true);
AddTextComponentString(text);
DrawText(screenX, screenY);
end
end
Expected result
Korean should be displayed correctly.
Reproduction steps
- Implement the
DrawText3D
function in C# Mono V2. - Pass a Korean string to the
AddTextComponentString
native function. - Observe that Korean characters appear as unknown symbols.
- Test the same logic in C# V1 and Lua, where Korean characters display correctly.
Importancy
Unknown
Area(s)
ScRT: C#
Specific version(s)
FiveM 3095/Ver. 13570
Additional information
No response