Search Issue Tracker

Fixed

Votes

0

Found in [Package]

1.7.5

1.7.6

Issue ID

UVSB-2029

Regression

No

Additional editor assemblies are not detected correctly

Package: Visual Scripting

-

*Reproducible on:*
* VS version: 1.7.6
* Unity version: 2021.2.2f1

*Case 1:*
*Note:* This bug came from the forum: https://forum.unity.com/threads/additional-editor-assemblies-are-not-detected-correctly.1197328/

If my editor assembly (created using an assembly definition) is not one of the special names Assembly-CSharp-Editor or Assembly-CSharp-Editor-firstpass, I have to have an [assembly: AssemblyIsEditorAssembly] somewhere in it. But when I do that, watch what happens in the function above: _editorAssemblyCache.TryGetValue returns false and sets isEditor to default (false), then Attribute.IsDefined returns true, and a key value pair of (assembly, false) is added to _editorAssemblyCache. Thereafter, _editorAssemblyCache keeps serving the wrong false value.

* Consider this function in Codebase.cs (package version 1.7.6):
{code:java}
Code (CSharp):
private static bool IsEditorAssembly(Assembly assembly)
{
// assembly.GetName() is surprisingly expensive, keep a cache
if (_editorAssemblyCache.TryGetValue(assembly, out var isEditor))
return isEditor;
if (Attribute.IsDefined(assembly, typeof(AssemblyIsEditorAssembly)))
{
_editorAssemblyCache.Add(assembly, isEditor); // <== isEditor is always false!
return true;
}

var isEditorAssembly = IsEditorAssembly(assembly.GetName());
_editorAssemblyCache.Add(assembly, isEditorAssembly);
return isEditorAssembly;
}
{code}

* Workaround from the user: make sure your editor assembly uses something from UnityEditor.CoreModule, for example:

{code:java}
Code (CSharp):
internal class DummyEditorDependency : UnityEditor.Editor { }
{code}

*Case 2:*

Small bug in Codebase.IsEditorAssembly() (1.7.5, also 1.7.6): l.330 _editorAssemblyCache.Add(assembly, isEditor); should be _editorAssemblyCache.Add(assembly, true); At the moment it's not possible to add visual scripting editor extensions in separate Assemblies because of this. (edited)

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.