Skip to content

CS0246: FileBrowserEditor not found when compiling on Linux/macOS editor #111

@cramuelaz

Description

@cramuelaz

Environment

  • Unity 2022.3.43f1
  • OS: Ubuntu (also applies to macOS editor)
  • Package: com.open-commissioning.core (upm branch)

Description

The package fails to compile in the Unity editor on non-Windows platforms with:

Runtime/Scripts/Data/FileBrowser.cs(16,27): error CS0246: The type or namespace name 'FileBrowserEditor' could not be found (are you missing a using directive or an assembly reference?)

The cause looks like a mismatch between the preprocessor symbol used to reference the class and the one used to define it.

In Runtime/Scripts/Data/FileBrowser.cs, the editor branch is guarded by UNITY_EDITOR:

#if UNITY_STANDALONE_WIN
    Browser = new FileBrowserWindows();
#elif UNITY_EDITOR
    Browser = new FileBrowserEditor();
#endif

But the class itself, in Runtime/Scripts/Data/FileBrowserEditor.cs, is guarded by UNITY_EDITOR_WIN:

#if UNITY_EDITOR_WIN

On a Windows editor both symbols are defined, so it compiles. On a Linux or macOS editor, UNITY_EDITOR is true but UNITY_EDITOR_WIN is false, so FileBrowser.cs references a class that never gets compiled.

Steps to reproduce

  1. Open a project on Linux (or macOS) with the editor, Unity 2022.3.x.
  2. Add the package via git URL with the required dependencies.
  3. The error appears on first compile.

Possible fix

Since FileBrowserEditor only uses EditorUtility APIs, which work across editor platforms, changing the guard in FileBrowserEditor.cs from #if UNITY_EDITOR_WIN to #if UNITY_EDITOR lets it compile and work on Linux/macOS as well. I tested this locally and it resolves the error.

Happy to open a PR if that would help. Thanks for the package.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions