【UE4】为FBX赋予材质
import unreal
import os
unreal_fbx_path='/Engine/BasicShapes/Plane'
destination_path='/Game/Mesh'
location=(0,0,0)
rotation=(90,0,0)
texture_name="/Game/Textures/Dog"
mat_inst_path='/Game/MaterialsMI/MI'
def assignMatToFbx(location,rotation):
if not unreal.EditorAssetLibrary.does_directory_exist(destination_path):
unreal.EditorAssetLibrary.make_directory(destination_path)
unreal.EditorAssetLibrary.duplicate_asset(unreal_fbx_path,destination_path+'/Ms')
fbx_obj = unreal.EditorAssetLibrary.load_asset(destination_path+'/Ms')
fbx_asset_data = unreal.EditorAssetLibrary.find_asset_data(destination_path+'/Ms')
mat_inst_obj = unreal.load_object(None, mat_inst_path)
fbx_asset = fbx_asset_data.get_asset()
fbx_asset.set_material(0, mat_inst_obj)
unreal.EditorLevelLibrary.spawn_actor_from_object(fbx_obj, location, rotation)
assignMatToFbx(location,rotation)
|