diff --git a/Source/LuaMachine/Private/LuaBlueprintFunctionLibrary.cpp b/Source/LuaMachine/Private/LuaBlueprintFunctionLibrary.cpp index 7e50a0d..96ac5f6 100644 --- a/Source/LuaMachine/Private/LuaBlueprintFunctionLibrary.cpp +++ b/Source/LuaMachine/Private/LuaBlueprintFunctionLibrary.cpp @@ -327,6 +327,23 @@ FString ULuaBlueprintFunctionLibrary::LuaValueToUTF8(FLuaValue Value) return FString(UTF8_TO_TCHAR(Bytes.GetData())); } +FLuaValue ULuaBlueprintFunctionLibrary::LuaValueFromUTF32(FString String) +{ + FTCHARToUTF32 UTF32String(*String); + return FLuaValue((const char*)UTF32String.Get(), UTF32String.Length()); +} + +FString ULuaBlueprintFunctionLibrary::LuaValueToUTF32(FLuaValue Value) +{ + FString ReturnValue; + TArray Bytes = Value.ToBytes(); + Bytes.Add(0); + Bytes.Add(0); + Bytes.Add(0); + Bytes.Add(0); + return FString(FUTF32ToTCHAR((const UTF32CHAR*)Bytes.GetData(), Bytes.Num() / 4).Get()); +} + FLuaValue ULuaBlueprintFunctionLibrary::LuaRunFile(UObject* WorldContextObject, TSubclassOf State, FString Filename, bool bIgnoreNonExistent) { FLuaValue ReturnValue; @@ -490,7 +507,9 @@ UTexture2D* ULuaBlueprintFunctionLibrary::LuaValueToTransientTexture(int32 Width UTexture2D* Texture = UTexture2D::CreateTransient(Width, Height, PixelFormat); if (!Texture) + { return nullptr; + } FTexture2DMipMap& Mip = Texture->PlatformData->Mips[0]; void* Data = Mip.BulkData.Lock(LOCK_READ_WRITE); diff --git a/Source/LuaMachine/Public/LuaBlueprintFunctionLibrary.h b/Source/LuaMachine/Public/LuaBlueprintFunctionLibrary.h index 58348e9..cafc217 100644 --- a/Source/LuaMachine/Public/LuaBlueprintFunctionLibrary.h +++ b/Source/LuaMachine/Public/LuaBlueprintFunctionLibrary.h @@ -218,6 +218,12 @@ class LUAMACHINE_API ULuaBlueprintFunctionLibrary : public UBlueprintFunctionLib UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Lua") static FString LuaValueToUTF8(FLuaValue Value); + UFUNCTION(BlueprintCallable, Category = "Lua") + static FLuaValue LuaValueFromUTF32(FString String); + + UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Lua") + static FString LuaValueToUTF32(FLuaValue Value); + UFUNCTION(BlueprintCallable, BlueprintPure, meta = (WorldContext = "WorldContextObject"), Category = "Lua") static int64 LuaValueToPointer(UObject* WorldContextObject, TSubclassOf State, FLuaValue Value);