简体   繁体   English

使用导入的Tango SDK构建Unity PC Standalone项目时出现编译错误

[英]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.) (我一直在寻找有关此问题的答案,但似乎这是一种罕见的情况,或者我的google-fu达不到标准。如果答案很明显,则道歉;如果您的回答是其他问题,则表示歉意。可以指引我,我会在路上。)

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. 尽管TangoSDK已导入到项目中,但即使在构建中包含的场景未使用任何Tango资产的情况下,似乎也无法从Unity构建PC Standalone应用程序。

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

Steps to replicate the issue: 复制问题的步骤:

  1. Create an empty Unity Project. 创建一个空的Unity项目。
  2. Import the TangoSDK Unity package (confirmed with versions Eisa, Farandole, Hopak) 导入TangoSDK Unity软件包(已通过版本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' 打开构建设置并将目标平台设置为“ 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' 资产/ TangoSDK /核心/脚本/公共/OrientationManager.cs(62,0):错误CS1029:#错误:“不受支持的平台”

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. 我尝试这样做的原因是因为我们正在构建一个跨平台应用程序,该应用程序的移动版本正在使用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. 一个明显的解决方法是创建2个不同的项目,一个用于在TangoSDK加载的情况下用于android部署,一个在没有Tango库的情况下用于台式机。 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. 但是由于版本之间有很多共享资产,所以将所有内容都放在一个项目中显然要高效得多,因此我试图找到一种解决方案,该解决方案目前不涉及将开发分为两个Unity项目。

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. 我直觉这个问题始于AndroidHelper界面(在Assets> Google-Unity> Scripts中),因为它似乎对OrientationManager进行了一些引用,但是对于为什么将它包含在PC版本中,我一无所知。

Is there a way then to exclude any android-relevant scripts from the build? 有没有办法从构建中排除任何与Android相关的脚本? 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. 第一次平台检查未涵盖UNITY_STANDALONE_WIN(Windows平台),因此导致错误。 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. 解决了原始错误,但总体而言问题仍然存在:抛出错误的每一行都在Tango库中或正在使用Tango库,而这些脚本根本就不会被调用,因为我实质上是在构建一个空的场景。 Are there any android-related scripts that are included in all Unity builds by default? 默认情况下,所有Unity构建中都包含任何与Android相关的脚本吗? That might help me narrow the search down. 这可能有助于我缩小搜索范围。

Is there a way then to exclude any android-relevant scripts from the build? 有没有办法从构建中排除任何与Android相关的脚本?

Yes

Firs of all, this should be the job of the people that made the TangoSDK. 首先,这应该是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. 解决方法是修改TangoSDK并自己使用Unity的平台指令对其进行修复,直到他们对其进行修复。

Switch to 'PC Mac & Linux Standalone' to make the errors appear. 切换到“ PC Mac&Linux Standalone”以显示错误。 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. 由于TangoSDK支持iOS,因此我也向其中添加了iOS。 You shouldn't have any problem if you do this for all the error. 如果针对所有错误执行此操作,则不会有任何问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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