Git Product home page Git Product logo

unreal.lua's People

Contributors

asqbtcupid avatar kevinofsias avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

unreal.lua's Issues

Can I get the pointer of the table represented object?

In most case, I want to call a C++ function in lua, and the C++ function need a pointer, such as UGameplayStatics::GetGameInstance(UObject* WorldContext), and in GameMode.lua, the self is a table? how can I get the light userdata of GameMode?

4.21下unreal.lua的master版的内存管理bug?

操作如下:
1.使用master分支的例子工程,用ue4.21生成c++工程,build后打开uproject工程。
2.在content下git/TopDownCharacter蓝图的BeginPlay事件中添加setlifespan(10.f)节点将角色生命周期设为10秒。
3.pie中播放,等待50秒至5分钟左右,有较大几率发现 输出日志 窗口出现错误;如果此时没有出现,点击停止按钮,则几乎必然在输出日志中出现错误。示例错误如下:

LogUObjectArray: Warning: Empty slot
LogOutputDevice: Warning: Script Stack (0 frames):
LogStats: FPlatformStackWalk::StackWalkAndDump - 5.871 s
LogOutputDevice: Error: === Handled ensure: ===
LogOutputDevice: Error: Ensure condition failed: 0 [File:D:\work\Unreal\LuaPlugin\origin\unreal.lua.4.21_20190206\unreal.lua\Plugins\UnrealLua\LuaPlugin\Source\LuaPluginRuntime\TableUtil.cpp] [Line: 962]
LogOutputDevice: Error: Bug
LogOutputDevice: Error: Stack:
LogOutputDevice: Error: [Callstack] 0x00007ffb9b47c9d9 UE4Editor-LuaPluginRuntime.dll!touobject() [d:\work\unreal\luaplugin\origin\unreal.lua.4.21_20190206\unreal.lua\plugins\unreallua\luaplugin\source\luapluginruntime\tableutil.cpp:962]
LogOutputDevice: Error: [Callstack] 0x00007ffb9b43f703 UE4Editor-LuaPluginRuntime.dll!EnsureDestroy() [d:\work\unreal\luaplugin\origin\unreal.lua.4.21_20190206\unreal.lua\plugins\unreallua\luaplugin\source\luapluginruntime\nativeluafunc.h:695]
LogOutputDevice: Error: [Callstack] 0x00007ffb9b54bd97 UE4Editor-Lua53.dll!luaD_precall() [d:\work\unreal\luaplugin\origin\unreal.lua.4.21_20190206\unreal.lua\plugins\lua53\source\lua53\private\ldo.c:437]
LogOutputDevice: Error: [Callstack] 0x00007ffb9b54b6bf UE4Editor-Lua53.dll!luaD_callnoyield() [d:\work\unreal\luaplugin\origin\unreal.lua.4.21_20190206\unreal.lua\plugins\lua53\source\lua53\private\ldo.c:509]
LogOutputDevice: Error: [Callstack] 0x00007ffb9b54c0a5 UE4Editor-Lua53.dll!luaD_rawrunprotected() [d:\work\unreal\luaplugin\origin\unreal.lua.4.21_20190206\unreal.lua\plugins\lua53\source\lua53\private\ldo.c:145]
LogOutputDevice: Error: [Callstack] 0x00007ffb9b54b940 UE4Editor-Lua53.dll!luaD_pcall() [d:\work\unreal\luaplugin\origin\unreal.lua.4.21_20190206\unreal.lua\plugins\lua53\source\lua53\private\ldo.c:729]
LogOutputDevice: Error: [Callstack] 0x00007ffb9b542551 UE4Editor-Lua53.dll!lua_pcallk() [d:\work\unreal\luaplugin\origin\unreal.lua.4.21_20190206\unreal.lua\plugins\lua53\source\lua53\private\lapi.c:968]
LogOutputDevice: Error: [Callstack] 0x00007ffb9b47d168 UE4Editor-LuaPluginRuntime.dll!uobjcet_gcfunc() [d:\work\unreal\luaplugin\origin\unreal.lua.4.21_20190206\unreal.lua\plugins\unreallua\luaplugin\source\luapluginruntime\nativeluafunc.h:614]
LogOutputDevice: Error: [Callstack] 0x00007ffb9b54bd97 UE4Editor-Lua53.dll!luaD_precall() [d:\work\unreal\luaplugin\origin\unreal.lua.4.21_20190206\unreal.lua\plugins\lua53\source\lua53\private\ldo.c:437]
LogOutputDevice: Error: [Callstack] 0x00007ffb9b54b6bf UE4Editor-Lua53.dll!luaD_callnoyield() [d:\work\unreal\luaplugin\origin\unreal.lua.4.21_20190206\unreal.lua\plugins\lua53\source\lua53\private\ldo.c:509]
LogOutputDevice: Error: [Callstack] 0x00007ffb9b54c0a5 UE4Editor-Lua53.dll!luaD_rawrunprotected() [d:\work\unreal\luaplugin\origin\unreal.lua.4.21_20190206\unreal.lua\plugins\lua53\source\lua53\private\ldo.c:145]
LogOutputDevice: Error: [Callstack] 0x00007ffb9b54b940 UE4Editor-Lua53.dll!luaD_pcall() [d:\work\unreal\luaplugin\origin\unreal.lua.4.21_20190206\unreal.lua\plugins\lua53\source\lua53\private\ldo.c:729]
LogOutputDevice: Error: [Callstack] 0x00007ffb9b54ec3f UE4Editor-Lua53.dll!runafewfinalizers() [d:\work\unreal\luaplugin\origin\unreal.lua.4.21_20190206\unreal.lua\plugins\lua53\source\lua53\private\lgc.c:848]
LogOutputDevice: Error: [Callstack] 0x00007ffb9b54debd UE4Editor-Lua53.dll!luaC_runtilstate() [d:\work\unreal\luaplugin\origin\unreal.lua.4.21_20190206\unreal.lua\plugins\lua53\source\lua53\private\lgc.c:1106]
LogOutputDevice: Error: [Callstack] 0x00007ffb9b54dbff UE4Editor-Lua53.dll!luaC_fullgc() [d:\work\unreal\luaplugin\origin\unreal.lua.4.21_20190206\unreal.lua\plugins\lua53\source\lua53\private\lgc.c:1173]
LogOutputDevice: Error: [Callstack] 0x00007ffb9b541d27 UE4Editor-Lua53.dll!lua_gc() [d:\work\unreal\luaplugin\origin\unreal.lua.4.21_20190206\unreal.lua\plugins\lua53\source\lua53\private\lapi.c:1103]
LogOutputDevice: Error: [Callstack] 0x00007ffb9b481609 UE4Editor-LuaPluginRuntime.dll!LuaContext::OnWorldCleanup() [d:\work\unreal\luaplugin\origin\unreal.lua.4.21_20190206\unreal.lua\plugins\unreallua\luaplugin\source\luapluginruntime\unrealluainterface.cpp:184]
LogOutputDevice: Error: [Callstack] 0x00007ffb9b4816b4 UE4Editor-LuaPluginRuntime.dll!LuaContextMgr::OnWorldCleanup() [d:\work\unreal\luaplugin\origin\unreal.lua.4.21_20190206\unreal.lua\plugins\unreallua\luaplugin\source\luapluginruntime\unrealluainterface.cpp:343]
LogOutputDevice: Error: [Callstack] 0x00007ffb9b47f00e UE4Editor-LuaPluginRuntime.dll!TBaseRawMethodDelegateInstance<0,LuaContextMgr,void __cdecl(UWorld *,bool,bool)>::ExecuteIfSafe() [d:\work\unreal\standard\ue4\ue_4.21\engine\source\runtime\core\public\delegates\delegateinstancesimpl.h:518]
LogOutputDevice: Error: [Callstack] 0x00007ffba9318deb UE4Editor-Engine.dll!TBaseMulticastDelegate<void,UWorld * __ptr64,bool,bool>::Broadcast() [d:\build++ue4\sync\engine\source\runtime\core\public\delegates\delegatesignatureimpl.inl:974]
LogOutputDevice: Error: [Callstack] 0x00007ffba9320780 UE4Editor-Engine.dll!UWorld::CleanupWorld() [d:\build++ue4\sync\engine\source\runtime\engine\private\world.cpp:3762]
LogOutputDevice: Error: [Callstack] 0x00007ffbab58af82 UE4Editor-UnrealEd.dll!UEditorEngine::TeardownPlaySession() [d:\build++ue4\sync\engine\source\editor\unrealed\private\playlevel.cpp:748]
LogOutputDevice: Error: [Callstack] 0x00007ffbab550f1b UE4Editor-UnrealEd.dll!UEditorEngine::EndPlayMap() [d:\build++ue4\sync\engine\source\editor\unrealed\private\playlevel.cpp:324]
LogOutputDevice: Error: [Callstack] 0x00007ffbaaf83002 UE4Editor-UnrealEd.dll!UEditorEngine::Tick() [d:\build++ue4\sync\engine\source\editor\unrealed\private\editorengine.cpp:1992]
LogOutputDevice: Error: [Callstack] 0x00007ffbab8a2346 UE4Editor-UnrealEd.dll!UUnrealEdEngine::Tick() [d:\build++ue4\sync\engine\source\editor\unrealed\private\unrealedengine.cpp:403]
LogOutputDevice: Error: [Callstack] 0x00007ff63f176225 UE4Editor.exe!FEngineLoop::Tick() [d:\build++ue4\sync\engine\source\runtime\launch\private\launchengineloop.cpp:3699]
LogOutputDevice: Error: [Callstack] 0x00007ff63f18596c UE4Editor.exe!GuardedMain() [d:\build++ue4\sync\engine\source\runtime\launch\private\launch.cpp:174]
LogOutputDevice: Error: [Callstack] 0x00007ff63f1859ea UE4Editor.exe!GuardedMainWrapper() [d:\build++ue4\sync\engine\source\runtime\launch\private\windows\launchwindows.cpp:145]
LogOutputDevice: Error: [Callstack] 0x00007ff63f1948da UE4Editor.exe!WinMain() [d:\build++ue4\sync\engine\source\runtime\launch\private\windows\launchwindows.cpp:276]
LogOutputDevice: Error: [Callstack] 0x00007ff63f19659a UE4Editor.exe!__scrt_common_main_seh() [f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:283]
LogOutputDevice: Error: [Callstack] 0x00007ffc0d7a7e94 KERNEL32.DLL!UnknownFunction []
LogOutputDevice: Error: [Callstack] 0x00007ffc0fcaa251 ntdll.dll!UnknownFunction []
LogStats: SubmitErrorReport - 0.000 s
LogStats: SendNewReport - 1.127 s
LogStats: FDebug::EnsureFailed - 7.005 s
LogOutputDevice: Warning: stack traceback:
[C]: in ?
[C]: in ?
LogUObjectArray: Warning: Other object in slot
LogOutputDevice: Warning: Script Stack (0 frames):
LogStats: FPlatformStackWalk::StackWalkAndDump - 0.005 s

