Skip to content

[Bug] v1.3.6 fails to compile on Unity 2022.3 — CS1520 in OCProgressBar.cs #107

@cramuelaz

Description

@cramuelaz

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: <--------

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions