【发布时间】:2022-07-13 01:39:15
【问题描述】:
我找不到使用 python 脚本将材质分配给 CachedGemotry 的方法。
在 staticGeometry 上,我可以使用“.set_material”来实现,但 CachedGeometry 上不存在该功能。
你有解决办法吗?
谢谢!
【问题讨论】:
标签: python unreal-engine4 unreal-blueprint unrealscript
我找不到使用 python 脚本将材质分配给 CachedGemotry 的方法。
在 staticGeometry 上,我可以使用“.set_material”来实现,但 CachedGeometry 上不存在该功能。
你有解决办法吗?
谢谢!
【问题讨论】:
标签: python unreal-engine4 unreal-blueprint unrealscript
当您谈论 CachedGeometry 时,我假设您的意思是 GeometryCache,还是我弄错了?
假设我不是(如果我是的话,请道歉)那么您应该能够通过修改 GeometryCache 对象上的“材料”属性来做到这一点。
import unreal
# Gets Pre-existing objects
cached_geo_asset = unreal.load_asset(‘<GEO_CACHE_PATH>’)
mat_asset = unreal.load_asset(‘<MATERIAL_PATH’)
# Display materials before update.
print(‘Before’)
mats = cached_geo_asset.get_editor_property('materials')
print(mats)
# Override the existing materials to use only the one loaded
# above.
cached_geo_asset.set_editor_property('materials', [mat_asset])
# Display materials after update.
print(‘After’)
mats = cached_geo_asset.get_editor_property('materials')
print(mats)
我希望这会有所帮助!我没有经常使用 GeometryCache,所以我很想知道这个解决方案是否适合你。
【讨论】: