diff options
author | chai <chaifix@163.com> | 2021-11-05 12:14:59 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2021-11-05 12:14:59 +0800 |
commit | 6d5787d8da9ad1685864668dd4c3d6aa73a563db (patch) | |
tree | f4d28a553b13b369a580c482e187bcc4b42f39de /Runtime/Scripting/GUI/Font.bind.cpp | |
parent | be9870f5c1ba4f6ae8cd9764f1a8ed56ee81ddd5 (diff) |
TextMeshGenerator
Diffstat (limited to 'Runtime/Scripting/GUI/Font.bind.cpp')
-rw-r--r-- | Runtime/Scripting/GUI/Font.bind.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/Runtime/Scripting/GUI/Font.bind.cpp b/Runtime/Scripting/GUI/Font.bind.cpp index 7d7e3f2..0570df0 100644 --- a/Runtime/Scripting/GUI/Font.bind.cpp +++ b/Runtime/Scripting/GUI/Font.bind.cpp @@ -7,6 +7,8 @@ #include "Runtime/Utilities/StaticInitiator.h"
#include "Runtime/GUI/UITextMesh.h"
#include "Runtime/Math/Math.h" +#include "Runtime/GUI/TextMeshGenerator.h" +#include "Runtime/Utilities/AutoInvoke.h" static std::vector<character::Unicode>* s_Codepoints;
@@ -102,6 +104,10 @@ LUA_BIND_IMPL_METHOD(Font, _GetCharacters) int encoding = state.GetValue<int>(6, EEncoding::Encoding_UTF8);
s_Codepoints->clear();
+ InvokeWhenLeave([]() {
+ s_Codepoints->clear();
+ });
+
if (encoding == EEncoding::Encoding_UTF8)
{
while (*buf != 0) {
@@ -137,7 +143,7 @@ LUA_BIND_IMPL_METHOD(Font, _GetCharacters) WipeGLError();
- UITextMesh* tm = new UITextMesh(str, self, size, size + 3, Color32::white, TextAnchor_UpperLeft, TextAlignment_Left, wordwrap, preferred);
+ const UITextMesh* tm = g_TextMeshGenerator.GetTextMesh(str, self, size, size + 3, Color32::white, TextAnchor_UpperLeft, TextAlignment_Left, wordwrap, preferred);
tm->Draw();
return 0;
|