Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
This question was closed Feb 07, 2017 at 06:19 PM by timchamill for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by timchamill · Feb 06, 2017 at 08:20 AM · c#scripting problemeditoreditor-scripting

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.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

  • Sort: 
avatar image
0

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.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Follow this Question

Answers Answers and Comments

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

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

Script works in Game View, but not in build 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges