In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the relevant knowledge of "what are the entry knowledge points of the game engine Unity". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Personally, the main reasons why Unity is easier to use than other engines are:
Component-based level design is more intuitive.
Unity controls the behavior of the game by abstracting the system or user's scripts into reusable components (Component) and attaching them to the game object. Compared with the traditional script-based development approach, level designers can build interfaces and levels more flexibly and quickly, with a sense of "building blocks". Although this design sacrifices some extensibility (for example, it is difficult to implement nested Prefab), it is very friendly for beginners.
The update of version 4.7 of Unreal engine also follows the example of Unity, moving closer to componentization, making the level structure easier to understand and maintain.
Using Mono as the platform on which scripts are run
C#/Mono has better stability and abstraction than C++ and other scripting languages, an easy-to-use .NET framework and easy-to-port open source libraries, and relatively complete language services such as GC and reflection make it much easier to develop complex logic. Although it lowers the threshold and makes low-quality code easier to produce, I think the advantages outweigh the disadvantages for both beginners and veterans.
The function of the engine itself is relatively simple + rich Asset Store plug-ins
Compared with the illusory super engine, the function provided by Unity is very basic, the number of components and the configurable content of each component are not much, so it is easier to have a more intuitive feeling when learning, so as not to get lost in the details. On the other hand, the success of the Asset Store pattern has created a large number of powerful third-party plug-ins, filling in various gaps in Unity development and further lowering the development threshold.
I think the main reason why it is difficult to master is:
High requirements for comprehensive ability
First of all, it's hard to master not only for Unity, but for any game engine or for game development itself. Because game client development itself is a very comprehensive activity, there are many integrated technologies, such as:
Modeling
Level making
Script logic
Network Communications
Platform feature integration
Animation production
Special effects production
Workflow integration
Debugging and optimization
For Unity engineers who glue these technologies together, although they do not need to be proficient in all aspects, it is also a great test of their ability to combine the work of team members with high efficiency and high quality. only long-term, all-round participation in the whole development process and understanding the way team members work can gradually grow into an excellent Unity engineer.
For example, Unity engineers need to:
Communicate with the design and art team to evaluate the impact of design on game performance, implement prototypes, and conduct various performance tests.
Communicate with the server engineer to determine the details of the interface and protocol content between each other.
Unity itself does not have a Gameplay Framework, and relatively low-level frameworks such as scene management and game data management need Unity engineers to build. How to reduce the erroneous practices of other members of the team is the responsibility of the main program, but also tests its architectural ability and understanding of Unity Runtime.
Some special effects can only be achieved by writing your own Shader.
The assets generated by animators and art teams often have to write their own Pipeline to import and optimize according to the needs of the project. Some of them also need to be packaged in an appropriate way for clients to download incrementally, and a good understanding of Unity's resource pipeline is needed. And seemingly simple decisions often contain a lot of performance considerations.
According to the needs of the level designer, make the editor extension tool to improve its work efficiency. There is little documentation in this area, and a deep understanding of Unity's unique serialization mechanism is required.
When you want to take advantage of iOS and Android and various platform-specific features, you need to write some Native plug-ins for specific platforms, such as local Push notifications, custom system keyboards, system pop-up windows, and so on. Only if you have some knowledge of iOS development and Android development can you control it.
Some Unity engineers may just set up levels and write control scripts, while the value of good Unity engineers is that they can take on more team responsibilities. So it takes a lot of time and effort to be proficient in this.
The difficulty lies in the details
Details are very important if you want to be proficient in anything, such as:
Memory management
Avoid and troubleshoot memory leaks in scripts. For example, references caused by unemptied delegates and static closures.
Optimize GC to understand the differences between Mono and .NET GC algorithms. For example, Unity uses an older version of Boehm GC, regardless of generations, GC pagination is 1KB, memory fragments cannot be merged, single thread, lack of LOH, once the managed heap is expanded, it is difficult to return memory to the system. If you optimize GC according to. Net ideas, sometimes it does not have the desired results. However, the IL2CPP runtime introduced by Unity recently adopts a new version of Boehm GC, the algorithm has changed, and the optimization strategy should be adjusted appropriately.
Learn about Unity's memory model, which resources are allocated on the Native heap and which resources are allocated on the Mono managed heap. Different kinds of resources on Native can be released cleanly in which ways. How the reference count on the Native heap works. How to relieve the pressure when Unity automatically releases the scene. What is the memory structure of AssetBundle, and how each part is precisely released without relying on GC.
How to temporarily release a hidden picture or object and how to reload it back into memory when displayed.
Learn which API and operations allocate memory and when using value types is better or worse. All this requires a deep understanding of C#.
Network and download
How to package AssetBundle, what kind of images and what granularity is the most efficient.
If you use Json to deserialize data, how can you avoid memory fragmentation that degrades the performance of the entire App.
Constantly updated materials need to be downloaded incrementally. Where is the bottleneck of Unity's built-in download mode? how to implement a more efficient download mechanism and more accurate cache control mechanism than Unity's built-in API?
Script execution
You can put more complex operations (such as deserialization data, heavy IO operations) in the background thread, and then schedule back to the main thread to update the game interface to avoid UI stutters. What is the thread priority of Unity?
Can you understand the iterator nature of Unity Coroutine, how to handle exceptions in Coroutine, how to make Coroutine have a return value, how much memory will be allocated when Coroutine starts, why complex Coroutine will use more memory, and how to merge multiple Coroutine into one to eliminate memory allocation.
How to make C # share memory with Objective C or Java when interacting with Native plug-ins (such as iOS plug-ins), thereby reducing the CPU burden caused by large data marshaling.
What are the root causes and what are the root causes of AOT exceptions on the iOS platform? The combination of value types and generics makes it easier to throw AOT exceptions and how to bypass them. How to use Linq safely, why to use C# standard events to trigger AOT exceptions, and how to avoid them. What is the trampoline of Mono AOT, and which style of code is more likely to deplete trampoline and throw AOT exceptions.
What are the weaknesses of Unity's C # compiler, and which code is compiled into DLL through Visual Studio and then put into Unity can improve execution efficiency and memory usage efficiency.
How to optimize the internal problems such as slow loading of the scene in Unity from its own script. Or what are the parts of Critical Path in your own code with different performance issues.
Render
What is Draw Call. How to Batch small pictures in different AssetBundle into a Draw Call.
What are the weaknesses of Tile-based GPU commonly used on mobile platforms and how to avoid them?
When making 2D games on high-definition screens such as Retina, how to dynamically generate the smallest Mesh grid for pictures to save fill rate.
Teamwork
How to control memory leaks in teammate code when you write your own Gameplay framework.
What are the intractable conflicts when using the version management system, and how to establish the development rules. Whether the framework or tools developed by yourself can effectively avoid conflicts between teammates.
How to realize the automation of resource pipeline.
How to convert the output of various exotic animation editors into Unity standard animation resources.
Whether complex data structures can be serialized correctly when making editor extensions. Can you let your own tools and scripts also achieve WYSIWYG, so that teammates can build the scene faster.
Whether Gizmo and Handle will be used to expand the scene Editor.
When you have to modify the definition of MonoBehaviour, how to deserialize the data in the old version that is already online to the new version correctly.
Be able to write reusable code and components with well-defined modules and reasonable dependencies to accelerate the development of new projects as the company's assets.
These are the problems that will be faced constantly in Unity development. If these details are not controlled from beginning to end, the accumulation will often make the team inefficient and difficult to produce high-quality applications.
So I think Unity is difficult to master lies in the grasp of detailed knowledge, and in the integration of team values in the process of how to enhance strengths and circumvent weaknesses. Not everyone in the Unity development team has a deep understanding of this engine. Everyone specializes in technology, some people build scenes, some people do the back end, and they inevitably have misunderstandings and practices in areas they are not familiar with. We can still master the details through time and effort, but what is really missing in the end is the reduction in communication costs brought about by trust among team members.
[update]
Answer some friends' questions.
About the source of information
It is difficult to have a systematic source of data on detailed questions, while questions like AssetBundle Dynamic Batch, which can hardly be answered, can only be fumbled for themselves. Here are some of the main sources of knowledge.
The official manual. For example, search Unity Optimization to find several official optimization manuals on GPU,CPU and Mobile. Official materials often contain the core and most easily overlooked principles, and in-depth understanding will often lead to new gains.
Official blog. From time to time, there are some technical articles on the blog, such as the knowledge about IL2CPP and serialization mechanism can only be read on those blogs. Technology
Unite video and Slide. There are more in-depth discussions in some areas, especially in memory management, AssetBundle and code organization. Search YouTube and SlideShare for Unite or Unity to find it. It is worth noting that Unite branches, such as Japan and South Korea, sometimes have some more in-depth analysis. Pages such as slideshare.net
Unity's Mono fork:Unity-Technologies/mono GitHub is firsthand information about GC and AOT. For example, the configuration of gc, how the implementation of Enumerable class causes Linq to easily trigger AOT exceptions, and the existence of JIT Hack in generic CompareExchange causes C# events and some thread synchronization operations to trigger AOT exceptions, and so on. In addition, GC can also refer to ivmai/bdwgc GitHub, there is a detailed mechanism to explain.
UI source code: Unity-Technologies / UI, modified and optimized can be directly integrated into the game, very convenient.
PDB debug files installed with Unity. The installation directory of Unity actually has all the Editor and Player source code PDB files of C++, and they are all private PDB. When you need to explore the internal data structures and process implementations of Unity, you can get a lot of bottom-level information by debugging Unity processes with these PDB files through WinDbg. Of course, if the company bought the source code of Unity, it would not be so troublesome.
On the optimization strategy
Not only Unity, the most important principle of the optimizer is to measure first. And without rich experience and confidence, don't write your own measurement code, but rely on Unity's own Profiler and Profiler API. I'll just talk about some of the things that are specific to Unity.
When using Profiler, do not guess. Be sure to figure out the exact meaning of all kinds of data, such as Self%, Self ms,GC Alloc, etc., if you don't, optimization is often in the opposite direction. In addition, when diagnosing CPU Spike, be sure to turn on Deep Profile, otherwise you can only see misleading surface data. Only when you find the real Hot Line can you start to optimize and improve performance.
When Hot Line is in its own code, you can try to dispatch CPU-intensive operations to background threads and then dispatch them back when you need to interact with Unity API. Better-grained operations can try to be dispatched to other frames using Coroutine to perform separately. The Spike caused by a large number of GC Alloc needs to redesign the memory allocation policy. When there are more small objects (the current version is smaller than 1KB), you can also try to expand the managed heap in advance (such as allocating a lot of buffers smaller than 1KB, and then releasing it), which can speed up subsequent memory allocation. Because Boehm GC's heap expansion strategy is time-linear rather than spatial-linear, the capacity of each expansion is doubled, which needs to be noted.
When Hot Line is in Unity API, it is often caused by its own erroneous practice, which requires a re-examination of the design. On the one hand, it is necessary to reduce the number of expensive API calls, on the other hand, it is necessary to reduce the scale of data processing within Unity. For example, when the scene loads slowly, you may need to simplify the scene itself, and then load the rest of the scene manually and incrementally after the scene starts.
In addition, we need to know some basic knowledge. For example, the poor performance of App during startup may be caused by a large number of JIT compilations on non-AOT platforms, while on AOT platforms, the CPU cache hit rate may be very low due to the complexity of initialization code, and the operating system frequently Page Fault. This is why the startup code must be simplified and batch processing should be implemented as much as possible.
On the GPU side, if there are no complex special effects, the bottleneck is often on Draw Call and Fill Rate. Draw Call needs Batch, and materials that can be shared must be shared. The problem with Fill Rate is usually obvious in high-resolution 2D games, and optimization should be started when Transparency rendering accounts for a large proportion of Profiler rendering. Compared with other engines, Unity does not have many specific aspects in GPU optimization strategy, and a general solution can usually be found on the basis of accurate measurement.
This is the end of the content of "what are the basic knowledge points of the game engine Unity". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.