Method and system for automatically combining atlas with UI chartlets
Through the automated UI map combination method, combined with the image set size threshold and reference probability, intelligent packaging of UI maps is realized, solving the problems of manpower and errors in the traditional packaging process, and improving game performance and efficiency.
Patent Information
- Application Number
- CN202310678203.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-08
- Publication Date
- 2024-12-10
AI Technical Summary
In game UI development, the traditional UI map packaging process requires a lot of manpower to consume labor and is prone to errors. As the map increases, the packaging method needs to be changed, resulting in manual repeated investment and potential performance problems.
A method of automatically combining picture sets of UI maps is adopted. By setting the size threshold of the picture set, the permanent and non-resident UI interfaces are identified, the maps are merged according to the citation probability and the occurrence probability, and the classification merge is dynamically loaded, and the merge is judged by the SpritePacker component of the Unity3d engine. The size of the picture atlas.
Reduces game memory usage and DrawCall count, saves labor time, reduces packaging errors, speeds up project progress, and optimizes game performance.
Smart Images

Figure CN119097921A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer communication technology, and in particular to a method and system for automatically combining UI maps into a collection. Background Art
[0002] In game UI development, multiple textures need to be packaged into an atlas for performance reasons. Usually, textures are selected and packaged into atlases based on developer experience. This requires developers to spend a lot of time thinking about how to package atlases, and the packaging of atlases will also change the method of combining atlases according to the increase of UI textures. If atlas packaging is handled by manpower, it will not only take a lot of man-hours but also be prone to errors. Summary of the invention
[0003] To overcome the above problems, the purpose of the present invention is to provide a method for automatically combining UI texture atlases, which can realize the tool's automatic execution of atlas packaging, save a lot of man-hours, and reduce atlas packaging errors.
[0004] The present invention is implemented by the following scheme: a method for automatically combining UI maps into a collection of maps, the method comprising the following steps:
[0005] Step S1, setting a threshold 1 of the atlas size in the game, obtaining a unique UI texture of a single UI interface in all UI interface prefabs, and merging all unique UI textures in a single UI interface into one or more atlases 1 according to the interface name;
[0006] Step S2, identifying the resident UI interface and the non-resident UI interface in the UI interface, merging the UI textures of the resident UI interface into one or more UI textures according to the threshold 1 of the atlas, traversing the UI interfaces of the non-resident UI interface through the UI textures referenced by the resident UI interface, obtaining the reference probability of the UI interface of the non-resident UI interface to the UI texture referenced by the resident UI interface, and merging the UI textures into one or more atlases 2 according to the probability from large to small;
[0007] Step S3, determining the probability of all UI maps that are not unique to a single interface of the non-resident UI interface appearing in the non-resident UI interface prefab, merging all UI maps that are not unique to a single interface of the non-resident UI interface according to the probability from large to small, and forming one or more atlases 3 when the size of the merged maps reaches the atlas threshold 1;
[0008] Step S4, dynamically loaded UI stickers are classified according to type, and a threshold 2 for the number of UI stickers of the same type is set. When the number of UI stickers of the same type is less than the threshold 2, they are merged into an atlas 4; when the number of UI stickers of the same type is more than the threshold 2, they are not merged.
[0009] Furthermore, the step 1 is further as follows: setting a threshold 1 for the atlas size in the game, traversing all UI interface prefabs to determine in which UI interface each UI texture appears, if the number of appearances in the UI interface is 1, then the UI texture is a unique texture for the UI interface, establishing atlas 1, merging all unique UI textures for the UI interface into atlas 1 according to the interface name, when the size of the merged textures in atlas 1 reaches threshold 1, creating a new atlas 1 to continue merging until all unique UI textures of all single UI interfaces are merged.
[0010] Furthermore, the step 2 is further as follows: according to the configuration of the game UI interface, the resident UI interface and the non-resident UI interface in the UI interface are identified, and the UI textures of the resident UI interface are merged into one or more UI textures according to the threshold 1 of the atlas, and the UI textures referenced by the resident UI interface traverse the UI interfaces of the non-resident UI interfaces, and the reference probability of the UI interfaces of the non-resident UI interfaces to the UI textures referenced by the resident UI interface is obtained, and the atlas 2 is established, and the textures with large probabilities are merged into atlas 2 first, and the probability value of the merged texture is the value with the largest probability of the merged texture, and the textures are continued to be sorted from large to small. The two textures with the largest probability of repetition are merged into atlas 2, and when the size of the merged texture in atlas 2 reaches threshold 1, a new atlas 2 is established to continue merging until all UI textures referenced by the resident UI interfaces are merged.
[0011] Furthermore, the step 3 is further as follows: collect and cache all non-resident UI interfaces' non-single-interface unique UI maps, traverse all non-resident UI interface prefabricated bodies, obtain the probability of the collected and cached UI maps appearing in these non-resident UI interface prefabricated bodies, sort the collected and cached UI maps by probability from large to small, establish atlas 3, merge the two maps with the highest probability into atlas 3 first, the probability value of the merged map is the value with the highest probability of the merged map, continue to sort the maps by probability value from large to small, repeat and merge the two maps with the highest probability into atlas 3, and when the size of the merged map in atlas 3 reaches threshold 1, establish a new atlas 3 and continue merging until all collected and cached non-interface unique UI maps and non-resident interface maps are merged.
[0012] Furthermore, a method for determining whether the size of the UI texture in the atlas reaches a threshold is to call the atlas packing SpritePacker component in the Unity3d engine, select the texture to be merged into the atlas, and obtain the size of the atlas after the merger.
[0013] The present invention also provides a system for automatically combining UI stickers into a collection of pictures, the system comprising a unique UI sticker synthesis module for a single UI interface, a UI sticker synthesis module for a resident UI interface, a UI sticker synthesis module for a non-resident UI interface that is not unique to a single interface, and a dynamically loaded UI sticker synthesis module;
[0014] The unique UI texture synthesis module of the single UI interface: setting a threshold 1 of the atlas size in the game, obtaining the unique UI texture of the single UI interface in all UI interface prefabs, and merging all the unique UI textures in the single UI interface into one or more atlases 1 according to the interface name;
[0015] The UI texture synthesis module of the resident UI interface: identifies the resident UI interface and the non-resident UI interface in the UI interface, merges the UI textures of the resident UI interface into one or more UI textures according to the threshold 1 of the atlas, traverses the UI interfaces of the non-resident UI interface with the UI textures referenced by the resident UI interface, obtains the reference probability of the UI interface of the non-resident UI interface to the UI texture referenced by the resident UI interface, and merges the UI textures into one or more atlases 2 from large to small according to the probability;
[0016] The non-resident UI interface non-single-interface unique UI texture synthesis module: determines the probability of all non-resident UI interfaces non-single-interface unique UI textures appearing in the non-resident UI interface prefab, merges all non-resident UI interfaces non-single-interface unique UI textures according to the probability from large to small, and forms one or more atlases 3 when the merged texture size reaches the atlas threshold 1;
[0017] The dynamically loaded UI texture synthesis module: dynamically loaded UI textures are classified according to type, and a threshold value 2 for the number of UI textures of the same type is set. When the number of UI textures of the same type is less than the threshold 2, they are merged into an atlas 4. When the number of UI textures of the same type is more than the threshold 2, they are not merged.
[0018] Furthermore, the unique UI texture synthesis module for a single UI interface is further as follows: a threshold 1 for the atlas size in the game is set, all UI interface prefabs are traversed to determine in which UI interface each UI texture appears, if the number of appearances in a UI interface is 1, then the UI texture is a unique texture for the UI interface, and atlas 1 is established, all unique UI textures for the UI interface are merged into atlas 1 according to the interface name, and when the size of the merged textures in atlas 1 reaches threshold 1, a new atlas 1 is created to continue merging until all unique UI textures for a single UI interface are merged.
[0019] Furthermore, the UI texture synthesis module of the permanent UI interface is further: according to the configuration of the game UI interface, the permanent UI interface and the non-resident UI interface in the UI interface are identified, the UI textures of the permanent UI interface are merged into one or more UI textures according to the threshold value 1 of the atlas, the UI textures referenced by the resident UI interface traverse the UI interfaces of the non-resident UI interfaces, and the reference probability of the UI interfaces of the non-resident UI interfaces to the UI textures referenced by the resident UI interface is obtained, and the atlas 2 is established, and the ones with large probabilities are merged into atlas 2 first, and the probability value of the merged texture is the one with the largest probability of the merged texture, and the textures are continued to be sorted from large to small. The two textures with the largest probability of repetition are merged into atlas 2, and when the size of the merged texture in atlas 2 reaches threshold 1, a new atlas 2 is established to continue merging until all UI textures referenced by the resident UI interfaces are merged.
[0020] Furthermore, the non-resident UI interface non-single-interface unique UI texture synthesis module further comprises: collecting and caching all non-resident UI interface non-single-interface unique UI textures, traversing all non-resident UI interface prefabricated bodies, obtaining the probability of the collected and cached UI textures appearing in these non-resident UI interface prefabricated bodies, sorting the collected and cached UI textures from large to small according to probability, establishing atlas 3, and merging the two textures with the highest probability into atlas 3 first, and the probability value of the merged texture is the value with the highest probability of the merged texture, and continuing to sort the textures from large to small according to the probability value, merging the two textures with the highest probability of repetition into atlas 3, and when the size of the merged texture in atlas 3 reaches threshold 1, establishing a new atlas 3 and continuing to merge until all the collected and cached non-interface unique UI textures and non-resident interface textures are merged.
[0021] Furthermore, a method for determining whether the size of the UI texture in the atlas reaches a threshold is to call the atlas packing SpritePacker component in the Unity3d engine, select the texture to be merged into the atlas, and obtain the size of the atlas after the merger.
[0022] The beneficial effect of the present invention is that in order to load as few atlases as possible during the game running process (fewer drawcalls) and not load UI maps that are not currently used (less memory occupancy), traditional atlas packaging requires manual selection of UI maps and then packaging of atlases. This process requires a lot of manpower to identify, and the packaging situation is not static. As the number of maps increases, the atlas packaging needs to change accordingly, and manual repeated investment is required. Manual identification of packaged atlases is also prone to unfavorable performance of the packaged atlases due to human negligence, thereby affecting the loading of a large number of unused UI maps at a certain moment in the game, increasing the game's memory occupancy and Drawcall increase; the present invention is based on the principle of packaging UI maps that appear at the same time as much as possible into one or more atlases and not loading UI maps that are not used at a certain moment into the game as much as possible. UI maps that appear at the same time with a high probability are packaged into one atlas, reducing the game's memory occupancy and the number of Drawcalls, and tool-based execution of atlas packaging saves a lot of man-hours, reduces packaged atlas errors, speeds up the progress of the project, and optimizes the performance of the game. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] Figure 1 It is a schematic flow chart of the method of the present invention.
[0024] Figure 2 It is a system principle block diagram of the present invention.
[0025] Figure 3 It is a schematic diagram of setting the atlas name of a texture in one embodiment of the present invention.
[0026] Figure 4 It is a schematic diagram of an atlas tool determining the size of a currently merged texture in one embodiment of the present invention. DETAILED DESCRIPTION
[0027] The present invention will be further described below in conjunction with the accompanying drawings.
[0028] See also Figure 1 As shown, a method for automatically combining UI textures into a collection of textures of the present invention comprises the following steps:
[0029] Step S1, setting a threshold 1 of the atlas size in the game, obtaining a unique UI texture of a single UI interface in all UI interface prefabs, and merging all unique UI textures in a single UI interface into one or more atlases 1 according to the interface name;
[0030] Step S2, identifying the resident UI interface and the non-resident UI interface in the UI interface, merging the UI textures of the resident UI interface into one or more UI textures according to the threshold 1 of the atlas, traversing the UI interfaces of the non-resident UI interface through the UI textures referenced by the resident UI interface, obtaining the reference probability of the UI interface of the non-resident UI interface to the UI texture referenced by the resident UI interface, and merging the UI textures into one or more atlases 2 according to the probability from large to small;
[0031] Step S3, determining the probability of all UI maps that are not unique to a single interface of the non-resident UI interface appearing in the non-resident UI interface prefab, merging all UI maps that are not unique to a single interface of the non-resident UI interface according to the probability from large to small, and forming one or more atlases 3 when the size of the merged maps reaches the atlas threshold 1;
[0032] Step S4, dynamically loaded UI stickers are classified according to type, and a threshold 2 for the number of UI stickers of the same type is set. When the number of UI stickers of the same type is less than the threshold 2, they are merged into an atlas 4; when the number of UI stickers of the same type is more than the threshold 2, they are not merged.
[0033] The present invention will be further described below in conjunction with a specific embodiment:
[0034] A method for automatically combining UI textures into a collection of textures.
[0035] 1. Set the threshold of the atlas size in the game to 1, obtain the unique UI texture of a single UI interface in all UI interface prefabs, and merge all the unique UI textures in a single UI interface into one or more atlases 1 according to the interface name;
[0036] 1.1 Set the threshold of the atlas size in the game to 1, traverse all UI interface prefabs to determine in which UI interface each UI texture appears. If the number of appearances in a UI interface is 1, then the UI texture is the unique texture of the UI interface, and establish atlas 1. Merge all unique UI textures of the UI interface into atlas 1 according to the interface name. When the size of the merged textures in atlas 1 reaches threshold 1, create a new atlas 1 to continue merging until all unique UI textures of a single UI interface are merged.
[0037] For example: Set the maximum threshold 1 of the atlas in the game to 1024*1024, and merge the UI maps set by the Unity3d engine into one atlas according to the name of the PackingTag parameter of the UI map set by the Unity3d engine as the name of the UI interface. When the size of the atlas exceeds 1024*1024, the newly created atlas will continue to be merged.
[0038] 2. Identify the resident UI interface and the non-resident UI interface in the UI interface, merge the UI textures of the resident UI interface into one or more UI textures according to the threshold 1 of the atlas, traverse the UI interfaces of the non-resident UI interface with the UI textures referenced by the resident UI interface, obtain the probability of the UI interface of the non-resident UI interface to reference the UI textures referenced by the resident UI interface, and merge the UI textures into one or more atlases 2 according to the probability from large to small; the probability of the UI interface of the non-resident UI interface to reference the UI textures referenced by the resident UI interface is the probability of the UI textures of the resident UI interface appearing in the non-resident UI interface, merge the UI textures of the resident UI interface with a high probability together, and then open the non-resident UI interface in the game, so that fewer unused UI texture resources can be loaded.
[0039] 2.2 According to the configuration of the game UI interface, the resident UI interface and the non-resident UI interface are identified in the UI interface, and the UI textures of the resident UI interface are merged into one or more UI textures according to the threshold 1 of the atlas. The UI textures referenced by the resident UI interface traverse the UI interfaces of the non-resident UI interface, and the reference probability of the UI interface of the non-resident UI interface to the UI texture referenced by the resident UI interface is obtained, and the probability is sorted from large to small to establish atlas 2. The textures with large probability are first merged into atlas 2. The probability value of the merged texture is the value with the largest probability of the merged texture, and the texture probability value is continued to be sorted from large to small. The two textures with the largest probability of repetition are merged into atlas 2. When the size of the merged texture in atlas 2 reaches the threshold 1, a new atlas 2 is established to continue merging until all UI textures referenced by the resident UI interface are merged. The purpose of obtaining the reference probability of the UI interface of the non-resident UI interface to the UI texture referenced by the resident UI interface is to determine whether the UI component of the UI interface uses the UI texture.
[0040] 3. Determine the probability of all UI maps that are not unique to a single interface of non-resident UI interfaces appearing in the non-resident UI interface prefab, merge all UI maps that are not unique to a single interface of non-resident UI interfaces according to the probability from large to small, and form one or more atlases 3 when the size of the merged maps reaches the atlas threshold 1;
[0041] 3.1 Collect and cache all UI textures that are not unique to a single interface of non-resident UI interfaces, traverse all non-resident UI interface prefabricated bodies, obtain the probability of the collected and cached UI textures appearing in these non-resident UI interface prefabricated bodies, sort the collected and cached UI textures from large to small by probability, establish atlas 3, merge the two textures with the highest probability into atlas 3 first, and the probability value of the merged texture is the value of the highest probability of the merged texture, continue to sort by texture probability value from large to small, merge the two textures with the highest probability of repetition into atlas 3, and when the size of the merged texture in atlas 3 reaches threshold 1, establish a new atlas 3 and continue to merge until all collected and cached non-interface unique UI textures and non-resident interface textures are merged. The sorting from large to small by texture probability value includes the previously merged textures.
[0042] 4. Dynamically loaded UI textures are classified by type, and a threshold of 2 is set for the number of UI textures of the same type. When the number of UI textures of the same type is less than the threshold 2, they are merged into atlas 4. When the number of UI textures of the same type is more than the threshold 2, they are not merged.
[0043] For example: dynamically loaded UI maps are classified into categories such as items and avatars. If they are all avatar categories, it is determined whether the number of dynamically loaded UI maps in the avatar category is greater than the threshold and is less than the set threshold of 2. If it is less, they are merged into an atlas. If the number of item categories is large and greater than the set threshold of 2, if there are several items in the package that are in different atlases of the items, all the item icons may be pulled into the memory, and the atlases will not be merged.
[0044] The atlas UI textures in the previous steps are all different, that is, there are no duplicate UI textures in each atlas, and the UI textures in each step are of different types. Step 1 merges the unique UI texture of a single UI interface among all UI interfaces (which only appears in this UI interface), step 2 merges all UI textures of the resident UI interface, step 3 merges UI textures that are neither non-resident UI interface textures nor unique textures of each UI interface, and step 4 merges the UI textures that are dynamically loaded; steps 1, 2, and 3 merge static UI textures fixed to the UI interface.
[0045] The method to determine whether the size of the UI texture in the atlas reaches the threshold is to call the atlas packing SpritePacker component in the Unity3d engine, select the texture to be merged into the atlas, and obtain the size of the atlas after the merger. Figure 4As shown, the engine comes with an atlas tool to determine the size of the currently merged texture. The Unity3d engine sets the Packing Tag of a UI texture after selecting it. UI textures with the same field name will be automatically packaged into an atlas. Other engines also have existing technologies to achieve fast or automatic packaging of atlases, and other ready-made tools can also be used.
[0046] See also Figure 2 As shown, the present invention also provides a system for automatically combining UI stickers into a collection, the system comprising a unique UI sticker synthesis module for a single UI interface, a UI sticker synthesis module for a resident UI interface, a UI sticker synthesis module for a non-resident UI interface that is not unique to a single interface, and a dynamically loaded UI sticker synthesis module;
[0047] The unique UI texture synthesis module of the single UI interface: setting a threshold 1 of the atlas size in the game, obtaining the unique UI texture of the single UI interface in all UI interface prefabs, and merging all the unique UI textures in the single UI interface into one or more atlases 1 according to the interface name;
[0048] 1.1 Set the threshold of the atlas size in the game to 1, traverse all UI interface prefabs to determine in which UI interface each UI texture appears. If the number of appearances in a UI interface is 1, then the UI texture is the unique texture of the UI interface, and establish atlas 1. Merge all unique UI textures of the UI interface into atlas 1 according to the interface name. When the size of the merged textures in atlas 1 reaches threshold 1, create a new atlas 1 to continue merging until all unique UI textures of a single UI interface are merged.
[0049] For example: Set the maximum threshold 1 of the atlas in the game to 1024*1024, and merge the UI maps set by the Unity3d engine into one atlas according to the name of the PackingTag parameter of the UI map set by the Unity3d engine as the name of the UI interface. When the size of the atlas exceeds 1024*1024, the newly created atlas will continue to be merged.
[0050] The UI texture synthesis module of the resident UI interface: identifies the resident UI interface and the non-resident UI interface in the UI interface, merges the UI textures of the resident UI interface into one or more UI textures according to the threshold 1 of the atlas, traverses the UI interfaces of the non-resident UI interfaces with the UI textures referenced by the resident UI interface, obtains the probability of the UI interfaces of the non-resident UI interfaces to reference the UI textures referenced by the resident UI interface, and merges the UI textures into one or more atlases 2 according to the probability from large to small; the probability of the UI interfaces of the non-resident UI interfaces to reference the UI textures referenced by the resident UI interface is the probability of the UI textures of the resident UI interface appearing in the non-resident UI interface, merges the UI textures of the resident UI interface with a large probability together, and then opens the non-resident UI interface in the game, which can load fewer unused UI texture resources.
[0051] 2.2 According to the configuration of the game UI interface, the resident UI interface and the non-resident UI interface are identified in the UI interface, and the UI textures of the resident UI interface are merged into one or more UI textures according to the threshold 1 of the atlas. The UI textures referenced by the resident UI interface traverse the UI interfaces of the non-resident UI interface, and the reference probability of the UI interface of the non-resident UI interface to the UI texture referenced by the resident UI interface is obtained, and the probability is sorted from large to small to establish atlas 2. The textures with large probability are first merged into atlas 2. The probability value of the merged texture is the value with the largest probability of the merged texture, and the texture probability value is continued to be sorted from large to small. The two textures with the largest probability of repetition are merged into atlas 2. When the size of the merged texture in atlas 2 reaches the threshold 1, a new atlas 2 is established to continue merging until all UI textures referenced by the resident UI interface are merged. The purpose of obtaining the reference probability of the UI interface of the non-resident UI interface to the UI texture referenced by the resident UI interface is to determine whether the UI component of the UI interface uses the UI texture.
[0052] The non-resident UI interface non-single-interface unique UI texture synthesis module: determines the probability of all non-resident UI interfaces non-single-interface unique UI textures appearing in the non-resident UI interface prefab, merges all non-resident UI interfaces non-single-interface unique UI textures according to the probability from large to small, and forms one or more atlases 3 when the merged texture size reaches the atlas threshold 1;
[0053] 3.1 Collect and cache all UI textures that are not unique to a single interface of non-resident UI interfaces, traverse all non-resident UI interface prefabricated bodies, obtain the probability of the collected and cached UI textures appearing in these non-resident UI interface prefabricated bodies, sort the collected and cached UI textures from large to small by probability, establish atlas 3, merge the two textures with the highest probability into atlas 3 first, and the probability value of the merged texture is the value of the highest probability of the merged texture, continue to sort by texture probability value from large to small, merge the two textures with the highest probability of repetition into atlas 3, and when the size of the merged texture in atlas 3 reaches threshold 1, establish a new atlas 3 and continue to merge until all collected and cached non-interface unique UI textures and non-resident interface textures are merged. The sorting from large to small by texture probability value includes the previously merged textures.
[0054] The dynamically loaded UI texture synthesis module: dynamically loaded UI textures are classified according to type, and a threshold value 2 for the number of UI textures of the same type is set. When the number of UI textures of the same type is less than the threshold 2, they are merged into an atlas 4. When the number of UI textures of the same type is more than the threshold 2, they are not merged.
[0055] For example: dynamically loaded UI maps are classified into categories such as items and avatars. If they are all avatar categories, it is determined whether the number of dynamically loaded UI maps in the avatar category is greater than the threshold and is less than the set threshold of 2. If it is less, they are merged into an atlas. If the number of item categories is large and greater than the set threshold of 2, if there are several items in the package that are in different atlases of the items, all the item icons may be pulled into the memory, and the atlases will not be merged.
[0056] The atlas UI textures in the previous steps are all different, that is, there are no repeated UI textures in each atlas, and the UI textures in each step are of different types. The unique UI texture synthesis module of a single UI interface merges the unique UI texture of a single UI interface among all UI interfaces (which only appears in this UI interface), the UI texture synthesis module of the resident UI interface merges all UI textures of the resident UI interface, the UI texture synthesis module of the non-resident UI interface that is not unique to a single interface merges UI textures that are neither non-resident UI interface textures nor unique to each UI interface, the dynamically loaded UI texture synthesis module merges dynamically loaded UI textures; the unique UI texture synthesis module of a single UI interface, the UI texture synthesis module of the resident UI interface, and the UI texture synthesis module of the non-resident UI interface that is not unique to a single interface merge static UI textures fixed to the UI interface.
[0057] The method to determine whether the size of the UI texture in the atlas reaches the threshold is to call the atlas packing SpritePacker component in the Unity3d engine, select the texture to be merged into the atlas, and obtain the size of the atlas after the merger. Figure 4 As shown, the engine comes with an atlas tool to determine the size of the currently merged texture. The Unity3d engine sets the Packing Tag of a UI texture after selecting it. UI textures with the same field name will be automatically packaged into an atlas. Other engines also have existing technologies to achieve fast or automatic packaging of atlases, and other ready-made tools can also be used.
[0058] In summary, the present invention is based on the principle of packaging UI textures that are likely to appear at the same time into one or more atlases and not loading UI textures that are not used at a certain moment into the game as much as possible. UI textures that appear at the same time with a high probability are packaged into one atlas, which reduces the game memory usage and the number of DrawCalls. The tool-based execution of atlas packaging saves a lot of work hours, reduces atlas packaging errors, speeds up the progress of the project, and optimizes the performance of the game.
[0059] The above description is only a preferred embodiment of the present invention. All equivalent changes and modifications made according to the scope of the patent application of the present invention should fall within the scope of the present invention.
Claims
1. A method for automatically combining UI maps into a collection of maps, characterized in that: The method comprises the following steps: Step S1, setting a threshold 1 of the atlas size in the game, obtaining a unique UI texture of a single UI interface in all UI interface prefabs, and merging all unique UI textures in a single UI interface into one or more atlases 1 according to the interface name; Step S2, identifying the resident UI interface and the non-resident UI interface in the UI interface, merging the UI textures of the resident UI interface into one or more UI textures according to the threshold 1 of the atlas, traversing the UI interfaces of the non-resident UI interface through the UI textures referenced by the resident UI interface, obtaining the reference probability of the UI interface of the non-resident UI interface to the UI texture referenced by the resident UI interface, and merging the UI textures into one or more atlases 2 according to the probability from large to small; Step S3, determining the probability of all UI maps that are not unique to a single interface of the non-resident UI interface appearing in the non-resident UI interface prefab, merging all UI maps that are not unique to a single interface of the non-resident UI interface according to the probability from large to small, and forming one or more atlases 3 when the size of the merged maps reaches the atlas threshold 1; Step S4, dynamically loaded UI stickers are classified according to type, and a threshold 2 for the number of UI stickers of the same type is set. When the number of UI stickers of the same type is less than the threshold 2, they are merged into an atlas 4; when the number of UI stickers of the same type is more than the threshold 2, they are not merged.
2. The method for automatically combining UI stickers into a set of atlases according to claim 1, characterized in that: The step 1 is further as follows: setting a threshold 1 for the atlas size in the game, traversing all UI interface prefabs to determine on which UI interface each UI texture appears, if the number of appearances in a UI interface is 1, then the UI texture is a unique texture for the UI interface, establishing atlas 1, merging all unique UI textures for the UI interface into atlas 1 according to the interface name, and when the size of the merged textures in atlas 1 reaches threshold 1, creating a new atlas 1 to continue merging until all unique UI textures of a single UI interface are merged.
3. The method for automatically combining UI stickers into a set of atlases according to claim 1, characterized in that: The step 2 is further as follows: according to the configuration of the game UI interface, the resident UI interface and the non-resident UI interface in the UI interface are identified, the UI textures of the resident UI interface are merged into one or more UI textures according to the threshold 1 of the atlas, the UI textures referenced by the resident UI interface traverse the UI interfaces of the non-resident UI interfaces, and the reference probability of the UI interfaces of the non-resident UI interfaces to the UI textures referenced by the resident UI interface is obtained, and the atlas 2 is established. The textures with large probabilities are merged into atlas 2 first, and the probability value of the merged textures is the value with the largest probability of the merged textures, and the textures are continued to be sorted from large to small according to the probability value, and the two textures with the largest probability of repetition are merged into atlas 2. When the size of the merged textures in atlas 2 reaches threshold 1, a new atlas 2 is established and the merging continues until all UI textures referenced by the resident UI interfaces are merged.
4. The method for automatically combining UI stickers into a set of atlases according to claim 1, characterized in that: The step 3 is further as follows: collecting and caching all non-resident UI interfaces' non-single-interface unique UI maps, traversing all non-resident UI interface prefabricated bodies, obtaining the probability of the collected and cached UI maps appearing in these non-resident UI interface prefabricated bodies, sorting the collected and cached UI maps by probability from large to small, establishing atlas 3, merging the two maps with the highest probability into atlas 3 first, and the probability value of the merged maps is the value with the highest probability of the merged maps, continuing to sort the maps by probability value from large to small, merging the two maps with the highest probability of repetition into atlas 3, and when the size of the merged maps in atlas 3 reaches threshold 1, establishing a new atlas 3 and continuing to merge until all collected and cached non-interface unique UI maps and non-resident interface maps are merged.
5. The method for automatically combining UI stickers into a set of atlases according to claim 1, characterized in that: The method for judging whether the size of the UI texture in the atlas reaches the threshold is to call the atlas packing SpritePacker component in the Unity3d engine, select the texture to be merged into the atlas, and obtain the size of the atlas after the merger.
6. A system for automatically combining UI stickers into a collection of stickers, characterized in that: The system includes a unique UI texture synthesis module for a single UI interface, a UI texture synthesis module for a resident UI interface, a UI texture synthesis module for a non-resident UI interface that is not unique to a single interface, and a dynamically loaded UI texture synthesis module; The unique UI texture synthesis module of the single UI interface: setting a threshold 1 of the atlas size in the game, obtaining the unique UI texture of the single UI interface in all UI interface prefabs, and merging all the unique UI textures in the single UI interface into one or more atlases 1 according to the interface name; The UI texture synthesis module of the resident UI interface: identifies the resident UI interface and the non-resident UI interface in the UI interface, merges the UI textures of the resident UI interface into one or more UI textures according to the threshold 1 of the atlas, traverses the UI interfaces of the non-resident UI interface with the UI textures referenced by the resident UI interface, obtains the reference probability of the UI interface of the non-resident UI interface to the UI texture referenced by the resident UI interface, and merges the UI textures into one or more atlases 2 from large to small according to the probability; The non-resident UI interface non-single-interface unique UI texture synthesis module: determines the probability of all non-resident UI interfaces non-single-interface unique UI textures appearing in the non-resident UI interface prefab, merges all non-resident UI interfaces non-single-interface unique UI textures according to the probability from large to small, and forms one or more atlases 3 when the merged texture size reaches the atlas threshold 1; The dynamically loaded UI texture synthesis module: dynamically loaded UI textures are classified according to type, and a threshold value 2 for the number of UI textures of the same type is set. When the number of UI textures of the same type is less than the threshold 2, they are merged into an atlas 4. When the number of UI textures of the same type is more than the threshold 2, they are not merged.
7. The system for automatically combining UI stickers according to claim 6, characterized in that: The unique UI texture synthesis module for a single UI interface is further as follows: a threshold value 1 for the atlas size in the game is set, all UI interface prefabs are traversed to determine on which UI interface each UI texture appears, if the number of appearances in a UI interface is 1, then the UI texture is a unique texture for the UI interface, and atlas 1 is established, all unique UI textures for the UI interface are merged into atlas 1 according to the interface name, and when the size of the merged textures in atlas 1 reaches threshold 1, a new atlas 1 is created to continue merging until all unique UI textures for a single UI interface are merged.
8. The system for automatically combining UI stickers into a collection according to claim 6, characterized in that: The UI texture synthesis module of the permanent UI interface is further as follows: according to the configuration of the game UI interface, the permanent UI interface and the non-resident UI interface in the UI interface are identified, the UI textures of the permanent UI interface are merged into one or more UI textures according to the threshold value 1 of the atlas, the UI textures referenced by the resident UI interface traverse the UI interfaces of the non-resident UI interfaces, and the reference probability of the UI interfaces of the non-resident UI interfaces to the UI textures referenced by the resident UI interface is obtained, and the atlas 2 is established. The ones with large probabilities are merged into atlas 2 first, and the probability value of the merged texture is the one with the largest probability of the merged texture, and the texture probability value continues to be sorted from large to small, and the two textures with the largest probability of duplication are merged into atlas 2. When the size of the merged texture in atlas 2 reaches threshold 1, a new atlas 2 is established to continue merging until all UI textures referenced by the resident UI interfaces are merged.
9. The system for automatically combining UI stickers into a collection according to claim 6, characterized in that: The non-resident UI interface's non-single-interface-unique UI texture synthesis module further comprises: collecting and caching all non-resident UI interface's non-single-interface-unique UI textures, traversing all non-resident UI interface prefabricated bodies, obtaining the probability of the collected and cached UI textures appearing in these non-resident UI interface prefabricated bodies, sorting the collected and cached UI textures from large to small by probability, establishing atlas 3, merging the two textures with the highest probability into atlas 3 first, and the probability value of the merged texture is the value with the highest probability of the merged texture, continuing to sort the textures from large to small by probability value, merging the two textures with the highest probability of repetition into atlas 3, and when the size of the merged texture in atlas 3 reaches threshold 1, establishing a new atlas 3 and continuing to merge until all the collected and cached non-interface-unique UI textures and non-resident interface textures are merged.
10. The system for automatically combining UI stickers into a collection according to claim 6, characterized in that: The method for judging whether the size of the UI texture in the atlas reaches the threshold is to call the atlas packing SpritePacker component in the Unity3d engine, select the texture to be merged into the atlas, and obtain the size of the atlas after the merger.
