CN113051230A - Method and storage medium for clearing UI picture resources by Laya project - Google Patents

Method and storage medium for clearing UI picture resources by Laya project Download PDF

Info

Publication number
CN113051230A
CN113051230A CN201911378631.6A CN201911378631A CN113051230A CN 113051230 A CN113051230 A CN 113051230A CN 201911378631 A CN201911378631 A CN 201911378631A CN 113051230 A CN113051230 A CN 113051230A
Authority
CN
China
Prior art keywords
resource
picture
project
path
clearing
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201911378631.6A
Other languages
Chinese (zh)
Inventor
刘德建
陈波
林琛
肖雄
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Fujian Tianyi Network Technology Co ltd
Original Assignee
Fujian Tianyi Network Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Fujian Tianyi Network Technology Co ltd filed Critical Fujian Tianyi Network Technology Co ltd
Priority to CN201911378631.6A priority Critical patent/CN113051230A/en
Publication of CN113051230A publication Critical patent/CN113051230A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/16File or folder operations, e.g. details of user interfaces specifically adapted to file systems
    • G06F16/162Delete operations
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/17Details of further file system functions
    • G06F16/1737Details of further file system functions for reducing power consumption or coping with limited storage space, e.g. in mobile devices

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Human Computer Interaction (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention provides a method and a storage medium for clearing UI picture resources of a Laya project, wherein the method comprises the following steps: maintaining a resource use table after the project starts, wherein the table stores the path of the conventional dynamic type resource used by the project; after a cleaning instruction is triggered, loading each sub-resource path, interface picture resource path and the table under the UI picture resource root directory respectively; and clearing resource paths except the interface picture resource path and the table under the UI picture resource root directory. The method can comprehensively and accurately delete the useless resources of the project, thereby reducing the size of the project packet body and occupying the memory; meanwhile, the method has the advantages of easiness in implementation, high efficiency, short time consumption and the like.

Description

Method and storage medium for clearing UI picture resources by Laya project
Technical Field
The invention relates to the field of resource cleaning, in particular to a method and a storage medium for cleaning UI picture resources by a Laya project.
Background
In the development process of the Laya engine project, the used resources usually need to be frequently added, replaced or deleted. If not managed properly, there are a large number of useless resources in the project over time. After a long time of circulation, it is troublesome to easily know which picture is useless. Even if the knowledge of the resources of some modules is not needed, it is cumbersome if removed manually. If the useless resources cannot be deleted in time, the size of the bag body and the size of the memory are occupied, so that a series of problems are caused, and the useless resources must be deleted.
Disclosure of Invention
The technical problem to be solved by the invention is as follows: the invention provides a method and a storage medium for clearing UI picture resources of a Laya project, which can comprehensively delete useless resources in the project and optimize memory.
In order to solve the technical problems, the invention adopts the technical scheme that:
the method for clearing UI picture resources by the Laya project comprises the following steps:
maintaining a resource use table after the project starts, wherein the table stores the path of the conventional dynamic type resource used by the project;
after a cleaning instruction is triggered, loading each sub-resource path, interface picture resource path and the table under the UI picture resource root directory respectively;
and clearing resource paths except the interface picture resource path and the table under the UI picture resource root directory.
The invention provides another technical scheme as follows:
a computer readable storage medium having stored thereon a computer program, which when executed by a processor, is capable of carrying out all the steps included in the above-mentioned method for clearing UI picture resources by the Laya project.
The invention has the beneficial effects that: the resources used by the project are formed by maintaining a resource use table which stores picture resource paths needing to be dynamically loaded by codes under a non-ICON folder in the project and matching the picture paths manually configured on the interface during interface configuration. Through comparison, all useless resources can be screened out comprehensively and accurately. By the method and the device, useless resources in the project can be completely deleted, the size of the bag body is reduced, and the memory occupied by the project is reduced.
Drawings
Fig. 1 is a schematic flow chart of a method for clearing UI picture resources in Laya project according to an embodiment of the present invention;
fig. 2 is a schematic flow chart of a method for clearing UI picture resources in Laya project according to an embodiment of the present invention.
Detailed Description
In order to explain technical contents, achieved objects, and effects of the present invention in detail, the following description is made with reference to the accompanying drawings in combination with the embodiments.
The most key concept of the invention is as follows: maintaining a list of picture resource paths needing to be dynamically loaded by codes under a non-ICON folder in a storage project, and combining the picture paths manually configured on an interface during interface configuration to form resources used by the project, thereby comprehensively deleting other useless resources.
The technical terms related to the invention are explained as follows:
Figure BDA0002341683360000021
Figure BDA0002341683360000031
referring to fig. 1 and fig. 2, the present invention provides a method for clearing UI picture resources in Laya project, including:
maintaining a resource use table after the project starts, wherein the table stores the path of the conventional dynamic type resource used by the project;
after a cleaning instruction is triggered, loading each sub-resource path, interface picture resource path and the table under the UI picture resource root directory respectively;
and clearing resource paths except the interface picture resource path and the table under the UI picture resource root directory.
From the above description, the beneficial effects of the present invention are: by recording the usage dependency of each resource, comparison, screening and deletion are performed according to the dependency when resource cleaning is performed.
Further, the respectively loading each sub-resource path, interface picture resource path and the table under the UI picture resource root directory specifically includes:
loading each sub-resource path under the UI picture resource root directory to an array A;
and respectively loading the interface picture resource path and the table to an array B.
As can be seen from the above description, all resources and all useful resources are stored by the two arrays, which is not only beneficial to application and management, but also less prone to errors; but also is beneficial to quickly screening to obtain the required result.
Further, the clearing of resource paths other than the interface picture resource path and the table under the UI picture resource root directory specifically includes:
and through comparison, acquiring the resource path which is not in the array B in the array A, and deleting the resource path.
Further, the comparing step obtains a resource path that does not exist in the array B in the array a, and deletes the resource path, specifically:
traversing each sub-resource path in the array A, judging whether the currently traversed sub-resource path exists in the array B, if not, acquiring the currently traversed sub-resource path;
and after traversing the array A, deleting all the sub-resource paths acquired in the traversing process.
According to the description, all picture resources and all useful resources are stored based on the array, accurate results can be rapidly obtained based on array analysis and comparison, and the method is high in efficiency and convenient.
Further, after the project starts, a resource usage table is maintained, specifically:
establishing a resource use table comprising a record number field and a resource path field;
after the project is started, the adding, deleting, changing and checking operations of the conventional dynamic resources used by the project are recorded in the resource usage table.
According to the above description, the content of the resource usage table is synchronized with the resource change caused by the project development, so that the resource usage table is ensured to have accuracy in real time.
Further, loading an interface picture resource path, specifically:
loading interface configuration information in the interface configuration information folder to a memory;
according to the configuration resource attributes of each control in the interface configuration information traversal interface, judging whether the currently traversed control configures picture resources, if so, acquiring a path of the picture resources;
and acquiring paths of all the picture resources acquired in the traversal process to obtain interface picture resource paths.
From the above description, in the project development process, the picture resources manually configured on the interface during interface configuration will be comprehensively and accurately screened out by traversing the interface configuration information.
The invention provides another technical scheme as follows:
a computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, is capable of carrying out all the steps included in the method for clearing UI picture resources according to the Laya project:
maintaining a resource use table after the project starts, wherein the table stores the path of the conventional dynamic type resource used by the project;
after a cleaning instruction is triggered, loading each sub-resource path, interface picture resource path and the table under the UI picture resource root directory respectively;
and clearing resource paths except the interface picture resource path and the table under the UI picture resource root directory.
Further, the respectively loading each sub-resource path, interface picture resource path and the table under the UI picture resource root directory specifically includes:
loading each sub-resource path under the UI picture resource root directory to an array A;
and respectively loading the interface picture resource path and the table to an array B.
Further, the clearing of resource paths other than the interface picture resource path and the table under the UI picture resource root directory specifically includes:
and through comparison, acquiring the resource path which is not in the array B in the array A, and deleting the resource path.
Further, the comparing step obtains a resource path that does not exist in the array B in the array a, and deletes the resource path, specifically:
traversing each sub-resource path in the array A, judging whether the currently traversed sub-resource path exists in the array B, if not, acquiring the currently traversed sub-resource path;
and after traversing the array A, deleting all the sub-resource paths acquired in the traversing process.
Further, after the project starts, a resource usage table is maintained, specifically:
establishing a resource use table comprising a record number field and a resource path field;
after the project is started, the adding, deleting, changing and checking operations of the conventional dynamic resources used by the project are recorded in the resource usage table.
Further, loading an interface picture resource path, specifically:
loading interface configuration information in the interface configuration information folder to a memory;
according to the configuration resource attributes of each control in the interface configuration information traversal interface, judging whether the currently traversed control configures picture resources, if so, acquiring a path of the picture resources;
and acquiring paths of all the picture resources acquired in the traversal process to obtain interface picture resource paths.
As can be understood from the above description, those skilled in the art can understand that all or part of the processes in the above technical solutions can be implemented by instructing related hardware through a computer program, where the program can be stored in a computer-readable storage medium, and when executed, the program can include the processes of the above methods. Meanwhile, after the flows of the methods are executed, the beneficial effects corresponding to the methods can be obtained.
The storage medium may be a magnetic disk, an optical disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), or the like.
Example one
Referring to fig. 1 and fig. 2, the present embodiment provides a method for clearing UI picture resources in Laya project, which can comprehensively and accurately delete useless data of the project, optimize project resources, and reduce memory occupied by the project.
UI picture resources of a project are divided into two major types:
normal assignment types (added manually by the producer when laying out the panel) and dynamic assignment types (loaded by the code according to the resource path when the project is running).
The dynamic assignment type is divided into two types: ICON types (resources under the entire atlas/folder are assigned by code dynamic load), and regular dynamic types (resources under the entire atlas/folder are assigned by code dynamic load partly and partly by manual addition by the producer.
Based on the above, the method comprises:
s1: a resource usage table is maintained after the project begins.
First, a resource usage table is created in which the path of the conventional dynamic type resource used by the project in the code is configured. The resource usage table comprises a resID field (which is integer and is used as a record number to facilitate subsequent expansion) and a resPath field (which is a character string type and is used for storing a resource path corresponding to the record number).
Secondly, after the project is started, the adding, deleting, changing and searching operations of the conventional dynamic resources used by the project need to be recorded in the resource usage table in time. That is, after the project is started, all project members need to maintain the resource usage table according to the project development.
Specifically, the field data is empty at the beginning of the resource usage table. The values of the various fields are manually or automatically populated after the project begins, depending on the project member. The value of the resId field can be directly subjected to integer superposition, and the value of the resPath field is filled according to the path where the resource required to be used is located (manual filling mode), or is automatically scanned and filled after being used. Data in the resource usage table needs to be guaranteed to have uniqueness, whether the record exists in the table can be searched in advance in the filling process, if the record exists, the record is not added continuously, and a mode of adding the record does not exist, or other feasible modes. If the resource path used by the project is changed or the resource is deleted due to the development of the project, the resource path information needs to be synchronized in the table.
One specific example of the resource usage table is shown in table 1 below:
resID resPath
1 Res/DW_UI/Activity/ActivityTask
2 Res/DW_UI/Activity/RechargeAwardNew
TABLE 1
Referring to fig. 2 of the drawings, a schematic diagram of a display device,
s2: and after a cleaning instruction is triggered, loading each sub-resource path, each interface picture resource path and the table under the UI picture resource root directory respectively.
The timing of triggering the cleaning instruction may be a predetermined trigger period, or may be any timing that requires resource cleaning before each time the project is issued.
In one embodiment, the steps include:
s21: reading all sub-resource paths under the UI picture resource root directory, and storing the sub-resource paths to a newly-built array A;
s22: loading the resource usage table to the memory, and creating an array B for storing the content of the loaded resource usage table;
s23: and loading and storing the interface picture resource path to the array B. Because the interface picture resource path is also a resource path used in the project and is directly stored to the array B, one array can be created at a minimum, the resource storage used by all projects can be uniformly stored in one array, the uniform management is convenient, the cycle comparison frequency in the subsequent comparison can be reduced, and the comparison efficiency is improved.
Specifically, the loading interface picture resource path specifically includes:
loading each interface configuration information in the interface configuration information folder to a memory;
according to the configuration resource attributes of each control (which are divided into various types: Label, Button, Image and the like) in the interface configuration information traversal interface, judging whether the configuration resource attributes of the currently traversed control contain skin attributes (the picture resources are configured to have the name of the skin attribute), namely whether the control contains a skin resource path, if so, acquiring the path of the picture resources (preferably, directly storing the path value stored in the skin attribute into an array B after taking the path value stored in the skin attribute), and traversing downwards; if not, traversing downwards until the traversal is finished;
after the traversal is finished, all the image resource paths acquired in the traversal process form a required interface image resource path and are stored in the array B.
So far, the picture resources which are not under the ICON folder in the project and need to be dynamically loaded by codes are clearly recorded in the resource use table. And the interface picture resource path is also acquired and comprises all picture resources manually configured on the interface by the project member during interface configuration. Therefore, the array B includes the resource path configuration information used by all the entries.
S3: and clearing resource paths except the interface picture resource path and the table under the UI picture resource root directory.
And after a cleaning instruction is triggered, the use relation of the acquired resources (acquired through the resource use table and the interface picture resource path) is read, the UI picture resource root directory is read, all resource paths of the project are taken, and then useless resources are screened out by comparing the resource use relation with the resource use root directory and deleted.
The reason why the statistics is not performed on the ICON folder when the usage relationship of the resources is obtained in this embodiment is that the resources under the ICON are all read according to the fixed path, and these picture resources are often associated with the planned configuration table, so that they can be directly ignored during the comparison, and it is not necessary to count the resources when the usage relationship of the resources is obtained. It is of course initially defined that ICON resources such as props, equipment, head portraits, etc. in backpacks are all placed under the ICON folder and not in other folders, as is conventional in the art.
Specifically, the resource paths other than the interface picture resource path and the table under the UI picture resource root directory are cleared.
Corresponding to the above embodiment, the resource path that does not exist in the array B in the array a is obtained directly by comparison, and deleted. The specific cleaning process comprises the following steps:
traversing each sub-resource path in the array A, judging whether the currently traversed sub-resource path exists in the array B (namely whether the currently traversed sub-resource path can be matched with a certain path in the array B), if not, proving that the resource is not used in the whole project, and then acquiring the currently traversed sub-resource path; if yes, the next sub-resource path is continuously traversed. Therefore, after traversing the array A, all useless sub-resource paths can be obtained and deleted.
Example two
The present embodiment provides a computer-readable storage medium, which stores thereon a computer program, which when executed by a processor, can implement all the steps included in the method for clearing UI picture resources in Laya project according to the first embodiment. The detailed steps are not repeated here, and refer to the description of the first embodiment for details.
In conclusion, the method and the storage medium for clearing UI picture resources of the Laya project, provided by the invention, can comprehensively and accurately delete project useless resources, so that the size of a project packet body is reduced and the memory is occupied; meanwhile, the method has the advantages of easiness in implementation, high efficiency, short time consumption and the like.
The above description is only an embodiment of the present invention, and not intended to limit the scope of the present invention, and all equivalent changes made by using the contents of the present specification and the drawings, or applied directly or indirectly to the related technical fields, are included in the scope of the present invention.

Claims (7)

  1. A method for clearing UI picture resources by a Laya project, comprising the following steps:
    maintaining a resource use table after the project starts, wherein the table stores the path of the conventional dynamic type resource used by the project;
    after a cleaning instruction is triggered, loading each sub-resource path, interface picture resource path and the table under the UI picture resource root directory respectively;
    and clearing resource paths except the interface picture resource path and the table under the UI picture resource root directory.
  2. 2. The method for clearing UI picture resources according to Laya project of claim 1, wherein the loading each sub-resource path, interface picture resource path and the table under the UI picture resource root directory respectively specifically is:
    loading each sub-resource path under the UI picture resource root directory to an array A;
    and respectively loading the interface picture resource path and the table to an array B.
  3. 3. The method for clearing UI picture resources according to Laya project of claim 2, wherein the resource paths other than the interface picture resource path and the table in the root directory of the clearing UI picture resources are specifically:
    and through comparison, acquiring the resource path which is not in the array B in the array A, and deleting the resource path.
  4. 4. The method for clearing UI picture resources according to Laya project of claim 3, wherein the comparing obtains and deletes the resource path that does not exist in the array B in the array a, specifically:
    traversing each sub-resource path in the array A, judging whether the currently traversed sub-resource path exists in the array B, if not, acquiring the currently traversed sub-resource path;
    and after traversing the array A, deleting all the sub-resource paths acquired in the traversing process.
  5. 5. The method for clearing UI picture resources according to claim 1, wherein the project maintains a resource usage table after the start of the project, specifically:
    establishing a resource use table comprising a record number field and a resource path field;
    after the project is started, the adding, deleting, changing and checking operations of the conventional dynamic resources used by the project are recorded in the resource usage table.
  6. 6. The method for clearing UI picture resources of Laya project of claim 1, wherein the loading of the interface picture resource path specifically is:
    loading interface configuration information in the interface configuration information folder to a memory;
    according to the configuration resource attributes of each control in the interface configuration information traversal interface, judging whether the currently traversed control configures picture resources, if so, acquiring a path of the picture resources;
    and acquiring paths of all the picture resources acquired in the traversal process to obtain interface picture resource paths.
  7. 7. A computer readable storage medium having stored thereon a computer program, wherein said program, when executed by a processor, is capable of implementing all the steps comprised in the method for clearing UI picture resources according to any of the claims 1-6.
CN201911378631.6A 2019-12-27 2019-12-27 Method and storage medium for clearing UI picture resources by Laya project Pending CN113051230A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911378631.6A CN113051230A (en) 2019-12-27 2019-12-27 Method and storage medium for clearing UI picture resources by Laya project

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911378631.6A CN113051230A (en) 2019-12-27 2019-12-27 Method and storage medium for clearing UI picture resources by Laya project

Publications (1)

Publication Number Publication Date
CN113051230A true CN113051230A (en) 2021-06-29

Family

ID=76506741

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911378631.6A Pending CN113051230A (en) 2019-12-27 2019-12-27 Method and storage medium for clearing UI picture resources by Laya project

Country Status (1)

Country Link
CN (1) CN113051230A (en)

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103955372A (en) * 2014-04-30 2014-07-30 广东欧珀移动通信有限公司 Method and device for detecting resources in mobile terminal
CN103970516A (en) * 2013-01-30 2014-08-06 腾讯科技(深圳)有限公司 Superfluous picture deletion method and device
US20160378797A1 (en) * 2013-11-12 2016-12-29 Dropbox, Inc. Content item purging
CN106708565A (en) * 2016-11-29 2017-05-24 武汉斗鱼网络科技有限公司 Method and device for removing useless picture resources in APK (Android Package)
CN108089893A (en) * 2017-12-14 2018-05-29 网易(杭州)网络有限公司 Definite method, apparatus, terminal device and the storage medium of redundant resource
CN109344277A (en) * 2018-08-31 2019-02-15 网易传媒科技(北京)有限公司 Image processing method, device, medium and calculating equipment
CN109828777A (en) * 2018-12-06 2019-05-31 珠海西山居互动娱乐科技有限公司 A kind of hand trip installation kit optimization method and system

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103970516A (en) * 2013-01-30 2014-08-06 腾讯科技(深圳)有限公司 Superfluous picture deletion method and device
US20160378797A1 (en) * 2013-11-12 2016-12-29 Dropbox, Inc. Content item purging
CN103955372A (en) * 2014-04-30 2014-07-30 广东欧珀移动通信有限公司 Method and device for detecting resources in mobile terminal
CN106708565A (en) * 2016-11-29 2017-05-24 武汉斗鱼网络科技有限公司 Method and device for removing useless picture resources in APK (Android Package)
CN108089893A (en) * 2017-12-14 2018-05-29 网易(杭州)网络有限公司 Definite method, apparatus, terminal device and the storage medium of redundant resource
CN109344277A (en) * 2018-08-31 2019-02-15 网易传媒科技(北京)有限公司 Image processing method, device, medium and calculating equipment
CN109828777A (en) * 2018-12-06 2019-05-31 珠海西山居互动娱乐科技有限公司 A kind of hand trip installation kit optimization method and system

Similar Documents

Publication Publication Date Title
US11556501B2 (en) Determining differences between two versions of a file directory tree structure
CN102141963B (en) A kind of data analysing method and equipment
US20150310129A1 (en) Method of managing database, management computer and storage medium
CN111143368B (en) Relational database data comparison method and system
CN108573019B (en) Data migration method and device, electronic equipment and readable storage medium
CN104182354B (en) A kind of video management method and device
CN112463886A (en) Data processing method and device, electronic equipment and storage medium
CN107145538B (en) Table data query method, device and system
CN110083579A (en) Incremental data synchronous method, apparatus, computer equipment and computer storage medium
CN108376156A (en) Create method, apparatus, server and the storage medium of database index
CN106897342A (en) A kind of data verification method and equipment
CN111159020B (en) Method and device applied to synchronous software test
CN111367869A (en) Mirror image file processing method and device, storage medium and electronic equipment
US9747328B2 (en) Method and apparatus for modifying a row in a database table to include meta-data
CN108038253B (en) Log query processing method and device
CN113051230A (en) Method and storage medium for clearing UI picture resources by Laya project
CN111752941B (en) Data storage and access method and device, server and storage medium
US20240045888A1 (en) Key name generation method and apparatus and non-transitory computer-readable storage medium
CN113792026B (en) Method and device for deploying database script and computer-readable storage medium
CN111090670B (en) Data pre-aggregation method, system, computing device and storage medium
US7565217B2 (en) Traversal of empty regions in a searchable data structure
CN114816247A (en) Logic data acquisition method and device
CN113918096A (en) Method and device for uploading algorithm mirror image packet and application
CN113591147A (en) Data extraction method and device, computer equipment and storage medium
US20170147256A1 (en) Memory storage recycling

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination