Getting errors from BuildPipeline.BuildAssetBundles but not when building game...

I have looked at a number of threads about errors between editor and production builds related to AssetBundles:
They do not seem to relate to the issue I am having. I can do in editor builds of the game for Android, iOS, and WebGL and they run in the editor.

But, when I call the BuildPipeline.BuildAssetBundles API the Photon 3rd party library gives a bunch of errors like this one:

Yet the code looks very straight forward:

using UnityEditor;
using UnityEngine;

public class ChatEditor : EditorWindow

It is the class declaration is line 21 that is showing the error.

It seems like maybe there is some compiler defines set that are different when the BuildPipeline.BuildAssetBundles is called as compared to what is set during editor builds?

Any ideas? It is a major stumbling block for me right now.

There is an update to the Photon Library that I am going to pull in next but I don’t have a lot of confidence that will fix it. The current code that is showing the error looks pretty good.


It’s a crappy solution, but you need to wrap any classes giving you that error in

using Foo;

public class Bar
    // code here

I’m not entirely sure why, but the BuildAssetBundles() function wants to build stuff inside Editor folders as if they’re supposed to run in the game.