(v) Unity5.0 new features------Scripting in Unity

Source: Internet
Author: User
Tags unity 5

??

Source: http://blog.csdn.net/u010019717

Author: Sun Guangdong time: 2015.3.32

The previous Unity script

using Mono (WinRT on Windows Store Apps and Windows Phone), we use C # for third-party libraries and for ease of access to native performance. However, there are some challenges:

    • C # Runtime performance still lags behind C + +
    • The latest and best. NET language and runtime features are not supported in Unity's current version of Mono .
    • Approximately 23 platforms and architectures are arranged in a significant amount of effort, requiring porting, maintenance, and the provision of functional and quality parity.
    • Garbage collection may cause runtime pauses

Over the last few years these problems remain in our minds, so unity has managed to resolve them.

as the scope of the problem was clarified, trials were made to study different methods to solve the problem. Some of them have a future; But in the end, Unity found innovative solutions that proved to be the right way forward.

This road is il2cpp.

Il2cpp: Quick and dirty Introduction

Il2cpp consists of two parts: Ahead of Time (AOT) compiler and virtual machine (VM).

These two sections show that we do our own common language infrastructure, similar to. NET or mono. This is consistent with the implementation of the previous unity script.

Fundamentally, unlike previous implementations, the Il2cpp compiler translates assemblies into C + + source code. It then takes advantage of the standard platform C + + compiler to take the next step in the cost machine binary code.

Executing this code at run time (like a GC, metadata, and platform-specific resources) is an additional service provided by the Il2cpp VM.

The benefits of Il2cpp.

Let's talk about the problems that have been mentioned before, il2cpp how to solve every one.

Performance

Il2cpp is designed to provide ease of use and productivity and C + + performance in C #.

It allows the previous, production script workflow to remain intact while giving immediate performance gains. We've seen some of our script re-benchmark 2 x 3 x performance improvements. This performance improvement is due to several reasons.

    • The C + + compiler and linker offer a wide variety of advanced optimizations that were previously unavailable.
    • Static analysis of the size and speed of your code is optimized.
    • Unity centralizes scripts to run-time optimizations.

While Il2cpp is definitely still working in progress, these early performance gains are indicative of great things to come by.

. NET Upgrade

we get a very frequent request to provide runtime upgrades. while. NET has advanced over the years, Unity's current C # compilers and class libraries support the. NET 2.0/3.5 ERA features. Many users require access to the updated features while providing their code, as well as third-party libraries.

to complement Il2cpp, as it matures, in the editor we will also upgrade to the latest version of the Mono C # compiler, base Class library and runtime (the editor will not switch to Il2cpp, a quick iteration in the development process). Combining these two things will bring unity to a modern version of. NET.

It is also important to note that unity works with Microsoft to make current and future. NET features secure Unity's compatibility and quality.

Portability and maintenance

While this area may sound an internal issue for unity, it can also affect you. Unity 's virtual machines have a lot of platform and architecture-specific code. when we come to unity to bring a new platform, we have a great deal of effort to enable Mono virtual machines to be ported and maintained for that platform. features (and bugs) may exist on some platforms and not others. This affects unity's commitment to delivering value to you, and easily deploying the same content to different platforms.

Il2cpp the number of methods that solve these problems:

    • All code generation is for C + +, not architecture-specific machine code. the cost of porting and the maintenance of a specific code generation for the architecture are now easier to amortize.
    • for us, feature development and bug fixes take place faster . features and bug fixes are immediately available for all platforms. in its current state, il2cpp support is ported to the new platform within a short time.

In addition, a platform or architecture-specific compiler can be expected to be more optimized than a singular code generator. This allows us to reuse all efforts that have been entered into the C + + compiler instead of transforming it itself.

Garbage collection

Il2cpp does not depend on any particular garbage collector, but interacts with a pluggable API. in its current iteration Il2cpp uses the upgraded version of LIBGC, even when we look at multiple options. In addition to just the GC itself, we are studying to reduce GC stress by analyzing it in the Il2cpp compiler.

Although we do not have much to share, research is underway. We know this is important to many of you and we will continue to do it and keep you informed of future blog post. irrelevant to the il2cpp, but it's worth mentioning that in a garbage collection, you'll see more and more Unity 5 allocated free APIs.

Il2cpp is not what?

Il2cpp does not re-create the entire. NET or mono toolchain. We will continue to use Mono C # compiler. We will continue to use Mono's class library. currently supporting all features and mono AOT work should continue with Il2cpp's third-party libraries. We just want to provide a replacement for the Mono virtual machine and the AOT compiler and will always stick to the wonderful Mono Project.

When can we use Il2cpp?

by now, we hope you are just excited because we are using il2cpp and want to know when you can in your hands! Earlier versions of Il2cpp will be available as a part of WebGL publishing in Unity5.

beyond WebGL, we will continue to develop il2cpp for other platforms. In fact, we already have a job to achieve the number of platforms we support. We expect to launch at least one other platform later this year. Our current plan is to have IOS under the platform to get il2cpp support.

The upgrade of our mono Toolchain program will follow the Il2cpp after it is available on multiple platforms and has matured.

will never get il2cpp of a platform is webplayer; This is due to security implications. As mentioned earlier, the editor will still be able to use mono.

In addition, you can see the Il2cpp runtime in today's action. As mentioned earlier, the two WebGL demos we posted are il2cpp powered.

What's next?

Il2cpp still strives to develop: implement new features, optimize code generation, fix bugs, and support more platforms. Unity will continue to post more in-depth blogs about the progress we have made and talk about it with you on the forum.

Scripting team.









(v) Unity5.0 new features------Scripting in Unity

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.