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
- Crash on ShaderLab::ShaderState::ApplyShaderState when entering Play Mode and calling ShaderWarmup.WarmupShaderFromCollection with a shader that has dynamic_branch
- Crash on operator delete[] when a serializable structure in the System namespace is serialized by a MonoBehaviour
- [macOS] forward and backward mouse buttons are recognized as middle mouse button
- NavMeshModifier.OnEnable/OnDisable gets progressively slower when called repeatedly
- "System.Net.CookieContainer" throws an "ArgumentException" error when using a non-UTF-8 machine locale and hostname
Resolution Note:
PR: https://github.cds.internal.unity3d.com/unity/com.unity.visualscripting/pull/506