这样的错误有好几种,有时候提示Other object in slot,有时候提示什么not registered,有时候显示lua堆栈在TimerMgr类的Tick函数中。看提示像是lua的内存管理上的bug。有时间的话能否处理一下这个问题?非常感谢。

allweakclass.script.h

error C2011: “TWeakObjectPtr_UObject”:“class” type redifinition?
when I add a new class in a new file to my project, then build solution, some errors occur in visual studio 2017?

vs2017 compile warning

11>WARNING : warning : Plugin 'LuaPlugin' does not list plugin 'VarWatcher' as a dependency, but module 'LuaPluginRuntime' depends on 'VarWatcher'.
11>WARNING : warning : Plugin 'LuaPlugin' does not list plugin 'LuaDebugger' as a dependency, but module 'LuaCircularModules' depends on 'LuaDebugger'.
11>WARNING : warning : Plugin 'LuaDebugger' does not list plugin 'LuaPlugin' as a dependency, but module 'LuaDebugger' depends on 'LuaPluginRuntime'.

RootMotionMovementParams.lua.h(39): warning C4996: 'FRootMotionMovementParams::RootMotionTransform': RootMotionTransform should not be accessed directly, please use GetRootMotionTransform() to read it or one of the set/accumulate functions to modify it Please update your code to the new API before upgrading to the next release, otherwise your project will no longer compile.

