WebGL開發入門

來源:互聯網
上載者:User

標籤:難解   visual   available   res   for   其他   build   toolchain   bytecode   

­­­Getting started with WebGL development

WebGL開發入門

What is Unity WebGL?

什麼是Unity WebGL

The WebGL build option allows Unity to publish content as JavaScript programs which use HTML5 technologies and the WebGL rendering API to run Unity content in a web browser. To build and test your content for WebGL, choose the WebGL build target in the Build Player window, and click Build & Run.

可以使用Unity的WebGL構建選項將內容以JavaScript程式發布,這當中使用了HTML5技術和WebGL渲染介面API以在瀏覽器中運行Unity內容。在Build Player視窗中選擇WebGL構建目標,然後點擊Build & Run,就能以WebGL形式構建並測試你的內容。

Technical overview

技術概覽

To run in WebGL, all code needs to be JavaScript. We use the emscripten compiler toolchain to cross-compile the Unity runtime code (written in C and C++) into asm.js JavaScript. asm.js is a very optimizable subset of JavaScript which allows JavaScript engines to AOT-compile asm.js code into very efficient native code.

要在WebGL中運行,所有代碼必須是JavaScript。我們使用emscripten編譯工具鏈將Unity運行時代碼(用C和C++編寫)跨平台編譯成asm.js JavaScript。asm.js是JavaScript的一個很可最佳化的子集,允許JavaScipt引擎將asm.js代碼AOT編譯成非常高效的原生代碼。

To convert the .NET game code (your C# and UnityScript scripts) into JavaScript, we use a technology called IL2CPP. IL2CPP takes .NET bytecode and converts it to corresponding C++ source files, which is then compiled using emscripten to convert your scripts to JavaScript.

為將.NET遊戲代碼(你的C#和UnityScript指令碼)轉換成JavaScript,我們使用了稱為IL2CPP的技術。IL2CPP提取.NET位元組碼並將其轉換成相對應的C++源檔案,接著使用emscripten技術編譯這些檔案,將你的指令碼轉換成JavaScript。

Platform support

平台支援

Unity WebGL content is supported in the current versions of most major browsers on the desktop, however there are differences in the level of support offered by the different browsers. Mobile devices are not supported by Unity WebGL

大多數主流瀏覽器的目前的版本都支援Unity WebGL內容,然而不同瀏覽器的支援程度不一樣。Unity WebGL不支援行動裝置。

Not all features of Unity are available in WebGL builds, mostly due to constraints of the platform. Specifically:

WebGL構建裡並不包含Unity的所有內容,這主要因為平台的限制。具體來說是以下幾點:

·        Threads are not supported due to the lack of threading supporting in JavaScript. This applies to both Unity’s internal use of threads to speed up performance, and to the use of threads in script code and managed dlls. Essentially, anything in the System.Threading namespace is not supported.

·        構建的WebGL內容不支援多線程,這是由於JavaScript本身就缺乏多線程的支援。其中包括Unity內部為提高效能所用的多線程,以及指令碼代碼和託管dll裡使用的多線程。基本上,System.Threading命名空間裡的所有內容都不被支援。

·        WebGL builds cannot be debugged in MonoDevelop or Visual Studio. See: Debugging and trouble shooting WebGL builds.

·        在MonoDevelop或Visual Studio中WebGL構建不能被調試。詳見:WebGL構建調試及疑難解答。

·        Browsers do not allow direct access to IP sockets for networking, due to security concerns. See: WebGL Networking.

·        出於安全起見,瀏覽器不允許在網路編程裡直接存取IP通訊端。詳見:WebGL網路編程。

·        The WebGL graphics API is equivalent to OpenGL ES 2.0, which has some limitations. See: WebGL Graphics.

·        WebGL圖形介面API相當於OpenGL ES2.0,其有很多限制。詳見:WebGL圖形技術。

·        WebGL builds use a custom backend for Audio, based on the Web Audio API. This supports only basic audio functionality. See: Using Audio in WebGL.

·        基於Web Audio介面API ,WebGL構建為音頻使用自訂的後台技術,其只支援基本的音頻特性。詳見:在WebGL中使用音頻。

·        WebGL is an AOT platform, so it does not allow dynamic generation of code using System.Reflection.Emit. This is the same on all other IL2CPP platforms, iOS, and most consoles.

·        WebGL是一個AOT平台,因此它不支援使用System.Reflection.Emit動態建立代碼。在所有其他IL2CPP平台、iOS和大多數控制台上也是不支援的。

WebGL開發入門

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.