Editor scripts problem

Hey there.
Currently I work in Unity 5.6.0f3(can anyone having 5.6.1+ check if they have this issue?) and have a following issue: MenuItem does not work in editor scripts when opening a project with a compilation error in a runtime script.

Here’s how to reproduce this:
Completely empty project, where there are only 2 files(code in the end of the message).

  1. An editor script(that definetely compiles just fine on its own):
    Path: “Assets/Plugins/Editor/UnityCodeGenerator.cs”
    (tried puttin it into “Assets/Editor”, “Assets/Standard Assets/Editor”, etc - nothing worked)

a runtime script I made a compilation error in:
“Assets/BrokenScript.cs”

If I open this project, there is no “Entitas” menu item in the top menu. If I fix a compilation error in BrokenScript it appears and further runtime compilation errors do not make it disappear. Making a compilation error in a runtime script and relaunching the project does though, which is a big issue for me at the moment.

Code:

using System;
using System.Linq;
using UnityEditor;
using UnityEngine;

namespace Entitas.CodeGeneration.Unity.Editor
{

public static class UnityCodeGenerator
{

[MenuItem(“Tools/Entitas/Generate #%g”, false, 100)]
public static void Generate()
{
Debug.LogError(“TEST”);
}
}
}

using UnityEngine;

public class BrokenScript : MonoBehaviour {

void Start () {
weq
}
}

Hi,

Take a look at “Special folders and script compilation order” Unity - Manual: Special folders and script compilation order

Afaik, as Editor scripts depend on your code they won’t compile if there are compilation errors and those sources are not loaded. Therefore no menu items will show up.

Entitas fixed this in versino 0.41.0 by precompiling those sources to dlls which can be loaded even if there are compilation errors.

Taken from the release notes of Entitas 0.41.0

  • Deploying Entitas as Dlls instead of source code which has multiple benefits, e.g.

  • Entitas Unity menu appears even if code doesn’t compile

  • Enables 3rd party Addons and Plugins

  • Enables command line code generator

I hope that helps!