Unity original lecturer Big decryption

Source: Internet
Author: User

This article was reproduced from: http://nedwu13.blogspot.tw/2013_11_01_archive.html

Asset Bundle Workflow and Character conversion example-Lau
  • There are two kinds of resources in unity (C.C. have two kinds?) :
    • Resources: 10 years of history, albeit with asset Bundle
    • Asset Bundle: Nickname AB, now the center of Unity's resource
  • The difference of AB option
  • The cache for the asset bundle downloaded via web Player is subject to charge and is not charged at the ios,android cache. ---> Handheld games for!!!
  • The browser itself also has the cache, why use Unity's cache?
    • Because there is a decompression state in the cache, the next time the adjustment does not need to be re-stressed again, the CPU times.
    • Unity manages the cache size, and the compression file is dropped after it is suppressed.
    • Browser can only be compressed asset bundles, and the location of each browser is different. -There's a difference in payment.
  • Assetbundle.createfrommemory: Most of the content is used in the encryption and decryption, not the cache, that is, every time to download, script can be encrypted
  • Assetbundle.createfromfile
  • The difference between assetbundle.load and Application.load, application.load can only load streamasset inside the east.
  • Every www used to download assetbundle, will use 8MB of buffer, so the WWW download finished to do the following to clear the 8M:
    • WWW.Dispose
    • Assetbundle.unload (False)
    • Resources.unloadunusedassets
  • Assetbundle can be used as a dependency!!!
    • Buildpipeline.pushassetdependencies, push the resources.
    • Buildpipelinepopassetdependencies, get the resources out.
  • The following resources are available: A,b,c, through Push&pop, can produce 3 packege,c depending on b,a,b a,a asset alone, it does not duplicate the package resources!
  • In a prefab there will be mesh,material,shader,texture,script, should be divided into packages, load and then follow the order of load back, and then with the cache system, has been downloaded asset Bundles do not need to be downloaded again, you can reach the best use of resources, bandwidth------------------the resource-dependent logically must be designed clearly, or it will be chaotic.
  • The official mission advice is that each asset bundle is around 1M, too small to be downloaded too much, too big to download for a long time.
  • You can put the script in the ScriptObject, and then through the asset bundle back, so there is no need to put the script in the first package.
  • Official demo case, through the use of dependency can be 131MB size into 8.2m!
  • The role of the doll in the way, you can refer to Unity provides character customization examples, see how to Split asset Bundle.
  • The map is handled so that the map can be split into multiple sub-scenes, which are displayed when the protagonist moves.
  • The Asset bundle has a CRC system, and if the download has a problem, it will download itself again.
  • Code security
    • iOS platform closed, no need to worry (JB will say again)
    • Other platforms available Asset Bundle + code as. NET Assembly + assetbundle.createfrommemory plus decryption
    • The web is not suitable for putting code into the form of a native DLL
The resource of the large-scale scene and the dynamic loading-Zhang Xin
  • Enter the scene all loaded, the time, the player didn't walk
  • Unity scene only support 4096x4096, single meter, no way to make a bigger scene
  • There are two kinds of splits:
    • Terrain Resource Splitting
    • Surface splitting
  • Recommended Split tool: Terrain composer,http://www.terraincomposer.com/, the largest can be removed 8x8, each size 2000x2000, that is, 16000x16000, that is, 16kmx16km
  • What if the terrain is already well-established? Self-splitting
  • What is the terrain resource? Mr. NXN the terrain of the empty
    • Terrain data: Put data into the corresponding block---big project
    • Light map: Using the free image to remove light map. exr file, free image has a C + + Native DLL available
    • LOD: Re-terrain.setneighbors each terrain
  • How to remove the surface information?
    • The terrain is split
    • Packaged in a way previously mentioned Assetbundle Depedency
    • One pack is around 1M.
  • Well, how do you show it?
    • Assetbundle is too big to load in the first scene
    • When the camera moves, it loads the nine of the camera's center, and the rest is released to make sure that memory usage and efficiency are included.
    • Avoid the Instantiate,destroy of the frequency, causing the pull machine (?) The recycling system is too complex (averaging 10 ms) and can be used as an object Pool.
    • Avoid more than one www download, memory, www is the use of thread, will increase the system.
    • Coroutine also do not open too much, the official suggestion of a coroutine sequential download more resource
  • Load time Comparison:
    • Shader,material: The longest time to load, mainly in the parse inside the GPU, the proposed first download, but do not account for memory. This is also the key to the demo case 1xFPS to 5xFPS. --The first time you mention
    • Texture,particle
    • Mecanim,audio
  • For example, please refer to the sub-bombs in the Angrybot area of the Object pool.
  • The scene of the field demo split, the painting surface fine detail is very good, the map over the 4096x4096, the aircraft flew one side of the Assetbundle after the display of terrain, FPS in more than 50, on the mainstream of the mobile phone also few laps.
