c# - Unity Hololens (UWP) 构建会生成 Standalone 构建不会产生的错误?

标签 c# .net unity3d dll hololens

替代标题: Hololens Windows UWP 构建 (10.0.10586.0) 的 Unity 引用错误? 或者..... Unity Hololens Builds 可以访问 Standalone Build DLL 引用?

快速介绍:我正在设计一个在 Hololens 上运行的应用程序。该游戏在 Unity 中运行得非常好。它可以完美无误地构建到 PC、Mac 和 Linux 独立平台。

但是,在构建到 Windows 应用商店平台时,会出现“缺少”引用的错误。 (缺少引号,因为我已经彻底检查并重新检查我使用的是正确的引用资料,并且它们位于它们应该位于的位置)。

尝试构建的初始错误是:

Error building Player because scripts had compiler errors
error: The type or namespace name 'FileSystemEventArgs' could not be found (are you missing a using directive or an assembly reference?)
private void PrototypeFileWatcher_Created(object sender, FileSystemEventArgs e)
{
    ...
}

当通过注释掉上述函数和相关代码来更正此错误并再次尝试构建时,会出现这些错误:

error: The name 'Console' does not exist in the current context
catch (Exception e)
{
    Console.WriteLine(e.Message);
}

error: Argument 1: cannot convert from 'string' to 'System.IO.Stream'
using (StreamReader sr = new StreamReader(path))
{
    ...
}

error: The type or namespace name 'BufferedStream' could not be found (are you missing a using directive or an assembly reference?)
using (BufferedStream bs0 = new BufferedStream(f0))
{
    ...
}

引用存储在适当的位置:

C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v3.5\Profile\Unity Full v3.5\System.Core.dll

引用列在脚本的标题中:

using UnityEngine;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System;
using UnityEngine.UI;
using UnityEngine.EventSystems;
using System.Threading;

话虽如此。我试过:

-Changing Api Compatibility Level*
-Changing the project solutions net framework
-#if NETFX_CORE using x = WinRTLegacy.x; #else
-#if WINDOWS_UWP using System; #endif
-Trashing the project entirely and rebuilding from scratch
-And lots more

现在已经为这个问题苦苦挣扎了一整天。我有 NuGet pkgs,Unity 的 VS 工具(也称为 VSTU),我正在使用 VS2015。 我现在完全不知所措。我不明白我是否不能将它构建到 Windows 应用商店平台,因为它不能使用 Unity 独立构建可以使用的一些 DLL?

最佳答案

HoloLens 应用程序仅限于使用 UWP 应用程序中可用的内容。有些东西在 Unity 编辑器中可以工作,但在 HoloLens 应用程序中不起作用,因为 unity 编辑器使用 mono 而不是 .net 构建。你应该限制自己只使用在 UWP 中工作的东西,它们在编辑器中也能正常工作。即使是整套 UWP API 也无法在 HoloLens 上使用。

UWP 的完整文档在这里:

https://learn.microsoft.com/en-us/uwp/api/

专门为 HoloLens 添加的子集位于本页底部:

https://developer.microsoft.com/en-us/windows/mixed-reality/development

不幸的是,没有一个地方可以突出显示不可用的内容。 Visual Studio 编译器将帮助您了解什么是存在的,什么不是。

关于c# - Unity Hololens (UWP) 构建会生成 Standalone 构建不会产生的错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44531631/

相关文章:

c# - 如何在SQL Server 中增加外键中的id

c# - C# 中的 Excel 函数目标求等价算法

c# - 将城市 ID 保存到数据库并在检索数据时获取城市名称?

C#编译器无法在Windows 10上运行

c# - PictureBox 图像不会缩小,但 PictureBox 本身会扩展以适合图像

.net - IHTMLSelectionObject.createRange() 抛出 UnauthorizedAccessException

c# - 统一在 iOS 应用程序上发送电子邮件时出错

c# - 将 C# 委托(delegate)注册到 C++ 回调,Marshal.GetFunctionPointerForDelegate 有什么作用?

macos - 如何判断 OSX 代码签名为何无效

c# - 如何手动禁用/启用 mrtk v2 空间感知设置