/
vasandi
/
AirSimGeorefWorld
Обзор
Документация
Войти
/
vasandi
/
AirSimGeorefWorld
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
apply_texture.py
87 строк
3 KB
Андрей Васильченко
добавлен мир Москва
08 июл 2026, 13:02
08 июл 2026, 13:02
d82816d
Код
Авторство
О чём код?
import unreal import os log = unreal.log def main(): log("[MoscowWorld] Создание материала ландшафта с текстурой...") # 1. Создаём материал mat_tools = unreal.MaterialEditingLibrary editor_util = unreal.EditorAssetLibrary mat_path = "/Game/Materials/M_Landscape_Moscow" # Проверяем, существует ли уже if editor_util.does_asset_exist(mat_path): log("Материал уже существует: " + mat_path) else: asset_tools = unreal.AssetToolsHelpers.get_asset_tools() asset_data = asset_tools.create_asset( "M_Landscape_Moscow", "/Game/Materials", unreal.Material, None ) log("Материал создан: " + mat_path) # 2. Добавляем текстуру texture_path = "/Game/Textures/moscow_mapnik_z15" texture = editor_util.load_asset(texture_path) if texture is None: log("ОШИБКА: Текстура не найдена: " + texture_path) return log("Текстура найдена: " + texture.get_name() + " (" + str(texture.blueprint_get_size_x()) + "x" + str(texture.blueprint_get_size_y()) + ")") material = editor_util.load_asset(mat_path) if material is None: log("ОШИБКА: Материал не найден: " + mat_path) return # 3. Создаём Texture Sample Expression mat_expr = unreal.MaterialEditingLibrary.create_material_expression( material, unreal.MaterialExpressionTextureSample, 200, 0 # x, y position in material editor ) if mat_expr: mat_expr.set_editor_property("texture", texture) log("Texture Sample создан и привязан к текстуре") # 4. Подключаем к Base Color unreal.MaterialEditingLibrary.connect_material_property( mat_expr, "RGB", # RGB output name unreal.MaterialProperty.MP_BASE_COLOR ) log("Подключено к Base Color") # 5. Сохраняем editor_util.save_asset(mat_path) log("Материал сохранён: " + mat_path) # 6. Назначаем ландшафту actors = unreal.EditorLevelLibrary.get_all_level_actors() landscapes = [a for a in actors if a.get_class().get_name() == 'Landscape'] if landscapes: landscape = landscapes[0] log("Найден ландшафт: " + landscape.get_actor_label() + " (" + landscape.get_class().get_name() + ")") landscape.set_material(0, material) log("Материал назначен на ландшафт") else: log("Ландшафт не найден. Все акторы:") for a in actors[:20]: log(" " + a.get_class().get_name() + ": " + a.get_actor_label()) # 7. Сохраняем уровень unreal.EditorLevelLibrary.save_current_level() log("Уровень сохранён") log("[MoscowWorld] Готово! Материал с текстурой Москвы назначен на ландшафт") main()