Comments (4)
from sluaunreal.
谢谢大佬的回复!
是大佬截图的地方报的错,堆栈信息涉及一些商业隐私,不太方便截上来,我完整的描述一下我的情景:
我用的版本是:sluaunreal-2.1.2
我想要定义一个UStruct结构体FPlayerData,从C++传递(const TArray&)到Lua中,想在lua中访问从C++传递过来的FPlayerData数组
1.定义FPlayerData
USTRUCT(BlueprintType)
struct FPlayerData
{
GENERATED_BODY()
public:
UPROPERTY()
FString PlayerName;
UPROPERTY()
FString PlayerId;
};
namespace NS_SLUA
{
DefTypeName(FPlayerData);
DefDeduceType(FPlayerData, Struct);
}
2.定义一个PlayerController,提供一个服务端调用客户端执行的RPC函数
UCLASS()
class UNREALPROJ_API AXXXPlayerController : public APlayerController
{
//调用Lua代码
template<class ...ARGS>
void CallLuaFunc(const char* FuncName, ARGS&& ...args);
//将数据同步到客户端
UFUNCTION(Client, Reliable, Category = "XXXX")
void ClientUpdatePlayer(const TArray<FPlayerData>& PlayerDatas);
}
void AXXXPlayerController::ClientUpdatePlayer_Implementation(const TArray& PlayerDatas)
{
CallLuaFunc("UpdatePlayer", PlayerDatas);
}
template<class ...ARGS>
void AXXXPlayerController::CallLuaFunc(const char* FuncName, ARGS && ...args)
{
auto LuaWidget = Cast(HUDWidget);
if (LuaWidget)
{
auto Self = LuaWidget->GetSelfTable();
if (Self.isValid()) Self.callField(FuncName, Self, std::forward(args)...);
}
}
代码调用过程:
在Server端通过ClientUpdatePlayer将const TArray& PlayerDatas传递到ClientClientUpdatePlayer_Implementation
最终将PlayerDatas通过callField方法传递到了Lua的UpdatePlayer方法中
发现在Lua中无法使用PlayerDatas数据,并且报上面的错误日志
请问一下,应该如何正确的传递自定义的USTRUCT并通过const TArray& 传递到lua层?
from sluaunreal.
OK,我明天抽空构造一下现场看看
from sluaunreal.
OK,我明天抽空构造一下现场看看
好的,谢谢大佬
from sluaunreal.
Related Issues (20)
- 请问支持ue5.2及5.3吗? HOT 6
- sluaunreal-2.1.2 中 MyGameInstance.h 导致编译报错 HOT 2
- ue5.2 编译报错 HOT 1
- tag2.1.2 http c++绑定不能用了 HOT 2
- DefLuaMethod 导出类方法编译失败 HOT 4
- vscode luapanda lua 代码辅助功能打开没有填写Cpp文件夹路径的选项 HOT 1
- C++调用callByUFunction 有异常崩溃 HOT 1
- cppbinding问题 HOT 2
- REG_EXTENSION_PROPERTY 使用无效 HOT 4
- Tick函数不会调用 HOT 1
- 小白问一个C++使用LuaFunction的问题 HOT 1
- lua中的self.bCanEverTick似乎不起作用?(真正用法是怎样的?) HOT 2
- 当在同一进程开启多个游戏时(即设置Number of Player >=2),为什么lua代码只执行一次? HOT 2
- LuaArray中inner变量被销毁后,AddReferencedObjects访问inner野指针崩溃的问题 HOT 9
- 大大们,问一个小白的问题 HOT 1
- 打包slua,老报SafeDelete错误 HOT 2
- Undefined symbols for architecture arm64 HOT 7
- Undefined symbols for architecture arm64
- slua插件对mod加载以及Gamefeature的支持 HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sluaunreal.