Description
Package version 1.3.6 does not compile on Unity 2022.3 (tested on 2022.3.46f1), even though package.json declares "unity": "2022.3" as the minimum supported version.
The compilation errors come from Editor/Scripts/VisualElements/OCProgressBar.cs.
Environment
- Unity version: 2022.3.46f1
- Package: com.open-commissioning.core
- Package version: 1.3.6
- OS: Windows
Errors
Library\PackageCache\com.open-commissioning.core@\Editor\Scripts\VisualElements\OCProgressBar.cs(119,16): error CS1520: Method must have a return type
Library\PackageCache\com.open-commissioning.core@\Editor\Scripts\VisualElements\OCProgressBar.cs(121,16): error CS1520: Method must have a return type
Root cause
In OCProgressBar.cs, the class name differs between the two preprocessor branches:
- Inside
#if UNITY_6000_3_OR_NEWER → class is declared as OCProgressBar
- Inside
#else → class is declared as ProgressBar
However, the constructors at the bottom of the file are always named OCProgressBar:
public OCProgressBar() : this(""){}
public OCProgressBar(string title)
{
...
}
When Unity 2022.3 compiles the #else branch, the class is ProgressBar but the constructors are OCProgressBar, so the compiler interprets them as methods with no return type → CS1520.
The UxmlFactory and Init method inside the #else branch also still reference ProgressBar instead of OCProgressBar.
Suggested fix
In the #else branch, rename the class and its internal references to OCProgressBar:
public class OCProgressBar : UnityEngine.UIElements.ProgressBar
{
public new class UxmlFactory : UxmlFactory<OCProgressBar, UxmlTraits> { }
public new class UxmlTraits : UnityEngine.UIElements.ProgressBar.UxmlTraits
{
...
public override void Init(VisualElement ve, IUxmlAttributes bag, CreationContext cc)
{
base.Init(ve, bag, cc);
if (ve is not OCProgressBar progressBar) return;
...
}
}
}
Workaround
---> Downgrading to version 1.2.10 works correctly on Unity 2022.3: <--------
Description
Package version 1.3.6 does not compile on Unity 2022.3 (tested on 2022.3.46f1), even though
package.jsondeclares"unity": "2022.3"as the minimum supported version.The compilation errors come from
Editor/Scripts/VisualElements/OCProgressBar.cs.Environment
Errors
Library\PackageCache\com.open-commissioning.core@\Editor\Scripts\VisualElements\OCProgressBar.cs(119,16): error CS1520: Method must have a return type
Library\PackageCache\com.open-commissioning.core@\Editor\Scripts\VisualElements\OCProgressBar.cs(121,16): error CS1520: Method must have a return type
Root cause
In
OCProgressBar.cs, the class name differs between the two preprocessor branches:#if UNITY_6000_3_OR_NEWER→ class is declared asOCProgressBar#else→ class is declared asProgressBarHowever, the constructors at the bottom of the file are always named
OCProgressBar:When Unity 2022.3 compiles the
#elsebranch, the class isProgressBarbut the constructors areOCProgressBar, so the compiler interprets them as methods with no return type → CS1520.The
UxmlFactoryandInitmethod inside the#elsebranch also still referenceProgressBarinstead ofOCProgressBar.Suggested fix
In the
#elsebranch, rename the class and its internal references toOCProgressBar:Workaround
---> Downgrading to version 1.2.10 works correctly on Unity 2022.3: <--------