20tab / UnrealEnginePython

Embed Python in Unreal Engine 4
MIT License
2.76k stars 750 forks source link

UE4.20 struct import have issue when open unreal engine editor again #499

Open bianchengxiaosheng opened 6 years ago

bianchengxiaosheng commented 6 years ago

HI: I create a struct in content,and i use it in python script ,and run it OK. Fllow the problem will have. I run the same python script will have a problem when I close the unreal engine and open the unreal engin again. Fllow describe: "LogPython: Error: cannot import name 'TestStruct' LogPython: Error: Traceback (most recent call last): LogPython: Error: File "E:/CM/UE_V420/SHChongMing/Content/Scripts\GetStructTest.py", line 2, in from unreal_engine.structs import TestStruct "

rdeioris commented 6 years ago

Hi it looks like your struct asset is not loaded. Before importing it just use ue.load_object or ue.load_package

bianchengxiaosheng commented 6 years ago

I use the same script in unreal 4.17 is ok,but when I upgrade the engine to 4.20,the problem will have. the readme document describe that i just create struct in content folder,and i can use the struct in python script

rdeioris commented 6 years ago

In 4.20 lot of stuff changed. You need to adapt to those changes. But technically you should explicitely load non-native classes.

soTaddel commented 5 years ago

Hi rdeioris,

can you specify how to change it? We got the same issue (but only when running the packaged game). How to exactly load the struct before importing? Sorry for the noobish question.