4.18 Change to PreGarbageCollectDelegate for dev branch code

Just FYI since I tracked it down - in TableUtil.cpp a couple times FCoreObjectDelegates::PreGarbageCollectDelegate is used, but 4.18 has refactored that into FCoreUObjectDelegates::GetPreGarbageCollectDelegate()

Making that one change appears all that's necessary to fix build for 4.18.

Plays in editor with that change, though there is a problem with luahotupdate not finding files from HU.FileMap that I haven't tracked down yet. Looks like HU.FileMap just isn't being loaded with them at all

error in Call, No Exist such lua ins or ins has been released

void ASLGBuildingActor::BeginPlay()
{
Super::BeginPlay();
LuaCall("beginPlay", this);
}

function Call(functionName, inscpp, ...)
if type(inscpp) == "table" and not inscpp.has_destroy then
return inscpp[functionName](inscpp, ...)
else
dump(inscpp)
ensure(false, "error in Call, No Exist such lua ins or ins has been released")
end
end

lua.log:

[Thu Mar 8 22:06:29 2018] - }
[Thu Mar 8 22:06:29 2018] - "_gc_list" = {
[Thu Mar 8 22:06:29 2018] - userdata: 0000000089E33548 = true
[Thu Mar 8 22:06:29 2018] - }
[Thu Mar 8 22:06:29 2018] - "has_destroy" = true
[Thu Mar 8 22:06:29 2018] - "beginPlay" = function: 00000000850A2AE8
[Thu Mar 8 22:06:29 2018] - "initNameInfo" = function: 00000000850A2AC0
[Thu Mar 8 22:06:29 2018] - "m_HasBeginPlay" = true
[Thu Mar 8 22:06:29 2018] - "m_HasEndPlay" = true
[Thu Mar 8 22:06:29 2018] - }
...al/SteelOcean/Client_4.18/LuaSource/util\logutil.lua:57: error in Call, No Exist such lua ins or ins has been released...al/SteelOcean/Client_4.18/LuaSource/util\logutil.lua:57: error in Call, No Exist such lua ins or ins has been released
stack traceback:
[C]: in function 'error'
...al/SteelOcean/Client_4.18/LuaSource/util\logutil.lua:57: in function 'ensure'
E:/Unreal/SteelOcean/Client_4.18/LuaSource/main.lua:85: in function <E:/Unreal/SteelOcean/Client_4.18/LuaSource/main.lua:80>

the ASLGBuildingActor new and delete frequently。
please help

能解說一下您是怎麼讓處理與管理UE4與Lua的內存和垃圾回收機制嗎?

我也想弄一個UE4腳本😝。

但是面對UE4的GC物件機制我無從入手...因為虛擬機與UE4 NewObject的內存完全分離,兩邊都有自己的堆和根呀...如果我Lua那邊New了一個新物件,我應該讓Unreal回收還是Lua標記管理?如果C++那邊管了Lua的Object怎麼辦?

而且我覺得做多線程時,這尤其會有衝突...我覺得唯一的解決方法就是Lua虛擬機只可以執行純函數...

還有呢,怎麼樣處理Lua的組態?總不能每一個物件都配一個lua_State吧?如果我弄了1000個Entity這不就死得了...更何況這有機會造成內存洩漏...但是用全局Lua組態又不安全...有機會造成PIE崩潰和令某些物件不死...

BP我沒有怎麼看過,太複雜了。

另外我想問是怎麼樣實現Lua衍生的UObject反射?例如我在Lua弄了一個組函數我想把它反射出去然後在C++裏用UObject::FindFunction然後創建FFrame最後呼叫可以嗎?UE4的反射重建UHT太操蛋了...

順帶一提,我是想用TypeScript的。

