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.
-
Install Unity 2018.4
-
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.
-
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.
-
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);
}
}
-
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
-
Navigate to where your Unity Project assets are stored which is typically at
C:\Users\YOURNAME\UNITYPROJECTNAME\Assets\AssetBundles
-
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.
-
Move that AssetBundle into your plugins folder.
To be completed with steps on using AssetBundles in your plugin.