UnityTechnologies / open-project-1

Unity Open Project #1: Chop Chop
http://unity.com/open-projects
Apache License 2.0
5.72k stars 2.04k forks source link

Build error: type or namespace name 'Localization' does not exist in the namespace 'UnityEditor' #494

Open jamesplease opened 3 years ago

jamesplease commented 3 years ago

Hi! I've been following the Wiki to better understand this project, but I was unable to successfully complete the instructions on building the project.

When I attempt to build from the main branch I receive this error:

Assets\Scripts\Dialogues\DialogueDataSO.cs(6,19): error CS0234: The type or namespace name 'Localization' does not exist in the namespace 'UnityEditor' (are you missing an assembly reference?)

Here's a screenshot showing the error:

image

This is very similar to the error that a user reported in #403, but it's not clear to me if the solution presented there applies to my situation as I haven't made any code changes.

Steps I followed

  1. I cloned the repository
  2. Making no code changes, I followed the instructions from the build wiki:
  3. The first step was packaging the game's asset bundles, which I was able to complete without any build errors
  4. I then tried to run "Build" from the "Build Settings" panel. The folder I tried to build to was ./Build (a new folder within the root directory of the repo)

Here's a git status showing the files that have been changed since my clone. I believe these changes are due to packaging the asset bundle.

image

As a quick check, I reverted all of these changes (via git checkout -- .) and tried to run a build with a completely clean install. The same error occurred.

Does anyone have any tips or advice on what might be causing this problem? Thank you so much for taking the time to read this issue!

Operating System: Tested on both:

Unity version: 2020.3.12f1

ciro-unity commented 3 years ago

Thanks @jamesplease. The issue is exactly what the debug panel reports: there are classes that are part of the UnityEditor namespace which are being included in the code that has to go into the build. This makes it fail, since builds cannot contain any editor-related code. This is a mistake on our end, should be easy to fix by just wrapping those classes in a conditional compilation, to say the compiler not to include them when outside of the editor (i.e. in the build). I'll fix it as soon as I can push.

kamilswiec commented 2 years ago

I've run into similar issue when I tried to use reuse StateMachine code in my project.

For some reason Editor folders were included in build but as far as I understand the docs they should not as they are treated as special folders. Wrapping around conditional compilation fixed issue in my project but wanted to make sure if that was the case so tried building this open-project.

I followed instructions in wiki and I was able build game without adding conditional compilation to editor scripts. The only difference I spotted was that in RiderIDE folder named editor from open-project had different icon? In my project editor folders copied from open-project did not change the icon in RiderIDE. Not sure if this issue is not being caused by some settings in Unity? Because for some reason Editor folders are included in my projects builds after copying from here.

I've used same version in my project as open-project is using now - 2020.3 with latest patch.

yaungsuzeng123 commented 4 months ago

LOL