Unity original lecturer Big decryption

Source: Internet
Author: User

This article reprinted from: Http://nedwu13.blogspot.tw/2013_11_01_archive.html (outside the wall)

Notes: 20131030 Unity original instructor Big decryption Asset bundle workflow and Character Dressup example-Liu Gang
  • There are two kinds of resources within unity (C.C. have two kinds?) :
    • Resources: With 10 years of history, try to use asset packs
    • Asset Bundle: Nickname AB, the center of today's Unity processing resources
  • Differences in AB options
  • There is a charge for downloading the asset bundle's cache via web player, and there is no charge for the ios,android cache. ---> Handheld games top up with!!!
  • The browser itself also has the cache, why use Unity's cache?
    • Because there is the cache inside the decompression state, the next call does not need to decompress again, the large province CPU time.
    • Unity manages the cache size, which is discarded when compressed files are decompressed.
    • Browser can only be stored in the compressed state of the asset Bundle, and the location of each browser are different. -There's a bad pay.
  • Assetbundle.createfrommemory: Most of the content is used for encryption and decryption, can not cache, that is, every execution to download once, script can also be encrypted
  • Assetbundle.createfromfile
  • Assetbundle.load and Application.load differences, application.load can only load streamasset inside of things.
  • Each open a WWW used to download assetbundle, will use 8MB of buffer, so www downloaded to do the following actions to clear the 8M:
    • WWW.Dispose
    • Assetbundle.unload (False)
    • Resources.unloadunusedassets
  • Assetbundle can be correlated!
    • Buildpipeline.pushassetdependencies, push the resources.
    • Buildpipelinepopassetdependencies, bounce the resources out.
  • Assume that push the following resources: A,b,c, through the Push&pop, can generate 3 packege,c dependent b,a,b dependent a,a Independent asset Bundles, completely do not duplicate the package resources!
  • In a prefab inside there will be mesh,material,shader,texture,script, should be separate package, load and then in order to load back, and then with the cache mechanism, has been downloaded asset Bundle does not need to download again, can achieve the best use of resources, bandwidth-?? But this resource-dependent logic must be designed clearly, otherwise it will be messy
  • The official practice proposal is that each asset bundle is around 1M, too small to download too much, too big to download for too long.
  • You can put the script inside the ScriptObject and then back through the asset bundle, so you don't have to put the script in the first package??。
  • The official demo case, through the use of dependency can be reduced to 131MB size 8.2m!
  • The role of the paper doll processing, you can refer to unity provided by the character customization example, see how to split the asset Bundle.
  • Map processing method, you can split the map into a number of sub-scene, the protagonist when the move is downloaded, instant display.
  • Asset Bundle has a CRC mechanism, if the download has a problem will be re-download
  • Code security
    • iOS platform closed, no need to worry (JB will say again)
    • Other platforms can use the asset pack + to make the code. NET components + assetbundle.createfrommemory plus decryption to make
    • The web does not apply the form of the code package into a native DLL
Resource dismantling and dynamic loading in large-scale scenes-Zhang Xin
  • Enter the scene all loaded, time-consuming, the player did not walk to
  • Unity scene only support 4096x4096, unit meters, no way to make a bigger scene
  • There are two types 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 should I do if the terrain is already well-prepared? Self-splitting
  • How to dismantle the terrain resources? Mr. NXN the terrain of the empty
    • Terrain data: Put data into the corresponding block---big project
    • Light map: Use free images to disassemble the map. EXR archives, free images available with C + + native DLL
    • LOD: Re-terrain.setneighbors each piece of terrain
  • How to disassemble the surface data?
    • According to the terrain tiles to dismantle
    • 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, load the nine Gongge that are centered on the camera, and the others are released to ensure memory usage and efficiency.
    • 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.
    • To avoid opening multiple www simultaneous download, memory consumption, www is the use of thread, will increase the system burden.
    • Coroutine also don't drive too much, officials suggest a coroutine sequential download of multiple resource
  • Loading time comparison:
    • Shader,material: Loading time is the longest, mainly in the parse content into the GPU, it is recommended to first load, anyway, does not account for memory. This is also the key to the demo case 1xFPS to 5xFPS. --The first time you mention
    • Textures, particles
    • Mecanim, Audio
  • For an example of the Object pool, refer to the bullet inside Angrybot
  • The scene after the scene demo split, the picture fine degree is very good, the map surpasses 4096x4096, the airplane side flies while the dynamic download Assetbundle displays the terrain, FPS at 50 above, in the mainstream handset also smooth.
Developing 3D Web games with the Unity engine-Liu Gang
  • Load the unified display flag, unityobject.embedunity, set the parameter to 3.4
  • UnityObject2 (params), change the params at 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
  • Web Game Content Protection:
    • 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 saved into Textasset, remember to pack into Assetbundle to use the cache.
  • The profile of the memory leak,4.1.2 can see the status of all gameobject, please use the profiler more
  • Dynamically load, define the scene description file with Scriptableobject, record the dependency, and then use the data to load the scene content.
  • Co-process in unity is not multi-threading, multi-use or will be dragged into the main line, please use with caution.
  • In a new scene or new level, put material and shader load out first, put into an empty gameobject inside, and then diactive, there is need to put in the right 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 changing the unity player version.
  • From the game's Web server to fetch the resources of other URLs, to set crossdomain.xml
  • If you do not need to asset Bundle, self-compression decompression, it must be in the time of the load down to extract immediately, and with assetbundle.createfrommemory, time-consuming. -->assetbundle really wants the load to be unpacked ...
  • Material,shader Pack It first! And that should be the third time you mention it? Because it's so important, I have to say three times.
      Unity's Networking Solutions
      • Very good sleep zzzzz
      • Photon server:c# interface, the bottom with C + + implementation, load 30K simultaneously online, load balance mechanism, there is an FPS paradigm, with TCP and RUDP, only with Windows.
      • Smartfox Server, Http://www.smartfoxserver.com/,Java implementation, available Windows/linux, no load Balance, provides a variety of monitoring and management interfaces.
      • Use Raknet to make your own
      Unity Engine performance is excellent-Cheung Xin
      • Mobile superiority
        • 300~2000 Polygon
        • The skin grid renderer has at most one
        • Texture the same amount of time
        • Bone Digital <30
      • Static objects
        • <500 Poly
        • Tag static
        • Don't use animation.
      • Terrain: Texture number of <4, with texture Fusion, can add 5fps~10fps
      • Texture format
        • With PNG,TGA
        • Do not exceed 1024
        • It looks like good, you can use 128x128, do not use 256x256
        • With Mipmap
        • Control UV range at (0, 1)--can also be more than the original?
      • 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 to reduce code size
      • Forwarding light principle, to draw the object number x light source, so the less the better.
      • Set the pixel light fixed value, fine art again more than just one.
      • Particles in the mobile platform, is the block for the 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 will greatly drag performance.
        • Smaller particles
        • Particle number <50
        • Particles don't have alpha.
        • particles do not collide
      • While not using mesh colider, use Box,capsulecollider
      • Animation section
        • No need to animation, no need to move everything.
        • No scaling, manual or program operation to remove scale curve, can reduce 33% blending job
        • Mecanim is multithreaded, does not drag the main Thread, a game object on multiple animation clip is used, if only one clip, you can consider only animation
        • Use body mask to tell Mecanim that there is no need to calculate
      • Render part
        • Avoid alpha testing, alpha blending
        • 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 flattening, to flatten the texture if UV more than (0, 1) is difficult to do.
      • Masking culling for mobile platforms is suitable for PV and dynamic objects
      • Use instead of foreach because the foreach will give birth to a bunch of iterators
      • 30 times times faster with struct instead of class
      • Legendary 8-hour high-level email support that must reply
      • Shadow optimization with reference to Shadowgun simulation of shadow
      • Next, Unity's roadmap will support the new UI (speaking for a long time) with the server.

      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.