- Home /
The question is answered, right answer was accepted
How do I solve a BuildAssetBundles Compilation Error that only occurs in the Editor?
Greetings,
I'm running Unity 5.5.0f3 personal on Windows 10, 64 bit, and I'm trying to build an AssetBundle for a simple project. Here's the script I derived from the BuildPipeline BuildAssetBundles documentation:
using UnityEngine;
using UnityEditor;
/// <summary>
/// Builds the asset bundle
/// Code below is based on the Unity Scripting Reference documentation for the
/// BuildPipeline BuildAssetBundles method
/// </summary>
public class BuildAssetBundle : MonoBehaviour {
/// <summary>
/// Adds a menu item to build the asset bundle
/// </summary>
[MenuItem("Asset Bundle/Build Asset Bundle")]
static void BuildAB() {
// Put the bundle in a folder called "AssetBundle"
BuildPipeline.BuildAssetBundles("Assets/AssetBundle",
BuildAssetBundleOptions.None,
BuildTarget.StandaloneWindows);
}
}
This code compiles fine in Visual Studio with no errors (and I've confirmed there's an assembly reference to the UnityEditor dll in the Visual Studio project).
When I select Asset Bundle > Build Asset Bundle from the menu bar in the Unity editor, I get error messages in the Console pane that say
The type or namespace name `UnityEditor' could not be found. Are you missing an assembly reference?
Error building Player because scripts had compiler errors
Any ideas how I can fix this so I can build my Asset Bundle in the editor?
Thanks in advance for any suggestions.
Answer by timchamill · Feb 07, 2017 at 06:40 PM
I'm a n00b. This was my first editor script and I didn't realize that editor scripts have to live in a special Editor folder. The problem is resolved.
Follow this Question
Related Questions
Confused about custom GameObjects,Custom GameObject confusion 0 Answers
myObjetc..GetType().GetCustomAttributes(typeof(RequireComponent) not working correctly 1 Answer
Get callback when assets loading or deserialization finished? 1 Answer
Bind to OnWillSaveAssets and force to save my scene 0 Answers