Here’s an easy bug to replicate (though I’ve uploaded the project anyway through Bug Reporter) - simply create an empty Unity 6 project, add the Localization package, and try to build a Windows player.
You’ll receive a series of UIToolkit Code Generation errors like this:
Various code generation complaints about ‘RegisterUxmlCacheAttribute’ and ‘RegisterUxmlCacheAttributeAttribute’, I assume those are new parts of the UIToolkit in Unity 6.
Is the Localization package not compatible with Unity 6 yet? I’d be surprised if I’m the only one who has discovered this?
The package definitely works with Unity 6.
These errors look like they may be related to a UI toolkit change that landed recently. Changes were made to the code generator, this looks like something is going wrong with the UxmlObjects. We will investigate…
Edit:
We have not been able to reproduce this issue. We will wait and see if QA have any luck.
Unity QA also say they can’t reproduce the issue, so I’m a bit stuck.
I’ve tried building my reproduction project in 6000.0.25f1 and I can build fine, but switching the project back to 6000.0.30f1 I see all the Uxml errors again when I build.
Any advice for narrowing this down?
I guess I can download the versions between .25f1 and .30f1 to find exactly where this error appears?
Does this happen when you switch a project from .25 to .30 only? If you create a new project in .30 does it still happen?
If you delete the library folder and reopen the project does the error go away?
The reproduction project I uploaded was a brand new project created in .30, and not one that was created in .25.
I did try deleting the Library folder before posting the thread, didn’t help.
I’ve just tried opening my reproduction project in .29 and building succeeds, it’s totally fine. So I guess we can just keep our main game project on .29 for now.
Happy to try anything else if something comes to mind for narrowing it down, or perhaps other people will chime in if it’s an issue outside of my Unity .30 install.
Something did land in .30 that would be related to what you posted. I was also not able to repro this using a new project with the com.unity.localization package or using the project you provided in the bug report.
The additional code that is generated on my side looks like this for LocalizedString:
[global::UnityEngine.UIElements.RegisterUxmlCacheAttribute]
[global::System.Diagnostics.Conditional("UNITY_EDITOR")]
public new static void Register()
{
global::UnityEngine.UIElements.UxmlDescriptionCache.RegisterType(typeof(UxmlSerializedData), new global::UnityEngine.UIElements.UxmlAttributeNames[]
{
new (nameof(LocalVariablesUXML), "variables", null, global::System.Array.Empty<string>()),
}
);
}
Can you check if you get something similar?
Thanks!
So what I did for this one is, using Rider, I opened up LocalizedString.databinding.cs and then I right-clicked > Find usages on LocalizedString.LocalVariablesUXML and on an empty project, I believe only the generated code will use it, so it should bring you to it and the code I pasted above should be at the top of the file.
Those ifdefs should already be active in Unity 6.
Did that fix the errors? It shouldn’t make a difference. You wouldn’t be getting the errors if the code wasn’t used, that code is triggering the code generator which for some reason is producing those errors for you.
Visual studio isn’t aware of the generated code at the moment so shows it as zero references, rider is a little ahead and does detect the generated code.
We added some additional generated code since I wrote that blog post, that new code is what the errors are pointing towards but it’s very strange that it’s only happening for you. There must be something different about your setup…
Anyway, I suppose we’ll just wait to see if anyone else encounters the error, or if a brand new Unity Editor install of a future 0.31 will clear things up.