Prefabricated body replacement method, device, electronic device and storage medium
By automatically determining and replacing prefabricated bodies in virtual scenes, the problem of inefficiency of manual replacement is solved, and more efficient and accurate prefabricated bodies are achieved.
Patent Information
- Application Number
- CN202210928355.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-03
- Publication Date
- 2025-05-27
- Estimated Expiration
- 2042-08-03
AI Technical Summary
In game development, when manually replacing multiple prefabricated bodies in the virtual scene as new prefabricated bodies, it is inefficient and prone to misoperation.
By obtaining the storage information and attribute information of the candidate object, the prefabricated body to be replaced is automatically determined and replaced with the target prefabricated body based on its original position information.
It improves the replacement efficiency of the prefabricated body, reduces manual operation time, and reduces the risk of misoperation.
Smart Images

Figure CN115253302B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and particularly to a prefab replacement method, apparatus, electronic device, and storage medium. Background Art
[0002] With the popularization of computers and mobile intelligent devices, games have become a common form of entertainment. In game development, pre-made models can be imported into the game engine, and then prefabs can be created for each model. Each object in the game scene is an instance of a prefab, and by modifying the parameters of the prefab, the parameters of all prefab instances can be quickly modified.
[0003] However, if multiple prefabs in a virtual scene need to be replaced with new prefabs, usually developers need to manually replace them one by one, which not only consumes a lot of time but also is prone to misoperations, resulting in low efficiency of prefab replacement. Summary of the Invention
[0004] Embodiments of this application provide a prefab replacement method, apparatus, electronic device, and storage medium, which can improve the efficiency of prefab replacement.
[0005] An embodiment of this application provides a prefab replacement method, including:
[0006] Obtain the storage information and attribute information of candidate objects, where the candidate objects are selected virtual objects;
[0007] Based on the storage information and attribute information of the candidate objects, determine the prefab to be replaced from the candidate objects;
[0008] Obtain the original position information corresponding to the prefab to be replaced, where the original position information is used to represent the position of the prefab to be replaced in the virtual scene;
[0009] Replace the prefab to be replaced with a target prefab according to the original position information.
[0010] An embodiment of this application also provides a prefab replacement apparatus, including:
[0011] An obtaining module, configured to obtain the storage information and attribute information of candidate objects, where the candidate objects are selected virtual objects;
[0012] A screening module, configured to determine the prefab to be replaced from the candidate objects based on the storage information and attribute information of the candidate objects;
[0013] A position obtaining module, configured to obtain the original position information corresponding to the prefab to be replaced, where the original position information is used to represent the position of the prefab to be replaced in the virtual scene;
[0014] A replacement module, configured to replace the to-be-replaced prefabricated body with a target prefabricated body according to the original position information.
[0015] In some embodiments, the screening module further includes:
[0016] A type determination unit, configured to determine a target object type corresponding to the candidate object based on the storage information and attribute information of the candidate object;
[0017] A screening unit, configured to determine the to-be-replaced prefabricated body from the candidate objects based on the target object type corresponding to the candidate object and a preset specified object type.
[0018] In some embodiments, the target object type includes a target prefabricated body type or a target storage type, and the type determination unit is further configured to:
[0019] Determine a target storage type corresponding to the candidate object based on the storage information;
[0020] If the target storage type is a preset storage type, determine a target prefabricated body type corresponding to the candidate object based on the attribute information, and determine the target prefabricated body type as the target object type;
[0021] If the target storage type is not the preset storage type, determine the target storage type as the target object type.
[0022] In some embodiments, the type determination unit is further configured to:
[0023] Obtain a storage path indicated by the storage information;
[0024] If a file with a specified file extension is found under the storage path, determine that the target storage type corresponding to the candidate object is a first storage type;
[0025] If a file with a specified file extension is not found under the storage path, determine that the target storage type corresponding to the candidate object is a second storage type.
[0026] In some embodiments, the attribute information includes a nesting relationship between the candidate object and other objects, the target prefabricated body type includes a target nesting type, and the type determination unit is further configured to:
[0027] If it is determined based on the nesting relationship that the candidate object has a corresponding parent object, determine that the target nesting type is a first nesting type;
[0028] If it is determined based on the nested relationship that there is no corresponding parent object for the candidate object, determine that the target nesting type is the second nesting type.
[0029] In some embodiments, the attribute information further includes an object identifier, the target prefab type further includes a target loss type, and the type determination unit is further configured to:
[0030] Determine the target object identifier corresponding to the candidate object according to the target nesting type and the object identifier of the candidate object;
[0031] If the target object identifier includes a specified field, determine that the target loss type is the first loss type;
[0032] If the target object identifier does not include a specified field, determine that the target loss type is the second loss type.
[0033] In some embodiments, the replacement module further includes:
[0034] A target policy determination unit, configured to determine a target replacement policy corresponding to the prefab to be replaced according to the input position offset parameter;
[0035] A replacement unit, configured to replace the prefab to be replaced with a target prefab based on the target replacement policy and the original position information.
[0036] In some embodiments, the target replacement policy is the first replacement policy or the second replacement policy, and the replacement unit is further configured to:
[0037] Obtain the parent object corresponding to the prefab to be replaced to obtain a target parent object;
[0038] Set the target prefab as a child object of the target parent object to obtain a target prefab with a target relationship;
[0039] If the target replacement policy is the first replacement policy, set the position information of the target prefab with the target relationship to the original position information, and delete the prefab to be replaced;
[0040] If the target replacement policy is the second replacement policy, set the position information of the target prefab with the target relationship to the target position information, and delete the prefab to be replaced, where the target position information is determined by the original position information and the input position offset parameter.
[0041] In some embodiments, the replacement unit is further configured to:
[0042] Set the position information of the target prefab with the target relationship to the original position information;
[0043] Update the original position information based on the position offset parameter to obtain target position information;
[0044] Set the position information of the target prefab with the target relationship to the target position information, and delete the prefab to be replaced.
[0045] In some embodiments, the prefab replacement device further includes a storage module for:
[0046] Create a preset array;
[0047] Store the target prefab in the preset array and control the target prefab to be in a selected state.
[0048] In some embodiments, the prefab replacement device further includes a rollback module. After storing the target prefab in the preset array and controlling the target prefab to be in a selected state, the rollback module is used for:
[0049] In response to a rollback operation, obtain the original position information of the prefab to be replaced stored in advance;
[0050] Based on the original position information, control the prefab to be replaced to replace the target prefab.
[0051] In some embodiments, the prefab replacement device further includes a serial number inheritance module for:
[0052] Obtain the serial number corresponding to the prefab to be replaced, where the serial number is used to indicate the arrangement order of the prefab to be replaced in the inspection window;
[0053] Set the serial number of the target prefab corresponding to the prefab to be replaced to the serial number corresponding to the prefab to be replaced.
[0054] An embodiment of the present application further provides an electronic device, including a memory storing multiple instructions; the processor loads the instructions from the memory to execute the steps in any one of the prefab replacement methods provided by the embodiments of the present application.
[0055] An embodiment of the present application further provides a computer-readable storage medium, where the computer-readable storage medium stores multiple instructions, and the instructions are suitable for being loaded by a processor to execute the steps in any one of the prefab replacement methods provided by the embodiments of the present application.
[0056] Embodiments of the present application can obtain the storage information and attribute information of candidate objects; and based on the storage information and attribute information of the candidate objects, determine the prefabricated body to be replaced from the candidate objects, and based on the original position information of the object to be replaced, replace the prefabricated body to be replaced with the target prefabricated body. By automatically determining the prefabricated body to be replaced from the candidate objects, it is possible to avoid the consumption of a large amount of time for manually determining the prefabricated body to be replaced, thereby improving the replacement efficiency of the prefabricated body. Description of the Drawings
[0057] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following will briefly introduce the drawings required for the description of the embodiments. Obviously, the drawings in the following description are only some embodiments of the present application. For those skilled in the art, without creative efforts, other drawings can also be obtained based on these drawings.
[0058] Figure 1 It is a schematic diagram of the scenario of the prefabricated body replacement method provided by the embodiments of the present application;
[0059] Figure 2 It is a schematic flowchart of the prefabricated body replacement method provided by the embodiments of the present application;
[0060] Figure 3 It is a schematic diagram of the target prefabricated body in a selected state provided by the embodiments of the present application;
[0061] Figure 4 It is a schematic flowchart of the prefabricated body replacement method provided by another embodiment of the present application;
[0062] Figure 5 It is a schematic diagram of the replacement panel provided by the embodiments of the present application;
[0063] Figure 6 It is a schematic structural diagram of the prefabricated body replacement device provided by the embodiments of the present application;
[0064] Figure 7 It is a schematic structural diagram of the electronic device provided by the embodiments of the present application. Detailed Embodiments
[0065] The following will clearly and completely describe the technical solutions in the embodiments of the present application with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only some embodiments of the present application, rather than all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative efforts belong to the scope of protection of the present application.
[0066] Embodiments of the present application provide a prefabricated body replacement method, device, electronic device, and storage medium.
[0067] Among them, the preform replacement device can be specifically integrated into an electronic device, which can be a device such as a terminal or a server. Among them, the terminal can be a device such as a mobile phone, a tablet computer, a smart Bluetooth device, a laptop computer, or a personal computer (PC); the server can be a single server or a server cluster composed of multiple servers.
[0068] In some embodiments, the preform replacement device can also be integrated into multiple electronic devices. For example, the preform replacement device can be integrated into multiple servers, and multiple servers are used to implement the preform replacement method of this application.
[0069] In some embodiments, the server can also be implemented in the form of a terminal.
[0070] For example, referring to Figure 1 , a schematic diagram of an application scenario for implementing the preform replacement method provided by an embodiment of this application is shown. This scenario can include a terminal device 1000, a server 2000, a database 3000, and a network 4000. The terminal 1000 held by the user can be connected to the server 2000 through the network 4000. Among them, the terminal device 1000 is any device with computing hardware that can support and execute software products corresponding to page display; the server 2000 can be a single server or a server cluster; the network 4000 can be a wireless network or a wired network. For example, the wireless network is a wireless local area network (WLAN), a local area network (LAN), a cellular network, a 2G network, a 3G network, a 4G network, a 5G network, etc. In addition, different terminal devices 1000 can also use their own Bluetooth network or hotspot network to connect to other terminals or connect to the server 2000. The database 3000 is used to store the data generated when the user uses the terminal device 1000 for preform replacement.
[0071] When the terminal device 1000 executes the preform replacement method, the terminal device 1000 can obtain the storage information and attribute information of the candidate object, where the candidate object is a selected virtual object; based on the storage information and attribute information of the candidate object, determine the preform to be replaced from the candidate objects; obtain the original position information corresponding to the preform to be replaced, where the original position information is used to represent the position of the preform to be replaced in the virtual scene; according to the original position information, replace the preform to be replaced with a target preform. Thus, it is possible to automatically screen out the preform to be replaced from the candidate objects and, based on the original position information of the preform to be replaced, automatically replace the preform to be replaced with a target preform, reducing the workload of manual replacement and thereby improving the efficiency of preform replacement.
[0072] It should be noted that the prefab is the prefab. A prefab can be understood as a collection of a virtual object and its components, aiming to enable the virtual object and resources to be reused. The same virtual object can be created through a preset. For example, dragging the prefab into the scene can create a virtual object associated with the prefab. After changing the parameters of the prefab, the virtual objects associated with the prefab will also be changed synchronously, so that the prefab can improve the utilization rate of resources and the development efficiency.
[0073] The prefab has the characteristic that if the parameters of the prefab are directly modified, all the virtual objects obtained based on the prefab in the scene will change. In the actual development process, it may be necessary to replace some of the virtual objects obtained based on the prefab in the scene. For example, virtual object A`, virtual object B`, and virtual object C` are all prefab instances of the same prefab in the scene. When it is necessary to replace virtual object A` and virtual object B`, the method provided in the embodiment of the present application can be used to screen out the prefab to be replaced from the candidate objects and perform the replacement, while other prefabs will not be affected. The following will be described in detail respectively.
[0074] In this embodiment, a prefab replacement method is provided, as Figure 2 shown. The specific process of this prefab replacement method can be as follows:
[0075] S110. Obtain the storage information and attribute information of the candidate object, where the candidate object is the selected virtual object.
[0076] The candidate object refers to the selected virtual object in the virtual scene. For example, it can refer to the virtual object selected by the user, or the virtual object automatically selected based on the script.
[0077] The storage information can refer to information such as the storage path and storage address of the candidate object, that is, based on this storage information, the address where the relevant information of the candidate object is stored can be determined.
[0078] The attribute information refers to the information used to describe the candidate object. For example, it can include the parameters of the candidate object, the nested relationship between the candidate object and other objects, the identifier of the candidate object, the position information of the candidate object in the virtual scene, the size, etc.
[0079] In some embodiments, when obtaining the storage information and attribute information of the candidate object, it can be to first determine the candidate object; and then obtain the storage information and attribute information of the candidate object. For the convenience of subsequent use of the storage information and attribute information of the candidate object, a data structure can also be created to store these data.
[0080] S120. Determine the prefab to be replaced from the candidate objects based on the storage information and attribute information of the candidate objects.
[0081] After obtaining the storage information and attribute information of the candidate objects, the candidate objects can be screened based on the storage information and attribute information of the candidate objects, so as to screen out the candidate objects that really need to be replaced from the candidate objects and obtain the prefab to be replaced.
[0082] The prefab to be replaced refers to the prefab that needs to be replaced. Since there may be prefabs and non-prefabs in the virtual scene, the candidate objects may also include prefabs and non-prefabs. Usually, during the game development process, some specific prefabs need to be replaced. In order to quickly find the prefabs that need to be replaced and improve the replacement efficiency of the prefabs, the prefab to be replaced can be automatically screened out from the candidate objects.
[0083] In some embodiments, when determining the prefab to be replaced from the candidate objects, it may be based on the storage information and attribute information of the candidate objects to determine the target object type corresponding to the candidate objects; based on the target object type corresponding to the candidate objects and the specified object type set in advance, determine the prefab to be replaced from the candidate objects.
[0084] Among them, the target object type refers to the type corresponding to the candidate object. The number of candidate objects can be multiple. Therefore, according to the storage information and attribute information of the candidate objects, the target object type corresponding to each candidate object can be determined correspondingly.
[0085] The specified object type refers to the type set in advance. For example, it can be the type set according to the development needs. After determining the target object type corresponding to the candidate object, the prefab to be replaced can be determined from the candidate objects based on the target object type corresponding to the candidate object and the specified object type.
[0086] In some embodiments, it may be to match the target object type with the specified object type. If the match is successful, the corresponding candidate object is determined as the prefab to be replaced.
[0087] As an implementation, when matching the target object type with the specified object type, it may be to determine whether the specified object type exists in the target object type corresponding to the candidate object; if the specified object type exists, it is determined that the match is successful; if the specified object type does not exist, it is determined that the match fails.
[0088] For example, if the specified object type is type a, the target object types corresponding to candidate object A are type a and type b, the target object type corresponding to candidate object B is type a, and the target object type corresponding to candidate object C is type c. Since the specified object type exists in the target object types corresponding to both candidate object A and candidate object B, the matching is successful; since the specified object type does not exist in the target object type corresponding to candidate object C, the matching fails. Then, it can be determined that candidate object A and candidate object B are objects to be replaced.
[0089] For another example, if the specified object types are type a and type b, when determining the objects to be replaced, the candidate objects whose target object types include type a or type b can be determined as the objects to be replaced, or the candidate objects whose target object types include both type a and type b can be determined as the objects to be replaced. Among them, the specific matching rules can be set according to actual needs and are not specifically limited here.
[0090] In some embodiments, the target object type may include a target prefabricated type or a target storage type. To accurately determine the target object type, based on the storage information, the target storage type corresponding to the candidate object can be determined; if the target storage type is a preset storage type, based on the attribute information, the target prefabricated type corresponding to the candidate object is determined, and the target prefabricated type is determined as the target object type; if the target storage type is not the preset storage type, the target storage type is determined as the target object type.
[0091] The preset storage type refers to a pre-set storage type. Based on the storage information, the target storage type of the candidate object can be determined; if the target storage type is the preset storage type, the target prefabricated type determined based on the attribute information is used as the target object type; if the target storage type is not the preset storage type, the target storage type is directly used as the target object type.
[0092] In some embodiments, when determining the target storage type corresponding to the candidate object based on the storage information, the storage path indicated by the storage information can be obtained; if a file with a specified file extension is found under the storage path, the target storage type corresponding to the candidate object is determined to be the first storage type; if a file with a specified file extension is not found under the storage path, the target storage type corresponding to the candidate object is determined to be the second storage type.
[0093] A file extension, usually also known as an extended file name or suffix, can be used to indicate the format of a file, such as docx, pdf, doc, etc. The specified file extension can be a file extension set in advance according to needs. The stored information can be used to represent information such as the storage location of the candidate object. Based on the stored information, the storage path indicated by the stored information can be obtained. Then, it is determined whether there is a file with the specified file extension under this storage path; if so, it can be determined that the target storage type corresponding to the candidate object is the first storage type; if not, it can be determined that the target storage type corresponding to the candidate object is the second storage type.
[0094] Among them, the first storage type can refer to that the candidate object belongs to an object stored locally, that is, the local storage type, and the second storage type can refer to that the candidate object does not belong to an object stored locally, that is, the non-local storage type.
[0095] As an implementation manner, when determining whether there is a file with the file extension under this storage path, it can be to obtain the extensions corresponding to all files under this storage path; if the specified file extension exists in the extensions, it is determined that there is a file with the specified file extension under this storage path; if the specified file extension does not exist in the extensions, it is determined that there is no file with the specified file extension under this storage path. For example, the extensions corresponding to all files under this storage path are X, Y, Z, and the specified file extension is Y. Since the extension includes the specified file extension Y, it can be considered that there is a file with the specified file extension under this storage path. In the embodiments of the present application, the specified file extension can be meta.
[0096] After determining the target storage type corresponding to the candidate object, it can be continued to determine whether the target storage type is the preset storage type; if it is the preset storage type, it can be continued to determine the target prefab type corresponding to the candidate object based on the attribute information, and use the determined target prefab type as the target object type; if it is not the preset storage type, directly determine the target storage type as the target object type.
[0097] Among them, the preset storage type can refer to the first storage type, that is, if the target storage type is the second storage type, it can be directly determined that the target object type of the candidate object is the second storage type. If the target storage type is the first storage type, then continue to determine the target prefab type.
[0098] The target prefab type can indicate what specific type of prefab the candidate object is. Based on the target storage type of the candidate object, it can be distinguished whether the candidate object is a prefab. Since a prefab must belong to an object stored locally, a candidate object with the second storage type is not a prefab, and there is no need to continue to determine the target prefab type.
[0099] In some embodiments, the attribute information may include the nesting relationship between the candidate object and other objects, and the target prefab type may include a target nesting type. When determining the target prefab type corresponding to the candidate object based on the attribute information, it may be that if, based on the nesting relationship, it is determined that the candidate object has a corresponding parent object, the target nesting type is determined to be the first nesting type; if, based on the nesting relationship, it is determined that the candidate object does not have a corresponding parent object, the target nesting type is determined to be the second nesting type.
[0100] The nesting relationship can represent the relationship between the candidate object and other objects in the virtual scene. For example, if the candidate object is nested on another object, the candidate object is the child object of the other object, and the other object is the parent object of the candidate object; another example is that if another object is nested on the candidate object, the candidate object is the parent object of the other object, and the other object is the child object of the candidate object. Through the nesting relationship, it can be determined whether the candidate object has a parent object. Among them, the parent object and the child object form a parent-child relationship. The transformation of the parent object can affect the child object. A child object has and only has one parent object, while a parent object can have multiple child objects.
[0101] If the candidate object has a parent object, the target nesting type can be determined to be the first nesting type; if the candidate object does not have a parent object, the target nesting type can be determined to be the second nesting type. Among them, the first nesting type may refer to a nested prefab, and the second nesting type may refer to a non-nested prefab.
[0102] In some embodiments, the target prefab type may further include a target loss type, and the attribute information may further include an item identifier. After determining the target nesting type, the target loss type can be further determined. For example, it may be to determine the target object identifier corresponding to the candidate object according to the target nesting type and the object identifier of the candidate object; if the target object identifier includes a specified field, the target loss type is determined to be the first loss type; if the target object identifier does not include the specified field, the target loss type is determined to be the second loss type.
[0103] Among them, the object identifier refers to the identifier of the candidate object, and the target object identifier is the basis for determining the target loss type. When determining the target object identifier according to the target nesting type and the object identifier of the candidate object, it may be that if the target nesting type of the candidate object is the first nesting type, the object identifier of the corresponding parent object of the candidate object is used as the target object identifier; if the target nesting type of the candidate object is the second nesting type, the object identifier of the candidate object is used as the target object identifier.
[0104] As an implementation manner, it is possible to associate and store a virtual object with its corresponding parent object. For example, the object identifier of the virtual object and the object identifier of its corresponding parent object are associated and stored as a mapping table. Thus, after obtaining the object identifier of the candidate object, if the candidate object has a parent object, the object identifier of the parent object of the candidate object can be found in the mapping table based on the object identifier of the candidate object, so as to obtain the target object identifier.
[0105] If the target object identifier includes a specified field, it can be determined that the target loss type of the candidate object is the first loss type, that is, the prefab that has lost the local file; if the target object identifier does not include the specified field, it can be determined that the target loss type of the candidate object is the second loss type, that is, the prefab that has not lost the local file.
[0106] From the above content, it can be seen that the target object type of the candidate object can be the target storage type or the target prefab type, and the target prefab type can include the target nesting type and the target loss type. If the target storage type is the second storage type, the target object type is also the second storage type. If the target storage type is the first storage type, the target object type may be the first nesting type and the first loss type, the second nesting type and the first loss type, the first nesting type and the second loss type, or the second nesting type and the second loss type.
[0107] Thus, the prefab to be replaced can be screened out from the candidate objects according to the target object type of the candidate object and the preset specified object type.
[0108] As an implementation manner, after determining the prefab to be replaced, the target object type corresponding to the prefab to be replaced can be obtained at the same time. In order to facilitate the user to confirm whether the prefab to be replaced is correct and reduce the probability of misoperation, the prefab to be replaced can be displayed according to the target object type.
[0109] S130. Obtain the original position information corresponding to the prefab to be replaced, where the original position information is used to represent the position of the prefab to be replaced in the virtual scene.
[0110] The prefab to be replaced refers to the prefab that can be replaced. Thus, the original position information corresponding to the prefab to be replaced can be obtained, where the original position information is used to represent the position of the prefab to be replaced in the virtual scene.
[0111] In some implementation manners, the attribute information may include the original position information. Since the attribute information of the candidate object has been obtained in advance, the original position information can be obtained based on the attribute information of the object to be replaced.
[0112] S140. Replace the to-be-replaced prefabricated body with the target prefabricated body according to the original position information.
[0113] After obtaining the original position information of the to-be-replaced prefabricated body, the to-be-replaced prefabricated body can be replaced with the target prefabricated body based on this original position information.
[0114] As an implementation manner, since the to-be-replaced prefabricated body and the target prefabricated body may be obtained through different digital content creation (DCC) software, the to-be-replaced prefabricated body and the target prefabricated body may have different axes or axles. After being imported into the engine, their position information usually has many different changes. To ensure that the replaced target prefabricated body remains at the position of the to-be-replaced prefabricated body and obtain a better replacement effect, the position offset parameter input by the user can be obtained, and the position can be corrected according to the position offset parameter. During the use process, the user can determine whether to input this position offset parameter according to actual needs.
[0115] When performing the replacement, it can be to determine the target replacement strategy corresponding to the to-be-replaced prefabricated body according to the input position offset parameter; and based on the target replacement strategy and the original position information, replace the to-be-replaced prefabricated body with the target prefabricated body.
[0116] Generally, the position offset parameter has its default value, which is hereinafter referred to as the default offset parameter for the convenience of description. When determining the target replacement strategy corresponding to the to-be-replaced prefabricated body according to the position offset parameter, the input position offset parameter and the default offset parameter can be compared; if the input position offset parameter is consistent with the default offset parameter, the target replacement strategy can be determined as the first replacement strategy; if the input position offset parameter is inconsistent with the default offset parameter, the target replacement strategy can be determined as the second replacement strategy.
[0117] When replacing the to-be-replaced prefabricated body with the target prefabricated body based on the target replacement strategy and the original position information, to ensure the accuracy of the replacement, it can be to obtain the parent object corresponding to the to-be-replaced prefabricated body to obtain the target parent object; set the target prefabricated body as the child object of the target parent object to obtain the target prefabricated body with a target relationship; if the target replacement strategy is the first replacement strategy, set the position information of the target prefabricated body with the target relationship as the original position information, and delete the to-be-replaced prefabricated body; if the target replacement strategy is the second replacement strategy, set the position information of the target prefabricated body with the target relationship as the target position information, and delete the to-be-replaced prefabricated body, where the target position information is determined by the original position information and the input position offset parameter.
[0118] Since the position of the parent object affects the position of the child object, to ensure that the position remains unchanged after replacement, after determining the prefab to be replaced, the parent object corresponding to the prefab to be replaced can be obtained and recorded as the target parent object, and then the target prefab can be set as the child object of the target parent object, so as to obtain the target prefab with the target relationship. The target prefab with the target relationship and the prefab to be replaced are both child objects of the same parent object.
[0119] In some embodiments, the prefab to be replaced may not have a corresponding parent object, then the target prefab can be set in the world coordinate system of the virtual scene. For example, the prefab to be replaced includes candidate object A and candidate object B, where the parent object of candidate object A is candidate object D, and candidate object B has no parent object. Then, when replacing candidate object A, the target prefab can be set as the child object of candidate object D, and when replacing candidate object B, the target prefab can be set as the child object of the world coordinate system.
[0120] If the target replacement strategy is the first replacement strategy, the position information of the target prefab with the target relationship can be set to the original position information, and then the prefab to be replaced can be deleted, so as to replace the prefab to be replaced with the target prefab.
[0121] If the target replacement strategy is the second replacement strategy, the target position information can be determined according to the original position information and the input position offset parameter, and the position information of the target prefab with the target relationship can be set to the target position information, so as to replace the prefab to be replaced with the target prefab and ensure that the target prefab remains at the original position of the prefab to be replaced.
[0122] As an implementation, determining the target position information according to the original position information and the input position offset parameter, and setting the position information of the target prefab with the target relationship to the target position information may specifically include: setting the position information of the target prefab with the target relationship to the original position information; updating the original position information based on the position offset parameter to obtain the target position information; setting the position information of the target prefab with the target relationship to the target position information.
[0123] That is, it can be to first set the position information of the target prefab with the target relationship as the original position information, and then, based on the position offset parameter, update the original position information to obtain the target position information, and then control the target prefab to transform to the position indicated by the target position information. Among them, the position offset parameter can include one or more of a rotation parameter, a translation parameter, and a scaling parameter. When updating the original position information, the scaling parameter, the rotation parameter, and the translation parameter can be used in sequence to obtain the target position information, and then the position information of the target prefab with the target relationship is set as the target position information, and the prefab to be replaced is deleted.
[0124] In other words, it is to first control the target prefab with the target relationship to inherit the original position information to obtain the target prefab at the original position information, and then use the input position offset parameter to transform the target prefab at the original position information to transform it to the target position information.
[0125] As an implementation manner, it can be to update the original position information to the target position information based on the position offset parameter, and then directly set the position information of the target prefab with the target relationship as the target position information, and delete the prefab to be replaced.
[0126] In some implementation manners, in order to simplify the user operation, after replacing the prefab to be replaced with the target prefab based on the original position information, a preset array can also be created; the target prefab is stored in the preset array, and the target prefab is controlled to be in a selected state.
[0127] The selected state refers to the display state of the target prefab obtained after replacement. Specifically, a specified special effect can be set for the target prefab to indicate that it is in the selected state. Among them, the specified special effect can be a glowing special effect, a stroking special effect, etc., and can be specifically set according to actual needs. For example, taking the specified special effect as the stroking special effect, it can be to perform a stroking process on the objects in the preset array. Thus, the target prefab has a stroking special effect to indicate to the user that the target prefab is in the selected state. For example, refer to Figure 3 , which shows a schematic diagram of the target prefab in the selected state. Assume that there are 3 virtual objects in the virtual scene 101, namely the cube 102, the cylinder 103, and the pentagram 104. Among them, the pentagram 104 is the target prefab after replacement. After performing a stroking process on it, it can be seen that the outer contour of the pentagram 104 is significantly thicker than other virtual objects.
[0128] In some implementation manners, if the user is not satisfied with the replacement effect, the target prefab can also be used as a candidate object for the next replacement without having to select again, improving the replacement efficiency.
[0129] In some embodiments, in order to simplify user operations, after the target preform is stored in the preset array and the target preform is controlled to be in a selected state, the preform to be replaced that is pre-stored can be obtained in response to a retraction operation; based on the original position information, the preform to be replaced is controlled to replace the target preform.
[0130] If the user is not satisfied with the effect after replacement, the user can also perform a retraction operation to withdraw the replacement operation and restore the preform to be replaced. The retraction operation refers to the operation of withdrawing the replacement. After the retraction operation is detected, the original position information of the preform to be replaced stored in advance can be obtained in response to the retraction operation, and then the preform to be replaced can be controlled to replace the target preform based on the original position information. That is, the preform to be replaced is set at the position indicated by the original position information, and then the target preform is deleted, so as to realize the retraction of the operation of replacing the preform to be replaced with the target preform.
[0131] In some embodiments, in order to facilitate user operation, the serial number corresponding to the preform to be replaced can also be obtained, and the corresponding target preform can be controlled to inherit the serial number. For example, the serial number corresponding to the preform to be replaced can be obtained, and the serial number is used to indicate the arrangement order of the preforms to be replaced in the viewing window; the serial number of the target preform corresponding to the preform to be replaced is set to the serial number corresponding to the preform to be replaced.
[0132] The serial number may be used to indicate the sorting order of the prefabricated bodies to be replaced in the viewing window. To facilitate user operation, the serial number of the prefabricated bodies to be replaced may be assigned to the corresponding target prefabricated bodies.
[0133] The prefabricated body replacement scheme provided in the embodiment of the present application can be applied to various prefabricated body replacement scenarios. For example, in the case of replacing a specified prefabricated body in game development, the specified prefabricated body can be selected and replaced from any virtual object selected by the user. The scheme provided in the embodiment of the present application can further reduce manual operations when replacing prefabricated bodies, thereby avoiding manual misoperation and improving the replacement efficiency of prefabricated bodies.
[0134] Through the method provided by the embodiments of the present application, the storage information and attribute information of candidate objects can be obtained; and based on the storage information and attribute information of the candidate objects, the prefabricated body to be replaced is determined from the candidate objects, and based on the original position information of the prefabricated body to be replaced, the prefabricated body to be replaced is replaced with the target prefabricated body. By automatically determining the prefabricated body to be replaced from the candidate objects, a large amount of time consumed by manually determining the prefabricated body to be replaced can be avoided, thereby improving the replacement efficiency of the prefabricated body. And the position of the replaced target prefabricated body can be adjusted by the input position offset parameter, which can avoid the phenomenon of offset of the replaced target prefabricated body and does not require manual adjustment, so that a better replacement effect can be obtained and the replacement efficiency is also improved.
[0135] The method described in the above embodiments will be further described in detail below.
[0136] In this embodiment, taking the replacement of prefabricated bodies of nested type and lost local file type as an example, the method of the embodiments of the present application will be described in detail.
[0137] As Figure 4 shown, the specific process of a prefabricated body replacement method is as follows:
[0138] S210. In response to a user operation, obtain candidate objects and the storage information and attribute information of the candidate objects.
[0139] When prefabricated body replacement is required, the user can select all virtual objects in the area where the prefabricated body to be replaced is located, and these selected virtual objects are candidate objects. Then, on the basis of selecting the candidate objects, the user clicks the control corresponding to the replacement function to enable the replacement function.
[0140] After the user clicks the control corresponding to the replacement function, the storage information and attribute information of the candidate objects can be directly obtained, and the storage information and attribute information of the candidate objects are stored using a preset data structure.
[0141] S220. Based on the storage information and attribute information of the candidate objects, determine the prefabricated body to be replaced from the candidate objects.
[0142] After obtaining the storage information and attribute information of the candidate objects, the target object type of the candidate objects can be determined, and then the prefabricated body to be replaced is determined based on the target object type.
[0143] First, it can be determined whether the candidate object belongs to the object stored locally based on the storage information. If so, it is determined that the candidate object is of the prefabricated body type, that is, the aforementioned first storage type; if not, it is determined that the candidate object is of the non-prefabricated body type, that is, the aforementioned second storage type.
[0144] Then continue to classify the candidate objects of the prefab type based on the attribute information. Specifically, it can be determined whether the candidate object is a nested prefab based on the nesting relationship between the candidate object and other objects. If so, the candidate object is a nested prefab, that is, the aforementioned first nesting type. If not, the candidate object is a non-nested prefab, that is, the aforementioned second nesting type.
[0145] Then, it can also continue to determine whether the candidate object of the prefab type is a prefab that has lost the local file based on the attribute information. If so, it can be determined as a prefab that has lost the local file, that is, the aforementioned first loss type. If not, it can be determined as a prefab that has not lost the local file, that is, the aforementioned second loss type.
[0146] The above specific classification logic can be integrated into the Application Programming Interface (API). By calling the API, the target object type of the candidate object can be determined. The specific classification logic can refer to the corresponding content in the foregoing embodiments. To avoid repetition, it will not be elaborated here.
[0147] Then, according to the target object type of the candidate object and the preset specified object type, the prefab to be replaced will be screened out from the candidate objects, that is, the prefab of the nested type and the prefab of the type that has lost the local file.
[0148] S230. Draw a replacement panel according to the prefab to be replaced. The replacement panel includes the information of the prefab to be replaced, the information of the target prefab, and the position offset parameter.
[0149] Then use a preset data structure to store the attribute information, storage information, and classification results of the prefab to be replaced.
[0150] For the convenience of user operation, a replacement panel can be drawn based on the prefab to be replaced. Specifically, the target prefab can be passed in through the replacement panel, and then using the data stored in the preset data structure and the graphical user interface code extended by the engine, the information of the object to be replaced is drawn in the replacement panel, and a clickable replacement button is added to execute the final replacement logic. For example, refer to Figure 5 , which shows a schematic diagram of the replacement panel. Among them, in the area indicated by 201, the target prefab can be selected to display the information of the target prefab.
[0151] To ensure that the replaced target prefab remains at the position of the prefab to be replaced, the offset information of the position input by the user, that is, the position offset parameter, can also be added to the replacement panel, including the values of translation, rotation, and scaling. The user can choose whether to input the position offset parameter. For example, continue to refer to Figure 5, it can be selected within the selection box 202. If the selection box 202 is clicked, the content within the area indicated by 203 can be displayed, that is, the setting of the position offset parameter. The value of the position offset parameter displayed within the area indicated by 203 is the default value, and the user can modify the value according to needs.
[0152] In some embodiments, it can also be that the content within the area indicated by 203 is always displayed, and only after selection within the selection box 202, editing of the content within the area indicated by 203 is allowed.
[0153] Meanwhile, information of the prefabricated body to be replaced can also be displayed within the area indicated by 204 in the replacement panel. For example, the prefabricated bodies to be replaced can be classified and displayed according to the target object type, etc.
[0154] S240. Determine the target replacement strategy based on the position offset parameter.
[0155] S250. Replace the prefabricated body to be replaced with the target prefabricated body based on the position information of the object to be replaced and the target replacement strategy.
[0156] The replacement panel can also provide a replacement button 205 and a save modification button 206. The user can click the save modification button 206 to save the input data. After the user clicks the replacement button 205, replacement can be achieved. After the user clicks the replacement button 205, in response to the user operation, the target replacement strategy can be determined according to the position offset parameter.
[0157] If the obtained position offset parameter is the default value, the position information of the prefabricated body to be replaced can be directly assigned to the target prefabricated body to achieve replacement.
[0158] If the obtained position offset parameter is not the default value, the position information of the prefabricated body to be replaced can be first assigned to the target prefabricated body, and then the position of the target prefabricated body can be corrected based on the position offset parameter to achieve the final replacement. According to the target replacement strategy, all prefabricated bodies to be replaced can be deleted and all replaced with the target prefabricated body. Since there can also be multiple prefabricated bodies to be replaced, batch replacement of prefabricated bodies can be achieved without manual replacement one by one, thereby improving the replacement efficiency of prefabricated bodies.
[0159] In some embodiments, the target prefab can also inherit the serial number of the prefab to be replaced, so as to ensure that the sorting order of the target prefab after replacement in the inspection window is the same as that of the prefab to be replaced. At the same time, a temporary array is created to store the target prefab after replacement, and this part is regarded as the object selected next time, so that the target prefab can always be in the selected state after replacement. In the final replacement logic, all the prefabs to be replaced in the previous replacement can also be recorded, so as to support the operation of withdrawing, that is, returning to the state before replacement.
[0160] As can be seen from the above, the embodiments of the present application can automatically determine the prefab to be replaced from the candidate objects, avoiding the consumption of a large amount of time for manually determining the prefab to be replaced, thereby improving the replacement efficiency of the prefab. And the position of the target prefab after replacement can be adjusted by the input position offset parameter, which can avoid the phenomenon of offset of the target prefab after replacement, without manual adjustment, and can not only obtain a better replacement effect, but also improve the replacement efficiency. Controlling the target prefab obtained after replacement to be in the selected state, supporting the withdrawal of replacement, and being able to inherit the arrangement order of the prefab to be replaced can all simplify the user operation and reduce the workload of manual operation, thereby improving the replacement efficiency of the prefab.
[0161] To better implement the above method, the embodiments of the present application also provide a prefab replacement device, which can be specifically integrated in an electronic device, and the electronic device can be a device such as a terminal or a server. Among them, the terminal can be a device such as a mobile phone, a tablet computer, a smart Bluetooth device, a notebook computer, or a personal computer; the server can be a single server or a server cluster composed of multiple servers.
[0162] For example, in this embodiment, taking the prefab replacement device being specifically integrated in a terminal device as an example, the method of the embodiments of the present application will be described in detail.
[0163] For example, as Figure 6 shown, the prefab replacement device 300 can include an acquisition module 310, a screening module 320, a position acquisition module 330, and a replacement module 340.
[0164] The acquisition module 310 is configured to acquire the storage information and attribute information of candidate objects, where the candidate objects are selected virtual objects;
[0165] The screening module 320 is configured to determine the prefab to be replaced from the candidate objects based on the storage information and attribute information of the candidate objects;
[0166] A position acquisition module 330, configured to acquire original position information corresponding to the to-be-replaced prefabricated body, where the original position information is used to represent the position of the to-be-replaced prefabricated body in a virtual scene;
[0167] A replacement module 340, configured to replace the to-be-replaced prefabricated body with a target prefabricated body according to the original position information.
[0168] In some embodiments, the screening module 320 further includes:
[0169] A type determination unit, configured to determine a target object type corresponding to the candidate object based on the storage information and attribute information of the candidate object;
[0170] A screening unit, configured to determine the to-be-replaced prefabricated body from the candidate objects based on the target object type corresponding to the candidate objects and a preset specified object type.
[0171] In some embodiments, the target object type includes a target prefabricated body type or a target storage type, and the type determination unit is further configured to:
[0172] Determine a target storage type corresponding to the candidate object based on the storage information;
[0173] If the target storage type is a preset storage type, determine a target prefabricated body type corresponding to the candidate object based on the attribute information, and determine the target prefabricated body type as the target object type;
[0174] If the target storage type is not the preset storage type, determine the target storage type as the target object type.
[0175] In some embodiments, the type determination unit is further configured to:
[0176] Obtain a storage path indicated by the storage information;
[0177] If a file with a specified file extension is found under the storage path, determine that the target storage type corresponding to the candidate object is a first storage type;
[0178] If a file with a specified file extension is not found under the storage path, determine that the target storage type corresponding to the candidate object is a second storage type.
[0179] In some embodiments, the attribute information includes a nesting relationship between the candidate object and other objects, the target prefabricated body type includes a target nesting type, and the type determination unit is further configured to:
[0180] If, based on the nested relationship, it is determined that the candidate object has a corresponding parent object, the target nested type is determined as the first nested type;
[0181] If, based on the nested relationship, it is determined that the candidate object does not have a corresponding parent object, the target nested type is determined as the second nested type.
[0182] In some embodiments, the attribute information further includes an object identifier, the target prefab type further includes a target loss type, and the type determination unit is further configured to:
[0183] According to the target nested type and the object identifier of the candidate object, determine the target object identifier corresponding to the candidate object;
[0184] If the target object identifier includes a specified field, determine the target loss type as the first loss type;
[0185] If the target object identifier does not include a specified field, determine the target loss type as the second loss type.
[0186] In some embodiments, the replacement module 340 includes:
[0187] A target policy determination unit, configured to determine a target replacement policy corresponding to the prefab to be replaced according to the input position offset parameter;
[0188] A replacement unit, configured to replace the prefab to be replaced with a target prefab based on the target replacement policy and the original position information.
[0189] In some embodiments, the target replacement policy is the first replacement policy or the second replacement policy, and the replacement unit is further configured to:
[0190] Obtain the parent object corresponding to the prefab to be replaced to obtain a target parent object;
[0191] Set the target prefab as a child object of the target parent object to obtain a target prefab with a target relationship;
[0192] If the target replacement policy is the first replacement policy, set the position information of the target prefab with the target relationship as the original position information, and delete the prefab to be replaced;
[0193] If the target replacement policy is the second replacement policy, set the position information of the target prefab with the target relationship as the target position information, and delete the prefab to be replaced, where the target position information is determined by the original position information and the input position offset parameter.
[0194] In some embodiments, the replacement unit is further configured to:
[0195] Set the position information of the target prefabricated body with the target relationship as the original position information;
[0196] Update the original position information based on the position offset parameter to obtain the target position information;
[0197] Set the position information of the target prefabricated body with the target relationship as the target position information, and delete the prefabricated body to be replaced.
[0198] In some embodiments, the prefabricated body replacement device 300 further includes a storage module for:
[0199] Create a preset array;
[0200] Store the target prefabricated body in the preset array and control the target prefabricated body to be in a selected state.
[0201] In some embodiments, the prefabricated body replacement device 300 further includes a retraction module. After storing the target prefabricated body in the preset array and controlling the target prefabricated body to be in a selected state, the retraction module is used for:
[0202] Respond to the retraction operation to obtain the original position information of the prefabricated body to be replaced stored in advance;
[0203] Based on the original position information, control the prefabricated body to be replaced to replace the target prefabricated body.
[0204] In some embodiments, the prefabricated body replacement device 300 further includes a serial number inheritance module for:
[0205] Obtain the serial number corresponding to the prefabricated body to be replaced, where the serial number is used to indicate the arrangement order of the prefabricated body to be replaced in the inspection window;
[0206] Set the serial number of the target prefabricated body corresponding to the prefabricated body to be replaced as the serial number corresponding to the prefabricated body to be replaced.
[0207] In specific implementation, the above-mentioned modules or units can be implemented as independent entities, or can be arbitrarily combined and implemented as the same or several entities. For the specific implementation of the above-mentioned modules or units, reference can be made to the foregoing method embodiments, which will not be elaborated herein.
[0208] As can be seen from the above, the preform replacement device of this embodiment can obtain the storage information and attribute information of candidate objects; and based on the storage information and attribute information of the candidate objects, determine the preform to be replaced from the candidate objects, and based on the original position information of the object to be replaced, replace the preform to be replaced with the target preform. By automatically determining the preform to be replaced from the candidate objects, it is possible to avoid the consumption of a large amount of time for manually determining the preform to be replaced, thereby improving the replacement efficiency of the preform.
[0209] Correspondingly, an embodiment of the present application further provides an electronic device, which can be a terminal or a server. The terminal can be a terminal device such as a smart phone, a tablet computer, a notebook computer, a touch screen, a game console, a personal computer, a personal digital assistant (Personal Digital Assistant, PDA), etc.
[0210] As Figure 7 shown, Figure 7 is a schematic structural diagram of the electronic device provided by the embodiment of the present application. The electronic device 400 includes a processor 401 with one or more processing cores, a memory 402 with one or more computer-readable storage media, and a computer program stored in the memory 402 and executable on the processor. Among them, the processor 401 is electrically connected to the memory 402. Those skilled in the art can understand that the structural diagram of the electronic device shown in the figure does not constitute a limitation on the electronic device, and it may include more or fewer components than shown in the figure, or combine certain components, or have different component arrangements.
[0211] The processor 401 is the control center of the electronic device 400, connecting various parts of the entire electronic device 400 through various interfaces and lines. By running or loading software programs and / or modules stored in the memory 402, and calling data stored in the memory 402, it executes various functions of the electronic device 400 and processes data, thereby monitoring the entire electronic device 400.
[0212] In the embodiment of the present application, the processor 401 in the electronic device 400 will load the instructions corresponding to the processes of one or more application programs into the memory 402 according to the following steps, and the processor 401 will run the application programs stored in the memory 402 to achieve various functions:
[0213] Obtain the storage information and attribute information of a candidate object, where the candidate object is a selected virtual object; based on the storage information and attribute information of the candidate object, determine a prefab to be replaced from the candidate object; obtain the original position information corresponding to the prefab to be replaced, where the original position information is used to represent the position of the prefab to be replaced in the virtual scene; according to the original position information, replace the prefab to be replaced with a target prefab.
[0214] By automatically determining the prefab to be replaced from the candidate object, it is possible to avoid the consumption of a large amount of time for manually determining the prefab to be replaced, thereby improving the replacement efficiency of the prefab.
[0215] Based on the storage information and attribute information of the candidate object, determine the target object type corresponding to the candidate object; based on the target object type corresponding to the candidate object and a preset specified object type, determine the prefab to be replaced from the candidate object.
[0216] By classifying the candidate object to obtain the target object type of the candidate object and screening out the prefab to be replaced from the candidate object based on the target object type, it is possible to avoid the consumption of a large amount of time for manually determining the prefab to be replaced, thereby improving the replacement efficiency of the prefab.
[0217] The target object type includes a target prefab type or a target storage type. Based on the storage information, determine the target storage type corresponding to the candidate object; if the target storage type is a preset storage type, based on the attribute information, determine the target prefab type corresponding to the candidate object, and determine the target prefab type as the target object type; if the target storage type is not the preset storage type, determine the target storage type as the target object type.
[0218] Through the target storage type and the target prefab type, the accuracy of determining the target object type can be improved.
[0219] Obtain the storage path indicated by the storage information; if a file with a specified file extension is found under the storage path, determine that the target storage type corresponding to the candidate object is the first storage type; if a file with a specified file extension is not found under the storage path, determine that the target storage type corresponding to the candidate object is the second storage type.
[0220] Based on the file with a specified file extension, determine the target storage type of the candidate object, which can ensure the accuracy of the determined target storage type.
[0221] The attribute information includes the nesting relationship between the candidate object and other objects. The target prefab type includes a target nesting type. If, based on the nesting relationship, it is determined that the candidate object has a corresponding parent object, the target nesting type is determined to be the first nesting type; if, based on the nesting relationship, it is determined that the candidate object does not have a corresponding parent object, the target nesting type is determined to be the second nesting type.
[0222] The attribute information further includes an object identifier, and the target prefab type further includes a target loss type; according to the target nesting type and the object identifier of the candidate object, the target object identifier corresponding to the candidate object is determined; if the target object identifier includes a specified field, the target loss type is determined to be the first loss type; if the target object identifier does not include the specified field, the target loss type is determined to be the second loss type.
[0223] When determining the target prefab type, it can include determining the target nesting type and the target loss type, which can classify candidate objects more comprehensively, improve the accuracy of classification, and thus improve the accuracy of screening the prefab to be replaced.
[0224] According to the input position offset parameter, the target replacement strategy corresponding to the prefab to be replaced is determined; based on the target replacement strategy and the original position information, the prefab to be replaced is replaced with the target prefab.
[0225] According to the input position offset parameter, the position of the target prefab can be corrected. By selecting and determining the corresponding target replacement strategy based on the position offset parameter, a better replacement effect can be ensured, without manual correction, improving the efficiency of prefab replacement.
[0226] The parent object corresponding to the prefab to be replaced is obtained to get the target parent object; the target prefab is set as the child object of the target parent object to obtain the target prefab with the target relationship; if the target replacement strategy is the first replacement strategy, the position information of the target prefab with the target relationship is set as the original position information, and the prefab to be replaced is deleted; if the target replacement strategy is the second replacement strategy, the position information of the target prefab with the target relationship is set as the target position information, and the prefab to be replaced is deleted, where the target position information is determined by the original position information and the input position offset parameter.
[0227] The position information of the target prefab with the target relationship is set as the original position information; based on the position offset parameter, the original position information is updated to obtain the target position information; the position information of the target prefab with the target relationship is set as the target position information, and the prefab to be replaced is deleted.
[0228] Through the first replacement strategy, the original position information of the prefab to be replaced can be directly assigned to the target prefab to achieve in-situ replacement. Through the second replacement strategy, on the basis of in-situ replacement, the position of the target prefab can be corrected to avoid the phenomenon of deviation after replacement.
[0229] Create a preset array; store the target prefab in the preset array and control the target prefab to be in a selected state.
[0230] After obtaining the target prefab by replacement, the target prefab can be controlled to be in a selected state, so as to directly operate on the target prefab without re-selection, simplifying the user operation.
[0231] In response to the withdrawal operation, obtain the original position information of the prefab to be replaced stored in advance; based on the original position information, control the prefab to be replaced to replace the target prefab.
[0232] Obtain the serial number corresponding to the prefab to be replaced, where the serial number is used to indicate the arrangement order of the prefab to be replaced in the inspection window; set the serial number of the target prefab corresponding to the prefab to be replaced to the serial number corresponding to the prefab to be replaced.
[0233] Pre-store the original position information of the prefab to be replaced to support withdrawal, so as to restore the prefab to be replaced before replacement; control the target prefab to inherit the serial number of the prefab to be replaced, ensuring that the sorting order of the target prefab after replacement is the same as the arrangement order of the prefab to be replaced in the inspection window.
[0234] For the specific implementation of each of the above operations, reference can be made to the previous embodiments and will not be elaborated here.
[0235] Optionally, as Figure 7 shown, the electronic device 400 further includes: a touch display screen 403, a radio frequency circuit 404, an audio circuit 405, an input unit 406, and a power supply 407. Among them, the processor 401 is electrically connected to the touch display screen 403, the radio frequency circuit 404, the audio circuit 405, the input unit 406, and the power supply 407 respectively. Those skilled in the art can understand that Figure 7 the structure of the electronic device shown in
[0236] The touch display screen 403 can be used to display a graphical user interface and receive operation instructions generated by a user acting on the graphical user interface. The touch display screen 403 may include a display panel and a touch panel. Among them, the display panel can be used to display information input by the user or information provided to the user, as well as various graphical user interfaces of the electronic device. These graphical user interfaces can be composed of graphics, text, icons, videos, and any combination thereof. Optionally, the display panel can be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), etc. The touch panel can be used to collect touch operations of the user on or near it (such as operations of the user using any suitable object or accessory such as a finger or a stylus on the touch panel or near the touch panel), and generate corresponding operation instructions, and the operation instructions execute the corresponding program. Optionally, the touch panel can include two parts: a touch detection device and a touch controller. Among them, the touch detection device detects the touch position of the user and detects the signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts it into contact coordinates, and then sends it to the processor 401, and can receive and execute the commands sent by the processor 401. The touch panel can cover the display panel. When the touch panel detects a touch operation on or near it, it is transmitted to the processor 401 to determine the type of touch event. Subsequently, the processor 401 provides a corresponding visual output on the display panel according to the type of touch event. In the embodiments of the present application, the touch panel and the display panel can be integrated into the touch display screen 403 to implement input and output functions. However, in some embodiments, the touch panel and the touch panel can be implemented as two independent components to implement input and output functions. That is, the touch display screen 403 can also be used as a part of the input unit 406 to implement the input function.
[0237] In the embodiments of the present application, a graphical user interface is generated on the touch display screen 403 by the processing logic of the processor 401 executing the engine, and a replacement panel can be provided on the graphical user interface. The touch display screen 403 is used to present the graphical user interface and receive operation instructions generated by a user acting on the graphical user interface.
[0238] The radio frequency circuit 404 can be used to transmit and receive radio frequency signals to establish wireless communication with a network device or other electronic devices through wireless communication, and transmit and receive signals with the network device or other electronic devices.
[0239] The audio circuit 405 can be used to provide an audio interface between the user and the electronic device through a speaker and a microphone. The audio circuit 405 can transmit the electrical signal converted from the received audio data to the speaker, which converts it into a sound signal for output; on the other hand, the microphone converts the collected sound signal into an electrical signal, which is received by the audio circuit 405 and then converted into audio data. After the audio data is output to the processor 401 for processing, it is sent via the radio frequency circuit 404 to, for example, another electronic device, or the audio data is output to the memory 402 for further processing. The audio circuit 405 may also include an earphone jack to provide communication between the peripheral earphone and the electronic device.
[0240] The input unit 406 can be used to receive input digital, character information or user feature information (such as fingerprint, iris, facial information, etc.), and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function controls.
[0241] The power supply 407 is used to supply power to each component of the electronic device 400. Optionally, the power supply 407 can be logically connected to the processor 401 through a power management system, so as to realize functions such as management of charging, discharging, and power consumption management through the power management system. The power supply 407 may also include any components such as one or more DC or AC power supplies, a recharge system, a power failure detection circuit, a power converter or inverter, and a power status indicator.
[0242] Although Figure 7 not shown in the figure, the electronic device 400 may also include a camera, a sensor, a Wi-Fi module, a Bluetooth module, etc., which will not be elaborated here.
[0243] In the above embodiments, the descriptions of each embodiment have their own emphases. For the parts not detailed in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0244] As can be seen from the above, the electronic device provided in this embodiment can obtain the storage information and attribute information of the candidate object; and based on the storage information and attribute information of the candidate object, determine the preform to be replaced from the candidate objects, and based on the original position information of the object to be replaced, replace the preform to be replaced with the target preform. By automatically determining the preform to be replaced from the candidate objects, it is possible to avoid the consumption of a large amount of time for manually determining the preform to be replaced, thereby improving the replacement efficiency of the preform.
[0245] Those of ordinary skill in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructions, or by controlling related hardware through instructions. The instructions can be stored in a computer-readable storage medium and loaded and executed by a processor.
[0246] To this end, an embodiment of the present application provides a computer-readable storage medium, in which multiple computer programs are stored, and the computer programs can be loaded by a processor to execute the steps in any of the prefabricated body replacement methods provided by the embodiments of the present application. For example, the computer program can execute the following steps:
[0247] Obtain the storage information and attribute information of a candidate object, where the candidate object is a selected virtual object; based on the storage information and attribute information of the candidate object, determine a prefabricated body to be replaced from the candidate objects; obtain the original position information corresponding to the prefabricated body to be replaced, where the original position information is used to represent the position of the prefabricated body to be replaced in the virtual scene; according to the original position information, replace the prefabricated body to be replaced with a target prefabricated body.
[0248] By automatically determining the prefabricated body to be replaced from the candidate objects, it is possible to avoid consuming a large amount of time in manually determining the prefabricated body to be replaced, thereby improving the replacement efficiency of the prefabricated body.
[0249] Based on the storage information and attribute information of the candidate object, determine the target object type corresponding to the candidate object; based on the target object type corresponding to the candidate object and a preset specified object type, determine the prefabricated body to be replaced from the candidate objects.
[0250] By classifying the candidate objects to obtain the target object type of the candidate objects and screening out the prefabricated bodies to be replaced from the candidate objects based on the target object type, it is possible to avoid consuming a large amount of time in manually determining the prefabricated body to be replaced, thereby improving the replacement efficiency of the prefabricated body.
[0251] The target object type includes a target prefabricated body type or a target storage type. Based on the storage information, determine the target storage type corresponding to the candidate object; if the target storage type is a preset storage type, based on the attribute information, determine the target prefabricated body type corresponding to the candidate object, and determine the target prefabricated body type as the target object type; if the target storage type is not the preset storage type, determine the target storage type as the target object type.
[0252] Through the target storage type and the target prefabricated body type, the accuracy of determining the target object type can be improved.
[0253] Obtain the storage path indicated by the storage information; if a file with a specified file extension is found under the storage path, determine that the target storage type corresponding to the candidate object is a first storage type; if a file with a specified file extension is not found under the storage path, determine that the target storage type corresponding to the candidate object is a second storage type.
[0254] Determining the target storage type of the candidate object based on a file with a specified file extension can ensure the accuracy of the determined target storage type.
[0255] The attribute information includes the nesting relationship between the candidate object and other objects. The target prefab type includes a target nesting type. If, based on the nesting relationship, it is determined that the candidate object has a corresponding parent object, the target nesting type is determined to be the first nesting type; if, based on the nesting relationship, it is determined that the candidate object does not have a corresponding parent object, the target nesting type is determined to be the second nesting type.
[0256] The attribute information further includes an object identifier, and the target prefab type further includes a target loss type; according to the target nesting type and the object identifier of the candidate object, the target object identifier corresponding to the candidate object is determined; if the target object identifier includes a specified field, the target loss type is determined to be the first loss type; if the target object identifier does not include the specified field, the target loss type is determined to be the second loss type.
[0257] When determining the target prefab type, it may include determining the target nesting type and the target loss type, which can classify the candidate object more comprehensively, improve the accuracy of classification, and further improve the accuracy of screening the prefab to be replaced.
[0258] According to the input position offset parameter, determine the target replacement strategy corresponding to the prefab to be replaced; based on the target replacement strategy and the original position information, replace the prefab to be replaced with the target prefab.
[0259] According to the input position offset parameter, it is possible to correct the position of the target prefab, select and determine the corresponding target replacement strategy based on the position offset parameter, which can ensure a better replacement effect, eliminate the need for manual correction, and improve the efficiency of prefab replacement.
[0260] Obtain the parent object corresponding to the prefab to be replaced to get the target parent object; set the target prefab as the child object of the target parent object to obtain a target prefab with a target relationship; if the target replacement strategy is the first replacement strategy, set the position information of the target prefab with the target relationship to the original position information and delete the prefab to be replaced; if the target replacement strategy is the second replacement strategy, set the position information of the target prefab with the target relationship to the target position information and delete the prefab to be replaced, where the target position information is determined by the original position information and the input position offset parameter.
[0261] Set the position information of the target prefabricated body with the target relationship as the original position information; update the original position information based on the position offset parameter to obtain the target position information; set the position information of the target prefabricated body with the target relationship as the target position information, and delete the prefabricated body to be replaced.
[0262] Through the first replacement strategy, the original position information of the prefabricated body to be replaced can be directly assigned to the target prefabricated body to achieve in-situ replacement. Through the second replacement strategy, on the basis of achieving in-situ replacement, the position of the target prefabricated body can be corrected to avoid the phenomenon of offset after replacement.
[0263] Create a preset array; store the target prefabricated body in the preset array, and control the target prefabricated body to be in a selected state.
[0264] After obtaining the target prefabricated body by replacement, the target prefabricated body can be controlled to be in a selected state, so as to directly operate on the target prefabricated body without re-selection, simplifying the user operation.
[0265] In response to the withdrawal operation, obtain the original position information of the prefabricated body to be replaced stored in advance; based on the original position information, control the prefabricated body to be replaced to replace the target prefabricated body.
[0266] Obtain the serial number corresponding to the prefabricated body to be replaced, where the serial number is used to indicate the arrangement order of the prefabricated body to be replaced in the inspection window; set the serial number of the target prefabricated body corresponding to the prefabricated body to be replaced as the serial number corresponding to the prefabricated body to be replaced.
[0267] Pre-store the original position information of the prefabricated body to be replaced to support withdrawal, so as to restore the prefabricated body to be replaced before replacement; control the target prefabricated body to inherit the serial number of the prefabricated body to be replaced, ensuring that the sorting order of the target prefabricated body after replacement is the same as the arrangement order of the prefabricated body to be replaced in the inspection window.
[0268] For the specific implementation of each of the above operations, reference can be made to the previous embodiments and will not be elaborated here.
[0269] Among them, the storage medium may include: read-only memory (ROM, Read Only Memory), random access memory (RAM, Random Access Memory), magnetic disk or optical disk, etc.
[0270] Since the computer program stored in the storage medium can execute the steps in any of the prefabricated body replacement methods provided in the embodiments of the present application, the beneficial effects that can be achieved by any of the prefabricated body replacement methods provided in the embodiments of the present application can be realized. For details, refer to the previous embodiments and will not be elaborated here.
[0271] The above has introduced in detail a preform replacement method, device, electronic device and storage medium provided by the embodiments of the present application. Specific examples are used herein to elaborate on the principle and implementation manner of the present application. The description of the above embodiments is only used to help understand the method and its core idea of the present application; at the same time, for those skilled in the art, according to the idea of the present application, there will be changes in the specific implementation manner and application scope. In summary, the content of this specification should not be construed as a limitation to the present application.
Claims
1. A preform replacement method, characterized in that, the method includes: Obtaining the storage information and attribute information of a candidate object, where the candidate object is a selected virtual object; Based on the storage information and attribute information of the candidate object, determining the target object type corresponding to the candidate object; Based on the target object type corresponding to the candidate object and a preset specified object type, determining a preform to be replaced from the candidate objects; Obtaining the original position information corresponding to the preform to be replaced, where the original position information is used to represent the position of the preform to be replaced in the virtual scene; According to the original position information, replacing the preform to be replaced with a target preform; wherein, the target object type includes a target preform type; the target preform type includes a target nesting type; the attribute information includes the nesting relationship between the candidate object and other objects; determining the preform to be replaced from the candidate objects based on the target object type corresponding to the candidate object and a preset specified object type includes: If it is determined based on the nesting relationship that the candidate object has a corresponding parent object, determining that the target nesting type is the first nesting type; If it is determined based on the nesting relationship that the candidate object does not have a corresponding parent object, determining that the target nesting type is the second nesting type; The replacing the preform to be replaced with a target preform according to the original position information includes: Determining a target replacement strategy corresponding to the preform to be replaced according to an input position offset parameter; the target replacement strategy is the first replacement strategy or the second replacement strategy; Obtaining the parent object corresponding to the preform to be replaced to obtain a target parent object; Setting the target preform as a child object of the target parent object to obtain a target preform with a target relationship; If the target replacement strategy is the first replacement strategy, setting the position information of the target preform with the target relationship to the original position information and deleting the preform to be replaced; If the target replacement strategy is the second replacement strategy, setting the position information of the target preform with the target relationship to target position information and deleting the preform to be replaced, where the target position information is determined by the original position information and the input position offset parameter.
2. The method according to claim 1, characterized in that, the target object type further includes a target storage type, and determining the target object type corresponding to the candidate object based on the storage information and attribute information of the candidate object includes: Based on the storage information, determining the target storage type corresponding to the candidate object; If the target storage type is a preset storage type, based on the attribute information, determining the target preform type corresponding to the candidate object and determining the target preform type as the target object type; If the target storage type is not the preset storage type, determining the target storage type as the target object type.
3. The method according to claim 2, characterized in that, Determining the target storage type corresponding to the candidate object based on the stored information includes: Obtaining the storage path indicated by the stored information; If a file with a specified file extension is found under the storage path, determining that the target storage type corresponding to the candidate object is the first storage type; If a file with a specified file extension is not found under the storage path, determining that the target storage type corresponding to the candidate object is the second storage type.
4. The method according to claim 3, wherein, the attribute information further includes an object identifier, the target prefab type further includes a target loss type, and determining the target prefab type corresponding to the candidate object based on the attribute information includes: Determining the target object identifier corresponding to the candidate object according to the target nesting type and object identifier of the candidate object; If the target object identifier includes a specified field, determining that the target loss type is the first loss type; If the target object identifier does not include a specified field, determining that the target loss type is the second loss type.
5. The method according to claim 1, wherein, Setting the position information of the target prefab having the target relationship to the target position information and deleting the prefab to be replaced includes: Setting the position information of the target prefab having the target relationship to the original position information; Updating the original position information based on the position offset parameter to obtain the target position information; Setting the position information of the target prefab having the target relationship to the target position information and deleting the prefab to be replaced.
6. The method according to claim 1, wherein, After replacing the prefab to be replaced with the target prefab according to the original position information, the method further includes: Creating a preset array; Storing the target prefab in the preset array and controlling the target prefab to be in a selected state.
7. The method according to claim 6, wherein, After storing the target prefab in the preset array and controlling the target prefab to be in a selected state, the method further includes: In response to a withdrawal operation, obtaining the original position information of the prefab to be replaced stored in advance; Controlling the prefab to be replaced to replace the target prefab based on the original position information.
8. The method according to any one of claims 1-7, wherein, the method further includes: Obtaining the serial number corresponding to the prefab to be replaced, where the serial number is used to indicate the arrangement order of the prefab to be replaced in the inspection window; Setting the serial number of the target prefab corresponding to the prefab to be replaced to the serial number corresponding to the prefab to be replaced.
9. A prefab replacement device, wherein, the device includes: An acquisition module for acquiring the storage information and attribute information of a candidate object, where the candidate object is a selected virtual object; A screening module for determining the target object type corresponding to the candidate object based on the storage information and attribute information of the candidate object; Determine a prefab to be replaced from the candidate objects based on the target object type corresponding to the candidate objects and a preset specified object type; A position acquisition module, configured to acquire original position information corresponding to the prefab to be replaced, where the original position information is used to represent the position of the prefab to be replaced in a virtual scene; A replacement module, configured to replace the prefab to be replaced with a target prefab according to the original position information; Wherein, the target object type includes a target prefab type; the target prefab type includes a target nesting type; the attribute information includes the nesting relationship between the candidate object and other objects; determining the prefab to be replaced from the candidate objects based on the target object type corresponding to the candidate objects and a preset specified object type includes: If it is determined, based on the nesting relationship, that the candidate object has a corresponding parent object, determine that the target nesting type is a first nesting type; If it is determined, based on the nesting relationship, that the candidate object does not have a corresponding parent object, determine that the target nesting type is a second nesting type; The replacing the prefab to be replaced with a target prefab according to the original position information includes: Determine a target replacement strategy corresponding to the prefab to be replaced according to an input position offset parameter; the target replacement strategy is a first replacement strategy or a second replacement strategy; Obtain the parent object corresponding to the prefab to be replaced to obtain a target parent object; Set the target prefab as a child object of the target parent object to obtain a target prefab with a target relationship; If the target replacement strategy is the first replacement strategy, set the position information of the target prefab with the target relationship to the original position information, and delete the prefab to be replaced; If the target replacement strategy is the second replacement strategy, set the position information of the target prefab with the target relationship to target position information, and delete the prefab to be replaced, where the target position information is determined by the original position information and the input position offset parameter.
10. An electronic device Characterized in that It includes a processor and a memory, and the memory stores multiple instructions; the processor loads the instructions from the memory to execute the steps in the prefab replacement method according to any one of claims 1 to 8.
11. A computer-readable storage medium Characterized in that The computer-readable storage medium stores multiple instructions, and the instructions are suitable for being loaded by a processor to execute the steps in the prefab replacement method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Implementation method and system supporting user-definition
CN106126242A
Inspection task and inspection role matching method and device, equipment and medium
CN113989953A