簡體   English   中英

在Unity3D中使用Windows.Networking.Sockets

[英]Using Windows.Networking.Sockets in Unity3D

我正在嘗試為Windows Store移植我們的Unity應用程序,到目前為止,我無法使SDK正常工作。 我已經到了可以在Visual Studio 2013 Express for Windows Desktop中打開Unity C#項目的地步(這很奇怪,因為“ ... for Windows”無法打開Unity項目,但開發需要它)。 #if UNITY_WINRT宏開始起作用,但是我似乎無法正確使用“ using”部分

using UnityEngine;
using System.Collections;
#if UNITY_WINRT
using Windows.Networking.Sockets;
#else
using System.Net;
using System.Net.Sockets;
#endif
using System;
using System.Threading;
using System.Xml;
using System.Collections.Generic;

Windows.Networking.Sockets被強調為錯誤,通常,似乎沒有using Windows ...我在做什么錯? 我應該在使用部分添加一些東西嗎? 我應該添加一些庫嗎?

現在,我了解了為什么與Android或iOS相比,開發設置如此困難且受限制,Windows Phone的應用程序開發人員如此之少(當然這是受限制的,但是設置很容易)。

非常感謝您的幫助 ...

由於您的應用程序是在Visual Studio Express for Desktop中打開的,而不是在Visual Studio Express for Windows中打開的,因此聽起來您是從Unity而不是Windows Phone項目中生成了Windows桌面項目。 您需要返回Unity並將Visual Studio解決方案重新生成為Windows應用商店或Windows Phone解決方案。 還要確保您的VS Express至少具有Update 2,以允許Windows Phone項目。 更好的是:升級到Visual Studio社區,而不是使用VS Express。 它仍然是免費的,但是等效於VS Pro,並且(最重要的是)它將運行Visual Studio Tools for Unity

您需要使用#if NETFX_CORE代替(或除了)UNITY_WINRT才能使用Windows運行時。 UNITY_WINRT將允許將特定功能定向到Windows Phone或Windows Store,但它仍將在Unity編輯器(單聲道,而不是Windows運行時)中運行。 NETFX_CORE僅在Windows運行時而不是Mono上運行時才為true。

好吧,我啟動並運行它。 我在Visual Studio中的C#(托管)中創建了一個DLL庫。 然后,我從mu Unity應用程序中調用了所需的方法。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM