Unity Hand Tour Project Optimization Advice (essay)

Source: Internet
Author: User

1. When loading a prefab, when to use asynchronous loading.
When the prefabrication is very complex, up to hundreds of MS, this time synchronous loading may cause the low-end model to lag. Asynchronous loading by splitting the preform avoids stalling, but it can take longer. The total time required for asynchrony is several times longer than synchronization, but the asynchronous divergence to a few frames after each frame will be short so the lag is less severe. (By the way, when a prefab is instantiated, the related resources on the prefab are loaded, and the Resourse.load loading the preform is quite fast). So we can put all the logic scripts in the sub-preform to execute the script at the end of their instance, otherwise there will be a long gap between the prefab instance and the script execution, and all the code on the master prefab must wait until all the sub-preforms have been loaded after the callback.
2. It's really important to develop good habits and give different names to every game object. If the project is very large, when you want to change the UI (change the script is another thing) your every UI is called Image Text, even if you really want to cry. (The names of different game objects are easy to manage in batch), and the subdivision of the precast body also helps in batch management.
3. Each behavior should be written in a method, in a complex project the best is better, so that in dealing with "we have a traitor" in the case of rewriting is very easy. When you write the main logic in a preshow (), you can only rewrite the whole preshow () to achieve the goal.
4. Encapsulation of common system functions, easy to manage. For example, to encapsulate Gameobject.setactive (false), let's say we want to add an animation to this object later, then we can modify the encapsulation method without having to go to every place to modify it.
5. When the text content length needs to be changed, using Bitfit or content size fit from the adaptation, in the UI should consider whether each text needs to be specialized.
6. Previously misunderstood the role of meta-file, that the meta file is stored in the resource reference, in fact, Meta is stored in the unique ID of this resource (used to identify resources), when the prefab in the resource miss, you upload the meta-prefab, The prefab meta contains the ID of the reference resource and then goes to the reference ID, which is not found because the meta of your resource does not exist, so it is miss.
7. In the UI, it should be localized to do well, or finally to change every place in Chinese is not so easy
8. The camera's orthogonal and perspective modes are not displayed when the object is in the same plane as the camera.
9. High cohesion and low coupling. For example, in game development, when we go to the development of the interface, we should consider whether the interface can be created independently or must depend on an interface to open, in general, when others to call our interface should be guaranteed high fault tolerance. Think of the game experience if you want to create n interfaces before opening that target interface.

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.