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
*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
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- "Draw Additional Lights Shadowmap" calls increase when custom MaterialBlockProperty is used
- Crash on _platform_memmove when importing the "Dragon Crashers - URP 2D Sample Project" to a new 2D project
- "Shader is not supported on this GPU" warnings and and shaders are not loading when building the project for non-Chromium browsers
- [iOS][URP] The screen flickers and the "Execution of the command buffer was aborted due to an error during execution" error is thrown continuously
- Shortcut Manager shows empty conflict filter when resolving runtime conflicts involving different contexts
Resolution Note:
PR: https://github.cds.internal.unity3d.com/unity/com.unity.visualscripting/pull/506