unity building assets + menuitems

While lookng at the api for Unity I found this nifty api that allows you to create your custom MenuItem in the Unity Interface.

You will need to decorate your script method with the menuitem as such defined in the api. Here is an example of its implementation in .cs:

using UnityEditor;
using UnityEngine;
public class MenuTest : MonoBehaviour
 // Add a menu item named "Do Something" to MyMenu in the menu bar.
    [MenuItem("MyMenu/Do Something")]
    static void DoSomething()
        Debug.Log("Doing Something...");

Here is the code for building your assets into bundles that can be loaded in the future rather at start of the application. So during run time you can initiate a method to call the loadasset bundles in the folder you’ve defined.

    [MenuItem("Example/Build Asset Bundles")]
    static void BuildABs()
        // Put the bundles in a folder called "ABs" within the Assets folder.
        BuildPipeline.BuildAssetBundles("Assets/ABs", BuildAssetBundleOptions.None, BuildTarget.StandaloneWindows);

And finally you can Load the assets using LoadAssets() and list them out using the AssetBundle.GetAllAssetBundles

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.