Main Content

Install Support Package for Customizing Scenes

To customize scenes in the Unreal® Editor and use them in Simulink®, you must install the UAV Toolbox Interface for Unreal Engine® Projects.

Verify Software and Hardware Requirements

Before installing the support package, make sure that your environment meets the minimum software and hardware requirements described in Unreal Engine Simulation Environment Requirements and Limitations. In particular, verify that you have version 15.9 or higher of Visual Studio® 2017 installed. This software is required for using the Unreal Editor to customize scenes.

In addition, verify that your project is compatible with Unreal Engine, Version 4.23. If your project was created with an older version of the Unreal Editor, upgrade your project to version 4.23.

Install Support Package

To install the UAV Toolbox Interface for Unreal Engine Projects support package, follow these steps:

  1. On the MATLAB® Home tab, in the Environment section, select Add-Ons > Get Add-Ons.

  2. In the Add-On Explorer window, search for the UAV Toolbox Interface for Unreal Engine Projects support package. Click Install.

    Note

    You must have write permission for the installation folder.

Set Up Scene Customization Using Support Package

The UAV Toolbox Interface for Unreal Engine Projects support package includes these components:

  • An Unreal Engine project file (MathWorks_Aerospace.uproject) and its associated files. This project file includes editable versions of the prebuilt 3D scenes that you can select from the Scene source parameter of the Simulation 3D Scene Configuration block.

  • Two plugin files, MathWorkSimulation.uplugin and MathWorksUAV.uplugin. This plugin establishes the connection between Simulink and the Unreal Editor and is required for co-simulation.

To set up scene customization, you must copy this project and plugin onto your local machine.

Copy Project to Local Folder

Copy the mwas project folder into a folder on your local machine.

  1. Specify the path to the support package folder that contains the project. If you previously downloaded the support package, specify only the latest download path, as shown here. Also specify a local folder destination in which to copy the project. This code specifies a local folder of C:\Local.

    supportPackageFolder = fullfile( ...
        matlabshared.supportpkg.getSupportPackageRoot, ...
        "toolbox","uav","spkg","uavunrealengine");
    localFolder = "C:\Local";
  2. Copy the MathWorks_Aerospace project from the support package folder to the local destination folder.

    projectFolderName = "mwas";
    projectSupportPackageFolder = fullfile(supportPackageFolder,projectFolderName);
    projectLocalFolder = fullfile(localFolder,projectFolderName);
    if ~exist(projectLocalFolder,"dir")
        copyfile(projectSupportPackageFolder,projectLocalFolder);
    end

    The MathWorks_Aerospace.uproject file and all of its supporting files are now located in a folder named mwas within the specified local folder. For example: C:\Local\mwas.

Copy Plugin to Unreal Editor

Copy the MathWorksSimulation and MathWorksUAV plugins into the Plugins folder of your Unreal Engine installation.

  1. Specify the local folder containing your Unreal Engine installation. This code shows the default installation location for the editor on a Windows® machine.

    ueInstallFolder = "C:\Program Files\Epic Games\UE_4.23";
  2. Copy the plugins from the support package into the Plugins folder.

    supportPackageFolder = fullfile( ...
        matlabshared.supportpkg.getSupportPackageRoot, ...
        "toolbox","uav","spkg","uavunrealengine");
    
    mwSimPluginName = "MathWorksSimulation.uplugin";
    mwSimPluginFolder = fullfile(supportPackageFolder,"mwas_plugins","MathWorksSimulation");
    mwUAVPluginName = "MathWorksUAV.uplugin";
    mwUAVPluginFolder = fullfile(supportPackageFolder,"mwas_plugins","MathWorksUAV");
    
    uePluginFolder = fullfile(ueInstallFolder,"Engine","Plugins");
    uePluginDestination = fullfile(uePluginFolder,"Marketplace","MathWorks");
    
    cd(uePluginFolder)
    foundPlugins = [dir("**/" + mwSimPluginName) dir("**/" + mwUAVPluginName)];
    
    if ~isempty(foundPlugins)
        numPlugins = size(foundPlugins,1);
        msg2 = cell(1,numPlugins);
        pluginCell = struct2cell(foundPlugins);
    
        msg1 = "Plugin(s) already exist here:" + newline + newline;
        for n = 1:numPlugins
            msg2{n} = "    " + pluginCell{2,n} + newline;
        end
        msg3 = newline + "Please remove plugin folder(s) and try again.";
        msg  = msg1 + msg2 + msg3;
        warning(msg);
    else
        copyfile(mwSimPluginFolder, fullfile(uePluginDestination,"MathWorksSimulation"));
        disp("Successfully copied MathWorksSimulation plugin to UE4 engine plugins!")
        copyfile(mwUAVPluginFolder, fullfile(uePluginDestination,"MathWorksUAV"));
        disp("Successfully copied MathWorksUAV plugin to UE4 engine plugins!")    
    end

After you install and set up the support package, you can begin customizing scenes. See Customize Unreal Engine Scenes Using Simulink and Unreal Editor.