2017-11-08 7 views
1

現在、UWPのMRアプリケーションで作業中です。私はunity3d(5.5.2と2017.1.2でテスト済み)でアプリケーションを構築しています。すべてをうまく動かすと、何かコンパイルエラーは発生しません。しかし、アプリケーションをビルドするとエラーが発生しますDescriptionAttributeが私のC#スクリプトからSystem.ComponentModelタイプまたは名前空間の名前 '説明'が見つかりません

コードスニペット

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 
    } 

希望の一部であり、私の知る限りAssets\Script\DMEWebRequest.cs(35,10): error CS0246: The type or namespace name 'DescriptionAttribute' could not be found (are you missing a using directive or an assembly reference?)Assets\Script\DMEWebRequest.cs(35,10): error CS0246: The type or namespace name 'Description' could not be found (are you missing a using directive or an assembly reference?)

誰かが私が欠けているものをディレクティブまたは参照把握することができます。

/T

+0

['System.ComponentModel'名前空間]に表示されます(https://msdn.microsoft.com/en-us/library/system.componentmodel.descriptionattribute(v = vs.110).aspx)。それを加えた。 – mmushtaq

+0

'ComponentModel'のリファレンスをどのように追加しましたか? – mmushtaq

+0

それ以外は何も入力していませんでした...しかし、@Programmerは答えでUWPとは動作しませんでした:/ –

答えて

4

PC、マック&およびLinuxスタンドアロン用にビルドするときにあなたのコードは正常に動作する必要があります。 System.ComponentModel.DescriptionはUWPでサポートされていないDescriptionAttributeを使用するため、プラットフォームをUniversal Windows Platformに切り替えると機能しません。 UWPは多くの.NET APIのサポートを削除しました。これは、UWPアプリケーションを作成する際に覚えておくべき1つのことです。

+0

Ohh大丈夫、感謝しています。それは意味があります:)私は別の方法を知っていますか?特別な文字(%、º、³など)を使用してパブリック列挙型を作成し、次に選択された列挙型を切り替えます。 –

+0

私がこれを回避する方法を知っていたら、それを答えに加えたでしょう。私は本当に知らない。たぶんこれをmono [ソースコード](http://www.dotnetframework.org/default.aspx/DotNET/DotNET/[email protected]/untmp/whidbey/REDBITS/ndp/fx/src/CompMod/System)で再実装してください/ ComponentModel/DescriptionAttribute @ cs/1/DescriptionAttribute @ cs)が動作する可能性があります。私は確信していませんが、試してみてください。このコードを['UNITY_WSA'](https://docs.unity3d.com/Manual/PlatformDependentCompilation.html)マクロにラップさせて、UWPに切り替えるときにのみ使用するようにしてください。 – Programmer

+0

私はもう一度答えに感謝します。これを数日間心配しています:) –

関連する問題