Use the Unity engine to launch the 3D Web game-Lau
  • Change loading unity to logo,unityobject.embedunity, set parameter for 3.4
  • UnityObject2 (params), change params for 4.X
  • To bounce a new window, OpenURL No, externaleval not, to use the HTML Iframe/div, can also be used Rokbox,http://www.rockettheme.com/extensions-joomla/rokbox
  • Unity to DB, use Wwwform as post, use WWW as get--> Direct read db a bit blind
  • Protect your Web game:
    • Code encryption: After the code package into the asset bundle, save into Textasset, and then wrapped into assetbundle (for cache!), take the time to use reflection to use, extremely difficult to use.
    • Code obfuscation: Recommended Practice, web platform to official help, Android can do it by itself, iOS heard not to do
    • Resource encryption: Most need is texture, can be encrypted and then saved into Textasset, remember to pack into Assetbundle to use the cache.
  • Memory leak,4.1.2 profile can see all gameobject state, please use profiler more
  • Dynamic loading, use Scriptableobject to define the scene profile, record the dependency, and then, according to these information to download the field Jingnejong.
  • Coroutine in unity is not multi thread, multi-use or will drag the main thread, please use caution.
  • In a new scene or a new card, put material and shader load out first, put in an empty gameobject inside, and then diactive, there is a need to put in the correct place. --The second time it mentions
  • Assetbundle packaging particle size, debug can package smaller the better, release suggestion 1MB
  • Block right-click functionality to prevent users from switching to the Unity player version.
  • From the game's Web server to fetch the resources of other URLs, to set the Crossdomain.xml
  • If you do not need to asset Bundle, self-compression decompression, must be loaded under the time of the horse decompression, and with assetbundle.createfrommemory, consumption time. The-->assetbundle is that the load needs to be suppressed ...
  • Material,shader Pack It first! And this should be the third time you mention it? Because it's so important to talk about three times??
Unity's web Solution
    • Very good sleep zzzzz
    • Photon server:c# interface, the bottom layer in C + +, can be negatively charged 30K at the same time in the line, Load balance machine, there are FPS examples, with TCP and RUDP, only with Windows.
    • Smartfox Server, Http://www.smartfoxserver.com/,Java, available windows/linux, no load Balance, provides multiple monitoring and management interfaces.
    • Use Raknet to make your own
Unity Engine performance is excellent-Cheung Xin
  • Mobile superiority
    • 300~2000 Polygon
    • Skinned Mesh renderer with up to one
    • Texture the same amount of time
    • Bone Digital <30
  • Static Object
    • < Poly
    • Label Static
    • Don't use animation.
  • Terrain: Texture number of <4, with texture Fusion, can add 5fps~10fps
  • Texture format
    • With PNG, TGA
    • Not over 1024.
    • Look like good, can use 128x128, don't use 256x256
    • With Mipmap
    • Control UV range in (0, 1)--and the original can be over?
  • Mesh simplifies, with meshlab, but only simplifies the meditation mesh. With Simplygon,
  • The mesh simplifies, animation simplifies, uses the simplygon,http://www.simplygon.com/, wants the money, the effect is good.
  • Do not use System.Xml with mono.xml, reduce the size of the code
  • Forwarding light principle, to draw the object number x light source, so the less the better.
  • The pixel light is set to a fixed value, and the art is only one more.
  • Particles in the mobile platform, the block as a single render, too many particles will increase the pixel fill rate, because the particles do not have depth, so be sure to draw, mobile platform power is not enough to greatly drag performance.
    • A little bit of particles
    • Particle number <50
    • Particles don't have alpha.
    • particles do not collide
  • While not using mesh colider, use Box,capsulecollider
  • Animation part
    • No need to animation, don't need everything Yi
    • There is no contraction, manual or program to remove scale curve, can reduce 33% blending
    • Mecanim is multi-threading, does not drag the main Thread, a game object on multiple animation clip to use, if only one clip, consider only with animation
    • Use body mask to tell Mecanim that there is no need to calculate
  • Renderer part
    • Avoid Alpha Test,alpha Blend
    • Static batching need a lot of vertexbuffer, if vertex too much, to move a bunch of vertex to move, but drag performance
    • The Dynamic batching in the polygon < 900 will be self-acting, if Gameobject's shader has POSITION,NORMAL,UV, each with one more, 900 is halved.
    • When using dynamic batching, vertex can only be combined on the CPU, so vertex cannot be too much
    • If the same scene small block texture a lot, you can consider the program will texture together, to flatten the texture if UV over (0, 1) is very difficult to do.
  • The occlusion culling of the mobile platform is suitable for PVS and dynamic objects
  • Use for instead of foreach, because foreach will have a bunch of iterator
  • 30 times times faster with struct instead of class
  • A high-level email support that says it must reply in 8 hours
  • The superiority of the shadow, can refer to the reality of the shadow of Shadowgun simulation
  • Then the Unity Roadmap will support the new UI (long time) with the server.

(turn) Unity original lecturer Big decryption

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.