bp call c++ bug?

I have a blueprint BP_ui which is inherit from my cpp class UBaseUserWiget,

`
UCLASS(BlueprintType, Blueprintable, meta = (lua = 1))
class CLIENT_API UBaseUserWiget : public UUserWidget
{
GENERATED_BODY()
public:
UBaseUserWiget(const FObjectInitializer& ObjectInitializer);
virtual ~UBaseUserWiget();

virtual void NativeConstruct();

public:
UFUNCTION(BlueprintCallable, BlueprintCosmetic)
void ActiveFunc();

UFUNCTION(BlueprintNativeEvent)
	UWidget* GetWidget(const int32& Id);
virtual UWidget* GetWidget_Implementation(const int32& Id);

};
`

`
void UBaseUserWiget::NativeConstruct()
{
Super::NativeConstruct();

LuaCtor("ui.baseuserwiget", this);	

}
`

situation 1,
I call "ActiveFunc" in the BP_ui.
on windows, that works well,
but on android, that does not work,

situation 2,
I override the method "GetWidget" in BP,
on windows, that works well,
but on android, that does not work,

ue4 version: 4.18.3

do you know how it happens?

please help, thank you

luacallr when the type of return value is struct, compile error

my struct:
USTRUCT()
struct FFormation
{
GENERATED_BODY()

FFormation()
{

}

// sort
UPROPERTY()
TArray<FBattleShip>	sortShipArr;

};

when compile at "luacallr(FFormation, ...."
it match
template
static T popinternal(lua_State L, int index, typename TEnableIf< TIsSame<typename traitstructclass::NotStructType, NotNeedTempInsType>::Value,T>::Type pp = nullptr )
{
return (T)ue_lua_tointeger(L, index);
};

please help

Crash when open level in 4.18.2

When I use Lua then OpenLevel will crash

Log:
[2018.04.18-07.15.20:940][419]LogBlueprintUserMessages: Late PlayInEditor Detection: Level '/Game/Map/Leide_HH/Leide_HH.Leide_HH:PersistentLevel' has LevelScriptBlueprint '/Game/Map/Leide_HH/Leide_HH.Leide_HH:PersistentLevel.Leide_HH' with GeneratedClass '/Game/Map/Leide_HH/Leide_HH.Leide_HH_C' with ClassGeneratedBy '/Game/Map/Leide_HH/Leide_HH.Leide_HH:PersistentLevel.Leide_HH'
[2018.04.18-07.15.22:678][469]LogNet: Browse: /Game/Map/HRTEST_MAP/bal02
[2018.04.18-07.15.22:679][469]LogLoad: LoadMap: /Game/Map/HRTEST_MAP/bal02
[2018.04.18-07.15.22:795][469]LogLoad: World /Game/Map/Leide_HH/UEDPIE_0_Leide_HH.Leide_HH not cleaned up by garbage collection!
[2018.04.18-07.15.22:795][469]LogReferenceChain: Searching referencers for Leide_HH. This may take several minutes.
[2018.04.18-07.15.23:156][469]LogReferenceChain: Generating reference graph ...
[2018.04.18-07.15.23:165][469]LogReferenceChain: Level 0 has 1 nodes ...
[2018.04.18-07.15.23:183][469]LogReferenceChain: Level 1 added 0 nodes ...
[2018.04.18-07.15.23:183][469]LogReferenceChain: Generating reference chains ...
[2018.04.18-07.15.23:183][469]LogReferenceChain:
[2018.04.18-07.15.23:183][469]LogReferenceChain: External Referencers:
[2018.04.18-07.15.23:183][469]LogReferenceChain:
[2018.04.18-07.15.24:319][469]LogReferenceChain: (root) GCObjectReferencer /Engine/Transient.GCObjectReferencer_0->0x00000000BF63F664 UE4Editor-CoreUObject-Win64-Debug.dll!UGCObjectReferencer::AddReferencedObjects() [f:\ff15project\client\engine\source\runtime\coreuobject\private\misc\gcobjectreferencer.cpp:19]
[2018.04.18-07.15.24:319][469]LogReferenceChain: (target) World /Game/Map/Leide_HH/UEDPIE_0_Leide_HH.Leide_HH
[2018.04.18-07.15.24:720][469]LogLoad: (Object is not currently rooted)

