简体   繁体   中英

Compile Errors when building a Unity PC Standalone project with the Tango SDK imported

Afternoon folks,

(I've searched around a fair bit for an answer to this issue, but it seems that it's either a rare scenario, or my google-fu is not up to par. Apologies if the answer is obvious and in another thread, if you could direct me, and I'd be on my way.)

The Problem:

It appears that it's impossible to build a PC Standalone application from Unity, while the TangoSDK is imported in the project, even when the scenes included in the build do not use any of the Tango assets.

(versions: Unity 5.5.1, TangoSDK Hopak, Windows 10)

Steps to replicate the issue:

  1. Create an empty Unity Project.
  2. Import the TangoSDK Unity package (confirmed with versions Eisa, Farandole, Hopak)
  3. Create and save a standard empty scene (Camera and Light only)
  4. Open the Build Settings and set the target platform to 'PC Mac & Linux Standalone'
  5. Click 'Build'
  6. The build process fails, with error:

Assets/TangoSDK/Core/Scripts/Common/OrientationManager.cs(62,0): error CS1029: #error: 'not supported platform'

The reason I'm trying to do this is because we're building a cross-platform app, where the mobile versions of the app are using Tango. An obvious workaround would be to create 2 different projects, one for android deployment with the TangoSDK loaded, one for desktop, without Tango libraries. But since there are a lot of shared assets between versions, it is obviously much more efficient to have everything in a single project, and so I'm trying to find a solution that doesn't involve me splitting development across 2 Unity projects for now.

I've a hunch the issue starts from the AndroidHelper interface (in Assets>Google-Unity>Scripts), as it seems to have some references to the OrientationManager, but I'm clueless as to why it's being included in a PC build.

Is there a way then to exclude any android-relevant scripts from the build? Thanks

EDIT

Here's a bit more info, after some more poking around. The original error was due to an omission, here's the original code that was giving the error:

        public static ScreenOrientation GetScreenOrientation()
        {
#if (UNITY_EDITOR || UNITY_STANDALONE_OSX)
            if (Screen.width > Screen.height)
            {
                return ScreenOrientation.LandscapeLeft;
            }
            else
            {
                return ScreenOrientation.Portrait;
            }
#elif (UNITY_IPHONE || UNITY_ANDROID)
            return Screen.orientation; 
#else 
#error not supported platform
#endif
        }

The first platform check did not cover UNITY_STANDALONE_WIN (Windows platforms), and was thus leading to the error. Replacing the line

#if (UNITY_EDITOR || UNITY_STANDALONE_OSX)

with

#if (UNITY_EDITOR || UNITY_STANDALONE)

fixes the original error, but overall the problem still persists: Every line that is throwing an error is either in a Tango library or is using a Tango library, when these scripts should not be getting called at all, as I'm essentially building an empty scene. Are there any android-related scripts that are included in all Unity builds by default? That might help me narrow the search down.

Is there a way then to exclude any android-relevant scripts from the build?

Yes

Firs of all, this should be the job of the people that made the TangoSDK. They likely forgot to do that. I suggest you contact them and report this problem.

The workaround is to modify the TangoSDK and fix it yourself with Unity's platform directives until they fix it.

Switch to 'PC Mac & Linux Standalone' to make the errors appear. Try to build it to make the error appear. Find the line of code from each error by double-clicking on it from the Editor then put that inside the code below:

#if UNITY_ANDROID || UNITY_IOS
//PUT THAT LINE OF CODE THAT IS CAUSING THE ERROR HERE
#endif

Since TangoSDK supports iOS, I added iOS to it too. You shouldn't have any problem if you do this for all the error.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM