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:
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
- Open a project on Linux (or macOS) with the editor, Unity 2022.3.x.
- Add the package via git URL with the required dependencies.
- 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.
Environment
Description
The package fails to compile in the Unity editor on non-Windows platforms with:
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 byUNITY_EDITOR:But the class itself, in
Runtime/Scripts/Data/FileBrowserEditor.cs, is guarded byUNITY_EDITOR_WIN:#if UNITY_EDITOR_WINOn a Windows editor both symbols are defined, so it compiles. On a Linux or macOS editor,
UNITY_EDITORis true butUNITY_EDITOR_WINis false, soFileBrowser.csreferences a class that never gets compiled.Steps to reproduce
Possible fix
Since
FileBrowserEditoronly usesEditorUtilityAPIs, which work across editor platforms, changing the guard inFileBrowserEditor.csfrom#if UNITY_EDITOR_WINto#if UNITY_EDITORlets 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.