赞
踩
意义:通过Python设置UE对象的值的示例,可以举一反三的获取或设置任意对象的任意值。
参照 UE5中使用Cesium for Unreal(一)1 创建项目。
大致过程:获取场景中的 Actor 对象,然后找到要设置的值,设置值,部分值需要调用更新方法。
# 获取 cesium for unreal 中的 Actor 的默认值 import unreal class CesiumForUnrealLibrary(object): ''' 获取Actor ''' def getActor(self, name): actors = self.getEditor().get_all_level_actors() for actor in actors: if name in actor.get_name(): return actor return None ''' 获取当前编辑器中的世界 ''' def getEditor(self): return unreal.get_editor_subsystem(unreal.EditorActorSubsystem) ''' 打印对象有哪些函数 ''' def Show(self, obj): help(obj) print('-------- 函数列表 functions -----------') [print(func) for func in dir(obj) if callable(getattr(obj, func)) and not func.startswith("__")] print('-------- 属性信息 properties -----------') [print(prop) for prop in dir(obj) if not callable(getattr(obj, prop)) and not prop.startswith("__")] print('-------- 方法和入参和返回值等信息 -----------') MyLib = CesiumForUnrealLibrary() # 1.替换坐标系到模型的中心点 myactor = MyLib.getActor('CesiumGeoreference') vec = myactor.get_georeference_origin_longitude_latitude_height() vec.x = 106.502765 vec.y = 29.613348 vec.z = 300 myactor.set_georeference_origin_longitude_latitude_height(vec) print( myactor.get_georeference_origin_longitude_latitude_height() ) # 2.设置太阳的时区 myactor = MyLib.getActor('CesiumSunSky') myactor.solar_time = 6.0 myactor.update_sun() # MyLib.Show(myactor) # print( myactor.solar_time )
粘贴 Python 文件路径到 Python 控制台中执行,即可实时看到效果。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。