Adding Assets - brandonandzeus/Trainworks2 GitHub Wiki

If you wish to use custom assets other than static images in your plugin (sounds, animations, etc), then you need to create an AssetBundle to hold all of those custom assets that can be downloaded alongside your plugin. To create an AssetBundle from basic assets, follow the steps below.

  1. Install Unity 2018.4

  2. Import your assets into Unity by right clicking the asset folder and pressing Import. Alternatively, if you know how to make prefabs you can add them to the asset folder directly.

  3. Select an asset and go to the bottom right of the screen - there should be two dropdowns. Fill in the first dropdown with the desired name of your AssetBundle.

  4. Create a Unity Script and paste the code below into it:

public class AssetBundler : MonoBehaviour
{
    [MenuItem("Assets/Build AssetBundles")]
    static void BuildAllAssetBundles()
    {
        string assetBundleDirectory = "Assets/AssetBundles";
        if (!Directory.Exists(assetBundleDirectory))
        {
            Directory.CreateDirectory(assetBundleDirectory);
        }
        BuildPipeline.BuildAssetBundles(assetBundleDirectory,
                                        BuildAssetBundleOptions.None,
                                        BuildTarget.StandaloneWindows);
    }
}
  1. If you are ready to bundle, go to the asset drop down at the top of the screen and click the option that says Build AssetBundles

  2. Navigate to where your Unity Project assets are stored which is typically at C:\Users\YOURNAME\UNITYPROJECTNAME\Assets\AssetBundles

  3. Take out the file with the name of your AssetBundle, it should have the name of your AssetBundle and should not be a Meta File.

  4. Move that AssetBundle into your plugins folder.


To be completed with steps on using AssetBundles in your plugin.