Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/unity3d/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 类型或命名空间名称';说明';找不到_C#_Unity3d_Uwp - Fatal编程技术网

C# 类型或命名空间名称';说明';找不到

C# 类型或命名空间名称';说明';找不到,c#,unity3d,uwp,C#,Unity3d,Uwp,我目前正在为UWP开发一个MR应用程序。我正在unity3d中构建应用程序(在5.5.2和2017.1.2中进行了测试),当我在unity中按play时,一切正常,没有任何编译错误。。。但是,当我构建应用程序时,会出现错误Assets\Script\dmewerquest.cs(35,10):错误CS0246:找不到类型或命名空间名称“DescriptionAttribute”(您是否缺少using指令或程序集引用?和Assets\Script\dmewerquest.cs(35,10):错误C

我目前正在为UWP开发一个MR应用程序。我正在unity3d中构建应用程序(在5.5.2和2017.1.2中进行了测试),当我在unity中按play时,一切正常,没有任何编译错误。。。但是,当我构建应用程序时,会出现错误
Assets\Script\dmewerquest.cs(35,10):错误CS0246:找不到类型或命名空间名称“DescriptionAttribute”(您是否缺少using指令或程序集引用?
Assets\Script\dmewerquest.cs(35,10):错误CS0246:找不到类型或命名空间名称“Description”(是否缺少using指令或程序集引用?

据我所知,DescriptionAttribute是System.ComponentModel

我的C#脚本中的代码片段

希望有人能帮我找出我缺少的指令或参考


/T

在构建PC、Mac和Linux单机版时,您的代码应该可以正常工作。当您将平台切换到通用Windows平台时,它不应该工作,因为
System.ComponentModel.Description
使用了UWP不支持的
DescriptionAttribute
。UWP取消了对许多.NET API的支持。这是制作UWP应用程序时应该记住的一件事。

它使用IL2CPP作为脚本后端。如果您需要Unity 2018 LTS中已弃用的.NET脚本后端(于2019年删除),您可以尝试从Mono中添加DescriptionAttribute.cs,或者按照@Programmer的建议添加反编译代码。在某些情况下它可能会工作,但在我的情况下,我遇到了更多的错误


最后,当我试图为UWP(.NET)编译ARSubsystem包时,我放弃了,这是同一项目的iOS/Android版本所需要的。相反,我操纵了包清单,根据平台排除/包括包。有两种方法可以实现类似或接口的功能。

它出现在中,您已经添加了它。您是如何添加
组件模型的引用的?
?没有做任何其他操作,然后键入它。。。但正如@Programmer在回答中所说的,它不会与UWP一起工作:/Ohh好的,非常感谢,现在它有了意义:)你知道我可以使用特殊字符(%,º,³等)制作一个公共枚举的另一种方法吗?除了切换所选枚举之外。如果我知道一种解决方法,我会将其添加到回答中。我真的不知道。也许用mono重新实现这一点是可行的。我不确定,但试试看。请确保将该代码包装在宏中,以便仅在切换到UWP时使用。我将尝试一下,再次感谢您的回答。这几天我一直在想:)Np。试试看。如果有效,我会将其编辑到我的答案中。无法使其生效。以将枚举值转换为字符串的开关结束:/
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.UI;


//Makes a dropdown menu in the inspector
public enum EGU {
    [Description("")] None,
    [Description("ºC")] DegreesCelcius,
    [Description("kW")] KiloWatts,
    [Description("kW/h")] KiloWattsPerHour,
    [Description("MW")] MegaWatts,
    [Description("MW/h")] MegaWattsPerHour,
    [Description("M³")] CubicMeters,
    [Description("M³/h")] CubicMetersPerHour,
    [Description("%")] Procentage,
    [Description("º")] Degrees,
    [Description("l/s")] LiterPerSecond,
    [Description("cm")] CentiMeters,
    [Description("m")] Meters,
    [Description("mg/l")] MiliGramPerLiter,
    [Description("g/l")] GramPerLiter
    }