[2018.04.18-07.15.42:230][469]LogWindows: Windows GetLastError: 操作成功完成。 (0)
[2018.04.18-07.15.42:232][469]LogWindows: Error: === Critical error: ===
[2018.04.18-07.15.42:232][469]LogWindows: Error:
[2018.04.18-07.15.42:232][469]LogWindows: Error: Fatal error: [File:F:\FF15Project\client\Engine\Source\Editor\UnrealEd\Private\EditorEngine.cpp] [Line: 6717]
[2018.04.18-07.15.42:232][469]LogWindows: Error: World /Game/Map/Leide_HH/UEDPIE_0_Leide_HH.Leide_HH not cleaned up by garbage collection!
[2018.04.18-07.15.42:232][469]LogWindows: Error: (Object is not currently rooted)
[2018.04.18-07.15.42:232][469]LogWindows: Error:
[2018.04.18-07.15.42:232][469]LogWindows: Error:
[2018.04.18-07.15.42:232][469]LogWindows: Error:
[2018.04.18-07.15.42:232][469]LogWindows: Error:
[2018.04.18-07.15.42:254][469]LogExit: Executing StaticShutdownAfterError
[2018.04.18-07.15.42:257][469]LogWindows: FPlatformMisc::RequestExit(1)
[2018.04.18-07.15.42:257][469]Log file closed, 04/18/18 15:15:42

if I doesnt call lua everythingh is ok.
My UE4 version is 4.18.2
thank you

some kind of enum type can not be export

such as, in WidgetComponent.h
UENUM(BlueprintType)
enum class EWidgetSpace : uint8
{
/** The widget is rendered in the world as mesh, it can be occluded like any other mesh in the world. /
World,
/
* The widget is rendered in the screen, completely outside of the world, never occluded. */
Screen
};

protected:
/** The coordinate space in which to render the widget */
UPROPERTY(EditAnywhere, Category=UserInterface)
EWidgetSpace Space;

export: in WidgetComponent.script.h
static int32 UWidgetComponent_Set_Space(lua_State* L)
{
UWidgetComponent* Obj = (UWidgetComponent*)UTableUtil::tousertype("UWidgetComponent",1);
return 0;
}

~please help

引擎源码版本编译不过,折腾了很久,作者你有遇到过么

3>EXEC : error : Can't save a makefile that has invalid contents. See UBTMakefile.IsValidMakefile()
3> (see ..\Programs\UnrealBuildTool\Log_UHT.txt for full exception trace)
ERROR: Can't save a makefile that has invalid contents. See UBTMakefile.IsValidMakefile()

另外反射版本哪个链接打开提示404 找不到git地址

UE4.18 support

UAssetObjectProperty has been renamed to USoftObjectProperty

How to avoid GC objects that created in lua?

If i want to create a UObject, In C++, i need to AddRefrenceObject to avoid the GC, But in lua, if i create a UObject, where shound i put the AddRefrenceObject code to? How do you avoid the GC in your lua framework?

