From 6d5787d8da9ad1685864668dd4c3d6aa73a563db Mon Sep 17 00:00:00 2001 From: chai Date: Fri, 5 Nov 2021 12:14:59 +0800 Subject: TextMeshGenerator --- Runtime/Scripting/GUI/Font.bind.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'Runtime/Scripting/GUI/Font.bind.cpp') 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* s_Codepoints; @@ -102,6 +104,10 @@ LUA_BIND_IMPL_METHOD(Font, _GetCharacters) int encoding = state.GetValue(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; -- cgit v1.1-26-g67d0