Introduction to local client development of UNITY3D technology

Source: Internet
Author: User

Welcome to Unity Learning, unity training, Unity Enterprise training and education zone, there are many u3d resources, u3d training videos, u3d tutorials, U3d Frequently asked questions, U3d Project source code, we are committed to creating the industry Unity3d training, learning the first brand.

Getting Started with local client development

Local client (NACL) is a new technology provided by Google that allows you to embed local executable code on a Web page so that you can deploy a highly-performing web application without installing a plug-in. Currently, NACL only supports the use of Google chrome on Windows, Mac os X and Linux (with available Chrome OS support), but this is an open source technology that we can later migrate to other browser platforms.

Unity 3.5 provides support for running the Unity Web Player (. unity3d file) directory using NaCl, which does not require running the directory with the plugin installed on Chrome. This is an earlier version – stable performance, but does not support all the features supported by Unity Web Player (web player) because NaCl is a constantly updated platform and does not support all the features supported in the browser plug-in.

Build and test games on NaCl

Building and testing games on NaCl is easy. You need to install Google Chrome. Simply select Web Player (web player) in the Publish settings (Build Settings), and then select the Enable (enable) NaCl check box. This ensures that the generated Unity3d files can run on NaCl (by adding the GLSL ES shader required by NaCl and disabling dynamic fonts that are not supported by NaCl), and install the NaCl runtime and HTML files to run the game in NaCl. If you click Build & Run, Unity installs the player as an application in Chrome and runs the player automatically.

Installing games with NaCl

Chrome Universal pages are not enabled by default in the current state. Embedding a NaCl player into any Web page and directing users to manually enable NaCl in Chrome://flags, the only way to install and run the NaCl game now is to deploy them in the Chrome Web store (which, by default, NaCl is enabled). Please note that the Chrome Web store (store) is public and unrestricted, which allows you to host content embedded in your own website, or use your own payment processing system, if required. According to the plan, the limitations of NaCl will be improved after Google completes the development of a new technology called portable NaCl (PNACL), which allows you to install executable files as LLVM bits, freeing the NaCl application from any particular CPU architecture. You should then enable NACL on any Web site.

Building Dimension Considerations

When you build NaCl, you may find that the "unity_nacl_files_3.x.x" folder is very large, more than a few megabytes. You might want to know if you need to download all of this data each time you run the NaCl catalog, and the answer is usually "not needed." There are two ways to provide apps in the Chrome Web store, one for managed apps and one for packaged apps. If you provide a catalog as a packaged app, all data will be downloaded as a compressed archive file at installation, and all data will be stored on the user's disk. If you provide content as a managed app, data is downloaded from the Web each time. However, the NaCl runtime will only download the relevant architecture from the "unity_nacl_files_3.x.x" folder (i686 or x86_64), and when the Web server is properly configured, the system will compress the data when it is transferred, and the actual data size to be transferred should be about ten MB ( Use physical stripping to reduce data size). The "unity_nacl_files_3.x.x" folder contains an Apache ". htaccess" file that can be set to compress data while it is being transmitted. If you are using a different Web server, you may need to set it yourself.

Limitations of NaCl

NaCl does not support all features of common Unity Web player (web player). Later versions of Chrome and Unity will support many of these features. Currently, NACL does not support the following features:

    • Webcam textures (Webcam textures)
    • Joystick input (Joystick input)
    • Cache (Caching)
    • Substance (substances)
    • Animated fonts (Dynamic Fonts)
    • Network consisting of types other than WWW class
    • The parser is not running because it needs to connect the network to the editor.
    • As with standard web player plug-ins, NaCl does not currently support local C + + plugins.

NaCl supports the following features, but there are some limitations:

    • Depth Texture:
Depth textures are ideal for making real-time shadows and other effects. Unity NaCl supports deep textures, but Chrome's OpenGL ES 2.0 implementation does not support the required Windows extensions, so deep textures are not available for OS X and Linux.
    • Other graphics Features:
NaCl uses OpenGL ES 2.0, which does not support all extensions in normal OpenGL. This means that some features are affected by the extension, such as NaCl does not currently support linear and HDR lighting functions. In addition, the shader (Shaders) needs to be compiled into a GLSL shader. Currently, not all built-in Unity shaders support this feature, for example, the GLSL shader does not support screen space ambient occlusion (Ambient occlusion).
    • Cursor Lock:
Cursor locking is supported, but is limited to full-screen mode only. Future versions of Chrome plan to support cursor locking in windowed mode.
    • Nullreferenceexceptions (null reference exception):
NACL does not support hardware exception handling. This means that NullReferenceException in the script code causes the NaCl to crash. However, you can transfer the softexceptions= "1″ to an embedded parameter (which is set automatically by Unity when building the development player) to tell Mono to check if there is a nullreferences (null reference) in the software and, if so, to slow down the execution of the script. But will not cause a crash.

Google does not set any system requirements for using NaCl, but Mac's operating system should be at least OS X 10.6.7, and we find it does not work well on legacy systems – especially with older GPUs or graphics drivers and smaller primary memory systems. If you want to use the target legacy hardware, you'll find that the Web Player provides better performance.

Full Screen mode:

Setting the Screen.fullscreen property supports full-screen mode, and you can only enter full-screen mode if the user releases the mouse button. NaCl does not actually change the hardware screen resolution, so screen.resolutions will only return the current desktop resolution. However, Chrome supports rendering a smaller back buffer and then zooming the bitmap to the screen size. Therefore, a smaller resolution is requested, and then the desktop resolution will typically support full-screen mode, but will cause the screen to be scaled based on the GPU instead of changing the full-screen mode.

WWW class:

The WWW class supports NaCl, but needs to follow the different security policies of the Unity Web player (web player). Unity Web Player (web Player) uses Crossdomain.xml policy files similar to flash memory, but unity NaCl must follow the cross-domain security mechanisms that NaCl follows. In fact, to access HTML documents in other domains hosting the player, you need to configure the Web server to deliver the Access-control-allow-origin response request header so that the domain can host the player.

Communicating with browser JavaScript in NaCl

NaCl supports interacting with Web pages using JavaScript, and this is similar to interacting with the Unity Web Player (web player). This differs from the syntax of sending messages from HTML JavaScript to Unity, which must pass through the NaCl module. When you use the default Unity-generated HTML, this code will run:

document.getElementById (' unityembed '). PostMessage ("gameobject.message (parameter)");

To invoke browser JavaScript code from NACL, you can call Application.externalcall or application.externaleval. However, Google has withdrawn support for the Chrome app's Eval function, so publishing it to the Chrome Web store won't work. To resolve this issue, you can use Application.externaleval to send the string you intercepted in the Unity_nacl.js Modulemessage class function, or to set the app to your satisfaction sandbox (sandbox).

Log

NaCl does not allow access to the user's file system, so log files are not written. All logs are output to the standard output stream. To view the player log in NaCl:

    • Perform a build and run (build & Run) in the editor to make sure your game is installed as an application to Chrome.
    • Start Chrome from the terminal on Mac OS X, and then click its icon to launch the application. You should be able to see the logs from the Unity player output at the terminal.
    • Windows systems are the same, but you need to set nacl_exe_stdout and NACL_EXE_STDERR environment variables and launch Chrome with an option without a sandbox.
    • For more highlights, please click http://www.gopedu.com/

Introduction to local client development of UNITY3D technology

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.