这个repository被重置了吗?怎么找不到我的版本

你好,我clone了当前的版本,发现我以前clone的代码怎么在当前的历史记录里找不到了,是github出问题了吗?都不知道以前的代码和今天clone的代码哪个比较新了。能帮我看看哪个是新版本吗?以前clone的Luautils.h文件是这样的:
// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "Kismet/BlueprintFunctionLibrary.h"
#include "UnrealLua.h"
#include "Luautils.generated.h"

USTRUCT()
struct LUAPLUGINRUNTIME_API FReplifetimeCond {
GENERATED_USTRUCT_BODY()

UPROPERTY()
FString PropertyName;

UPROPERTY()
TEnumAsByte<ELifetimeCondition> Cond;

};

UCLASS()
class LUAPLUGINRUNTIME_API ULuautils : public UBlueprintFunctionLibrary
{
GENERATED_BODY()

public:
UFUNCTION()
static UWorld* GetWorld1(AActor *obj);

UFUNCTION()
	static UWorld* GetActorWorld(AActor *obj);

UFUNCTION()
static void SetupAttachment(USceneComponent* Child, USceneComponent* InParent, FName InSocketName = NAME_None);

UFUNCTION(BlueprintCallable)
static void GetPlayerViewPoint(APlayerController* controler, FVector& out_Location, FRotator& out_Rotation);

UFUNCTION()
static FRotator GetViewRotation(APawn* pawn);

UFUNCTION()
static FVector VRandCone(FRandomStream stream, FVector const& Dir, float HorizontalConeHalfAngleRad, float VerticalConeHalfAngleRad);

UFUNCTION()
static FVector2D FVector2D_New(float InX =0, float InY =0);

UFUNCTION(BlueprintCallable, Category = "luautils")
static FColor FColor_New(uint8 InR = 0, uint8 InG = 0, uint8 InB = 0, uint8 InA = 255);

UFUNCTION()
static void GetAllWidgets(UUserWidget* UserWidget, UPARAM(ref)TArray<FName>& Names, UPARAM(ref)TArray<UWidget*>& Widgets, UPARAM(ref)TArray<FName>&TypesOfWidget);

UFUNCTION()
static void log(FString content);

UFUNCTION()
static FString GetName(UObject* p);

UFUNCTION()
	static void UpdateNav(UActorComponent *Component);

UFUNCTION()
	static void AddGCRef(UObject*p);

UFUNCTION()
	static UObject* GetPrivateClass(UObject *p);

UFUNCTION()
	static void CompareSpeed1(UObject*p);


static void CompareSpeed11() {};

UFUNCTION()
	static void CompareSpeed2(int i) {}

UFUNCTION()
	static void CompareSpeed3(int i, UObject* p) {}

static void call() {};

static void call1(int i) {};

static void call2(FVector& i) {};

static void call3(int i, float j, FString k) {};

static FVector call4() { static FVector i; return i; }

UFUNCTION()
	static void ucall(UObject*p) { delete p; };

UFUNCTION()
	static void ucall1(int i) {};

UFUNCTION()
	static void ucall2(FVector& i) {};

UFUNCTION()
	static void ucall3(int i, float j, FString k) {};

UFUNCTION()
	static FVector ucall4() { static FVector i; return i; }

UFUNCTION()
	static FString TestAlloc();

};

USTRUCT()
struct LUAPLUGINRUNTIME_API Flalala
{
GENERATED_BODY()

	UPROPERTY()
	int32 i;

};

struct CmpSpeed
{
static int32 TestTable(lua_State*inL)
{
lua_pushvalue(inL, lua_upvalueindex(1));
lua_pushvalue(inL, 2);
lua_rawget(inL, -2);
return 1;
}

static int32 TestTMap(lua_State*inL)
{
	void* p = (void*)lua_touserdata(inL, lua_upvalueindex(1));
	TMap<FName, void*>* Class = (TMap<FName, void*>*)(p);
	FName Key = lua_tostring(inL, 2);
	lua_pushlightuserdata(inL, *Class->Find(Key));
	return 1;
}

static int32 GetTwoFunc(lua_State*inL)
{
	lua_newtable(inL);
	void*p = reinterpret_cast<void*>(123);
	lua_pushlightuserdata(inL, p);
	lua_setfield(inL, -2, "longlongnamelala");
	lua_pushcclosure(inL, TestTable, 1);

	static TMap<FName, void*> Map;
	Map.Add(FName("longlongnamelala"), p);
	lua_pushlightuserdata(inL, &Map);
	lua_pushcclosure(inL, TestTMap, 1);

	return 2;
}

};

LUA_GLUE_BEGIN(CmpSpeed)
LUA_GLUE_FUNCTION(GetTwoFunc)
LUA_GLUE_END()

和现在github上的哪个新啊?

restartlevel lead to crash

enter console command "restartlevel", then the game crashed. Crash message
" World /Game/TestMap.TestMap not cleaned up by garbage collection! "

change level in play mode crash

Hi,
If I place a BP which Inherit from a C++ Actor in the editor, and the C++ Actor bind lua.
when I play, and change level by code, the engine crash,
because the level can't do Garbage collection.

If the C++ Actor don't bind lua, it is work well.

Please help.

当前最新版的一个bug?

UE4.21.2下 unreal.lua的master最新版貌似有一个bug:
如果一个StreamingLevel在一个PersistentLevel底下,这时该StreamingLevel里的ActorComponent调用自己的lua函数时会无法获取到GameInstance,从而导致LuaContext在每次调用lua函数时重新生成,从而无法成功执行lua函数。
需要把UnrealLuaInterface.cpp的477行代码:
UWorld* WorldBelong = Ins->GetTypedOuter();
改为:
UWorld *WorldBelong = GEngine->GetWorldFromContextObject(Ins, EGetWorldErrorMode::ReturnNull);

还有CppObjectBase.lua文件中的第35行:
self.OnEndPlay:Add(InsCallBack(self.EndPlay, self))
里的self.OnEndPlay是什么?我的脚本每次执行到这里就会出错,貌似没有这样的变量。我把这个文件中的三处OnEndPlay的位置删除掉才能正确执行。请问一下,我这样删除后有没有什么潜在的问题?

打包在真机运行的问题

你好,打包到真机上的时候,LuaSource应该是找不到的,所以main找不到会崩溃,看nativeluafunc.h里main应该是通过loadobject加载的,这块有需要额外设置什么吗?
我看了代码能想到的是把LuaSource放到Content目录下,然后在打包设置Additional Non-Asset Directories to Package里面加上LuaSource,然后在GetLuaCodeFromPath函数里从打包文件里读出来。这样应该是可以在真机打包里拿到。
但我不知道你的工程这里是不是已经有某种别的办法? 期待并感谢你的回答。

files broken

cannot download zip or clone repository. The files are broken. Is it a github issue? Is there anybody who can give a try?

UTableUtil::GetTempIns just can keep 10 ins,

UTableUtil::GetTempIns just can keep 10 ins, If lua ref C++ object, and in single functin or single class, it is very easy to over 10,
I need to new lua and copy ref C++ object to this new lua to avoid it, can any other way?

C++ call lua, param has struct, lua error

struct XX_API FRect2D
{
GENERATED_BODY()

UPROPERTY()
FVector2D origin;


UPROPERTY()
FVector2D size;

}

FRect2D test
FRect2D* pInfo = &test;
...
LuaCall("openInfoUI", this, *pInfo);

.lua

function openInfoUI(info)
local tmpOri = info:luaGet_origin()
local tmpX = info:luaGet_origin():luaGet_X()
end


error:
attempt to call method 'LuaGet_X' (a nil value)...


on lua debug,
the value of origin from "tmpOri" is wrong. the meta strcut of tmpOri is not FVector2D,which is FRect2D now.

please help,

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.