输出资源引用到的资源或者依赖的资源:
1. 核心API
unreal.AssetRegistryHelpers
unreal.AssetRegistry
2.使用方法
import unreal
asset_reg = unreal.AssetRegistryHelpers.get_asset_registry() #注册一个asset
print asset_reg.get_referencers('/Game/....', unreal.AssetRegistryDependencyOptions(True, True)) #输出引用者
print asset_reg.get_dependencies('/Game/....', unreal.AssetRegistryDependencyOptions(True, True))# 输出依赖的资源
路径为Package Path 不是Local Path
编辑器打开Window->Output Log
命令行换为Python
按行输入代码即可
3.输出整个文件夹下所有资源的引用/依赖
需要加一个读文件下资源的函数,然后用1中几行脚本输出
import re
import sys
import os
#Local Path 转为 Package Path,用于get_referencers函数输入
#如果直接输入Package Path 可不要此函数
def ConvertLocalPath2PackagePath(asset_path):
flag = 'Content'
package_path_with_suffix = re.sub('\\\\','/',asset_path)
package_path_with_suffix = re.sub(r'^.*?Content', "/Game", package_path_with_suffix)
package_path = re.sub(r'\..*$','',package_path_with_suffix)
return package_path
def Get_FileList(filepath):
asset_in_file = []
for dirpath,dirnames,filenames in os.walk(filepath):
for i in range(len(filenames)):
filenames[i] = ConvertLocalPath2PackagePath(dirpath + '/' + filenames[i])
asset_in_file.append(filenames[i])
# print('asset_in_file : \n')
# print(asset_in_file)
return asset_in_file
如何跑py文件官方文档里有