20tab / UnrealEnginePython

Embed Python in Unreal Engine 4
MIT License
2.75k stars 747 forks source link

I want to write data into a variable in editor #510

Open DragonRoared opened 6 years ago

DragonRoared commented 6 years ago

I want to write data into a variable in editor, here is my code

import unreal_engine as ue
from unreal_engine import FVector
from osmread import parse_file, Way,Node
import PyGIS

selectClass=ue.editor_get_selected_actors()[0] # WayPointList

selectClass.call('InputData')
selectClass.set_property('oneList',[FVector(0,0,0),FVector(1,1,1),FVector(2,2,2)])
selectClass.save_package()
selectClass.call('InputData')

function ‘InputData’ is a print list lenght

this is my output log

LogPython: 0
LogSavePackage: Save=510.14ms
LogSavePackage: Moving '../../../../../../Project/Unreal Engine 4 Project/SZ_PoliceStation/Saved/SZ_PoliceStation4FB4532C458E440DEE1081BE366915A6.tmp' to '../../../../../../Project/Unreal Engine 4 Project/SZ_PoliceStation/Content/Map/SZ_PoliceStation.uasset'
LogSavePackage: Display: Finished SavePackage ../../../../../../Project/Unreal Engine 4 Project/SZ_PoliceStation/Content/Map/SZ_PoliceStation.uasset
LogPython: 3
LogSlate: FSceneViewport::OnFocusLost() reason 0

but the editor doesn't change anything.

image

What should I do?thank you

rdeioris commented 6 years ago

Hi, call post_edit_change()

DragonRoared commented 6 years ago

sorry,I change my code ,but nothing has changed. this is my code

import unreal_engine as ue
from unreal_engine import FVector
from osmread import parse_file, Way,Node
import PyGIS

selectClass=ue.editor_get_selected_actors()[0] # WayPointList

print(len(selectClass.oneList))
selectClass.set_property('oneList',[FVector(0,0,0),FVector(1,1,1),FVector(2,2,2)])
selectClass.post_edit_change()

print(len(selectClass.oneList))

this is my editor setting image and output image

I tried function ‘post_edit_change’ ‘post_edit_change_property’ ‘pre_edit_change’ ,all not resolved , I use the latest version plugins,UE4 is 4.19 ,thank you

rdeioris commented 6 years ago

Hi, i think it is not clear what kind of value you want to show. By changing an actor you are changing the values of that istance. If you want to change the default values of a class/blueprint you need to change it GeneratedClass