The method, apparatus, equipment and media for running the instance
By using the component conversion and plugin system under the ECS architecture, the data processing logic of the game scene editor and the game engine is decoupled, which solves the coupling problem between the game engine and the editor and improves computing performance and memory read speed.
Patent Information
- Application Number
- CN202211168043.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-23
- Publication Date
- 2025-12-02
- Estimated Expiration
- 2042-09-23
AI Technical Summary
In existing technologies, the data processing logic of the game engine and the game scene editor is coupled, resulting in high maintenance complexity and affecting computing performance and memory read speed.
The system adopts an Entity Component System (ECS) architecture, which converts the editing parameters of components into runtime parameters through the game scene editor. The plug-in system decouples the data processing logic, enabling parameter conversion to be completed on the editor side.
It reduces the complexity of maintaining the game engine's data processing logic, improves computing performance and memory read speed, and makes the overall logic lighter and cleaner.
Smart Images

Figure CN115501609B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to an example of an operating method, apparatus, device and medium. Background Technology
[0002] The game scene editor allows you to edit the parameters of instances within a game scene. These parameters reflect the attributes of the instances. For example, an instance might include virtual characters within the game's virtual environment and objects that make up that environment. To facilitate user understanding, the game scene editor typically provides time-of-care parameters for editing instances.
[0003] During runtime, the game engine runs instances based on their parameters. To improve computational performance and memory read speed, the game engine needs to use efficient data structures. Therefore, it is necessary to transform the instance editing parameters in the game scene editor into runtime parameters that are usable when running the instance.
[0004] The data processing logic that converts instance-time parameters into runtime parameters is typically defined within the game engine, and the game engine performs this conversion when running the instance. However, the game engine needs to consider the related logic in the game scene editor that involves these parameters during runtime, creating coupling between the two data processing logics and making the maintenance of the game engine's data processing logic more complex. Summary of the Invention
[0005] This application provides a method, apparatus, device, and medium for running an instance, which eliminates the need to maintain the data processing logic in the game engine, reducing the complexity of maintaining data processing logic. The technical solution is as follows:
[0006] According to one aspect of this application, a method for running an instance is provided, the method comprising:
[0007] Obtain the components that make up the instance, which are built based on the Entity-Component-System (ECS) architecture. The instance is an editing unit in the game scene editor, which is used to edit virtual scenes in a virtual environment-based application.
[0008] During the runtime phase of the instance, the runtime parameters of the component are obtained by converting the editing parameters in the component through the game scene editor. The conversion process is determined based on the data structure of the parameters used by the game engine when running the instance.
[0009] The instance is run using the game engine, based on the components and the runtime parameters.
[0010] According to another aspect of this application, an example operating apparatus is provided, the apparatus comprising:
[0011] The acquisition module is used to acquire the components that make up the instance. The components are built on the ECS architecture. The instance is an editing unit in the game scene editor, which is used to edit virtual scenes in a virtual environment-based application.
[0012] A conversion module is used to convert the editing parameters in the component to obtain the running parameters of the component through the game scene editor during the runtime phase of the instance. The conversion process is determined according to the data structure of the parameters used by the game engine when running the instance.
[0013] The runtime module is used to run the instance through the game engine, based on the components and the runtime parameters.
[0014] In an optional design, the conversion module is used for:
[0015] Based on the logical mapping relationship between the editing parameters and the running parameters, the running parameters of the component are obtained by converting the editing parameters in the component through the game scene editor;
[0016] The logical mapping relationship is determined based on the editing parameters and the data structure.
[0017] In an optional design, the conversion module is used for:
[0018] The game scene editor calls the plugin system to convert the editing parameters in the component, thereby obtaining the component's running parameters;
[0019] The plug-in system is used to process the data of the components, and the plug-in system is built on the ECS architecture.
[0020] In an optional design, the plug-in system defines processing functions; the conversion module is used for:
[0021] The game scene editor calls the plugin system to run the processing function, which converts the editing parameters in the component to obtain the component's running parameters.
[0022] In an optional design, the device further includes:
[0023] The registration module is used to register the components corresponding to the plugin system for the instance through the plugin system, so as to obtain the components that make up the instance.
[0024] In an optional design, the acquisition module is used for:
[0025] Based on the identifiers of the components that make up the instance, obtain the class of the plugin system corresponding to the component;
[0026] The plugin system is obtained based on its class.
[0027] In an optional design, the game scene editor displays the icon of the instance and the virtual environment; the device further includes:
[0028] The display module is configured to display the instance in the virtual environment in response to a drag operation in the game scene editor where the icon of the instance is dragged to the virtual environment.
[0029] According to another aspect of this application, a computer device is provided, the computer device including a processor and a memory, the memory storing at least one instruction, at least one program, code set or instruction set, the at least one instruction, the at least one program, the code set or instruction set being loaded and executed by the processor to implement the running method of the example as described above.
[0030] According to another aspect of this application, a computer-readable storage medium is provided, wherein at least one instruction, at least one program, code set, or instruction set is stored therein, wherein the at least one instruction, the at least one program, the code set, or the instruction set is loaded and executed by a processor to implement the running method of the example described above.
[0031] According to another aspect of this application, a computer program product or computer program is provided, comprising computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the execution methods provided in the various alternative implementations of the above aspects.
[0032] The beneficial effects of the technical solution provided in this application include at least the following:
[0033] By converting component editing parameters into runtime parameters through the game scene editor, the data processing logic for parameter conversion is implemented within the game scene editor, thus placing all editor-related data processing logic on the editor side. The game engine does not need to consider the data processing logic of instances in the game scene editor during runtime, decoupling the data processing logic between the game engine and the game scene editor. This results in a lighter and cleaner overall processing logic and a more streamlined overall runtime architecture, eliminating the need to maintain data processing logic within the game engine and reducing the complexity of maintaining such logic. Attached Figure Description
[0034] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0035] Figure 1 This is a schematic diagram of a panel of a game scene editor provided in an exemplary embodiment of this application;
[0036] Figure 2 This is a schematic diagram illustrating the process of registering an instance in a game scene editor, provided by an exemplary embodiment of this application.
[0037] Figure 3 This is a flowchart illustrating the operation method of an example provided in an exemplary embodiment of this application;
[0038] Figure 4 This is a flowchart illustrating the operation method of an example provided in an exemplary embodiment of this application;
[0039] Figure 5 This is a schematic diagram illustrating an example provided in an exemplary embodiment of this application;
[0040] Figure 6 This is a schematic diagram of the components of a constituent instance provided in an exemplary embodiment of this application;
[0041] Figure 7 This is a schematic diagram of a virtual environment provided in an exemplary embodiment of this application;
[0042] Figure 8 This is a schematic diagram of editing parameters provided in an exemplary embodiment of this application;
[0043] Figure 9 This is a flowchart illustrating an example of an editing method provided in an exemplary embodiment of this application;
[0044] Figure 10This is a flowchart illustrating an example of an editing method provided in an exemplary embodiment of this application;
[0045] Figure 11 This is a schematic diagram of the structure of an operating device for an example provided in an exemplary embodiment of this application;
[0046] Figure 12 This is a schematic diagram of the structure of an operating device for an example provided in an exemplary embodiment of this application;
[0047] Figure 13 This is a schematic diagram of the structure of an operating device for an example provided in an exemplary embodiment of this application;
[0048] Figure 14 This is a schematic diagram of the structure of an editing device provided in an exemplary embodiment of this application;
[0049] Figure 15 This is a schematic diagram of the structure of a computer device provided in an exemplary embodiment of this application.
[0050] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application. Detailed Implementation
[0051] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings.
[0052] First, let me introduce the terms used in this application:
[0053] Entity-Component-System (ECS): ECS is a game architecture pattern that follows the principle of "composition over inheritance". In the game, each basic unit is an entity, and each entity is composed of one or more components. The system is used to process the collection of components.
[0054] Editor: An editor is a software program, generally referring to writing software used to modify computer files. Common editors include text editors, web page editors, source code editors, image editors, sound editors, and video editors. In this application, the editor refers to a game scene editor, which is used to edit in-game scenes (levels).
[0055] Examples: Examples include virtual characters and objects that make up the virtual environment in a game. For instance, in this application, an example refers to an Actor in a game scene editor. An Actor is any object that can be placed in the virtual environment (level), such as a camera, a static mesh object, or the player's starting position.
[0056] Object-Oriented Programming (OOP): OOP is a programming paradigm based on the concept of "objects". It can contain data and code, such as data in the form of fields (usually called properties) and code in the form of procedures (usually called methods).
[0057] Class: Classes are the foundation for information encapsulation in OOP. A class is a user-defined reference data type, also known as a class type. Each class contains data descriptions and a set of functions for manipulating data or passing messages. Instances of a class are called objects.
[0058] Virtual environment: This refers to the virtual environment displayed (or provided) when an application (game) runs on a terminal. This virtual environment can be a simulation of the real world, a semi-simulated / semi-fictional environment, or a purely fictional environment. The virtual environment can be any of a two-dimensional, 2.5-dimensional, or three-dimensional virtual environment; this application does not limit this.
[0059] A virtual character is at least one movable object controlled by a user within a virtual environment. This virtual character can be a virtual human, virtual animal, an anime character, etc. Optionally, the virtual character is a three-dimensional model created using animation skeletal technology. Each virtual character has its own shape and volume within the virtual environment and occupies a portion of the space within that environment.
[0060] In the game scene editor, you need to place one or more instances (Actors). By dragging and dropping an instance into the game scene being edited in the scene editor, you can create (display) that instance within that scene. For example, Figure 1 This is a schematic diagram of a panel of a game scene editor provided in an exemplary embodiment of this application. Figure 1 As shown, the Place Actors option in the game scene editor's panel displays different types of instances, and instances within each type. For example, types include Basic, Light, and Camera. Instances under the Basic type can include Box, Plane, Airwall, and Path. Each instance has its own attributes, such as position and size. Traditional OOP models treat instances as the smallest unit (smallest editing unit) in the game scene editor, constructing each instance individually through code. This is overly complex, carries too many functionalities, and cannot dynamically add or remove attributes from instances.
[0061] Furthermore, the game scene editor allows users to edit the parameters of instances within a game scene. To facilitate user understanding, the game scene editor typically provides instance-time parameters. During runtime, the game engine runs the instance based on these parameters. To improve computational performance and memory read speed, the game engine requires efficient data structures. Therefore, it needs to convert the instance-time parameters in the game scene editor into runtime parameters usable when running the instance. The data processing logic for converting instance-time parameters into runtime parameters is usually defined within the game engine, and the game engine performs the parameter conversion when running the instance. The game engine needs to consider the related logic in the game scene editor concerning these parameters during runtime, creating coupling between the data processing logic of the two, making the maintenance of the data processing logic within the game engine more complex.
[0062] The method provided in this application, by using components under the ECS architecture to construct instances, can dynamically add or remove attributes for instances by adding or removing components without modifying the instance's code. Furthermore, since the attributes provided by the components are stored contiguously in memory, performance is improved. Additionally, by converting the component's editing parameters into runtime parameters through the game scene editor, the data processing logic for parameter conversion is implemented within the game scene editor, thus placing all editor-related data processing logic on the editor side. The game engine does not need to consider the instance-related data processing logic in the game scene editor during runtime, achieving decoupling between the game engine and the game scene editor's data processing logic. This makes the overall processing logic lighter and cleaner, and the overall runtime architecture more streamlined, eliminating the need to maintain the data processing logic in the game engine and reducing the complexity of maintaining data processing logic.
[0063] Figure 2 This is a schematic diagram illustrating the process of registering an instance in a game scene editor, provided by an exemplary embodiment of this application. For example... Figure 1 As shown, in step S1, the computer device obtains the class of the component, which includes code for defining the component, which is built on the ECS architecture.
[0064] In step S2, the computer device obtains the class of the plugin system (System). The plugin system class includes code defining the plugin system, which is built on the ECS architecture. This plugin system corresponds to the aforementioned components and is used to process component data. The plugin system provides interfaces for adding and removing components. It also defines processing functions (which may be called tick functions). The computer device's game scene editor calls these processing functions to convert the component's editing parameters into runtime parameters for the game engine when running the component.
[0065] In step S3, the computer device registers the components corresponding to the plugin system for the instance according to the plugin system. The instance is composed of its constituent components, and the instance is an editing unit in the game scene editor, such as an Actor. The component is the smallest editing unit in the game scene editor.
[0066] In step S4, the computer device runs the instance through the game engine. During this process, the computer device calls the plug-in system's runnable processing function through the game scene editor, thereby converting the edit-time parameters of the components constituting the instance into runtime parameters and synchronizing them to the game engine, so that the game engine can run (render) the instance based on the components and the converted runtime parameters.
[0067] By converting component editing parameters into runtime parameters through the game scene editor, the data processing logic for parameter conversion is implemented within the game scene editor, thus placing all editor-related data processing logic on the editor side. The game engine does not need to consider the data processing logic of instances in the game scene editor during runtime, decoupling the data processing logic between the game engine and the game scene editor. This results in a lighter and cleaner overall processing logic and a more streamlined overall runtime architecture, eliminating the need to maintain data processing logic within the game engine and reducing the complexity of maintaining such logic.
[0068] Figure 3 This is a flowchart illustrating the operation method of an example provided in an exemplary embodiment of this application. This method can be used in a computer device. Figure 3 As shown, the method includes:
[0069] Step 302: Obtain the components that make up the instance.
[0070] This component is built on the ECS architecture and refers to a Component within the ECS architecture. This instance is an editing unit in the game scene editor, such as the smallest unit within the game scene editor. For example, this instance includes virtual characters and objects that make up the virtual environment of the game. This game scene editor is used to edit virtual scenes in applications based on virtual environments, such as an editor used to edit game scenes (levels) during game development.
[0071] For example, the aforementioned virtual environment-based applications may include any one of the following: First-Person Shooter (FPS) games, Third-Person Shooter (TPS) games, Multiplayer Online Battle Arena (MOBA) games, Tactical Battle Arena games, and Simulation Games (SLG).
[0072] Computer devices can access components by obtaining the component's class. This component class contains code used to define the component. Optionally, the component's class is written by the developer.
[0073] Step 304: During the instance's runtime phase, the component's runtime parameters are obtained by converting the edit-time parameters in the component through the game scene editor.
[0074] The execution phase of an instance is also known as runtime. This transformation process is determined based on the data structure of the parameters used by the game engine when running the instance. Optionally, the data structure of the edit-time parameters in the component and the parameters used by the game engine when running the instance is defined by the game developers. The edit-time parameters in the component are defined in the component's class.
[0075] Optionally, the component corresponds to a plugin system, which is built on the ECS architecture. This plugin system refers to the System within the ECS architecture and is used to process the component's data. Optionally, the plugin system includes the component's identifier, thereby establishing a correspondence between the plugin system and the component. For example, the component's identifier is a globally unique identifier (GUID). This plugin system provides the function of converting the parameters of its corresponding component. When a computer device calls the plugin system corresponding to the instance's component through the game scene editor, it can convert the editing parameters in the component to obtain the component's runtime parameters.
[0076] Step 306: Run the instance using the game engine, based on the components and runtime parameters.
[0077] When the game engine runs (renders) an instance, it uses the corresponding components of that instance along with the transformed runtime parameters described above. Optionally, these runtime parameters are synchronized to the game engine via the game scene editor.
[0078] In summary, the method provided in this embodiment converts the editing parameters of components into runtime parameters through the game scene editor, thereby implementing the data processing logic for parameter conversion within the game scene editor. This places all editor-related data processing logic on the editor side. The game engine does not need to consider the data processing logic of instances in the game scene editor during runtime, decoupling the data processing logic between the game engine and the game scene editor. This results in a lighter and cleaner overall processing logic and a more streamlined overall runtime architecture. Furthermore, it eliminates the need to maintain the data processing logic within the game engine, reducing the complexity of maintaining such logic.
[0079] Figure 4 This is a flowchart illustrating the operation method of an example provided in an exemplary embodiment of this application. This method can be used in a computer device. Figure 4 As shown, the method includes:
[0080] Step 402: Obtain the components that make up the instance.
[0081] This component is built on the ECS architecture and refers to a Component within that architecture. This instance is an editing unit in the game scene editor, such as the smallest unit within the game scene editor, or an Actor. Optionally, this instance can also be referred to as an Entity within the ECS architecture.
[0082] For example, this instance includes virtual characters and objects that make up the virtual environment of a game. This game scene editor is used to edit virtual scenes in applications based on virtual environments, such as an editor used to edit game scenes (levels) during game development.
[0083] Computer devices can access components by obtaining the component's class. This component class contains code used to define the component. Optionally, the component's class is written by the developer.
[0084] For example, Figure 5 This is a schematic diagram illustrating an example provided in an exemplary embodiment of this application. For example... Figure 5 As shown, a rectangular light source instance (QuadLightActor) consists of a TransformComponent and a rectangular light source component (QuadLightComponent).
[0085] The transformation component described above can be created through its class. For example, the code for the transformation component's class is as follows:
[0086]
[0087] The transformation component created using the above code contains some common properties of instances.
[0088] The rectangular light source component described above can be created using its class. For example, the code for the rectangular light source component class is as follows:
[0089]
[0090] The rectangular light source component created using the above code contains unique properties specific to the rectangular light source instance.
[0091] It should be noted that the number and content of the components that make up an instance are set by the developers based on the instance's properties.
[0092] Step 404: Obtain the plugin system corresponding to the component.
[0093] This plugin system is built on the ECS architecture. Specifically, it refers to a System within the ECS architecture, used to process component data. Optionally, the plugin system includes component identifiers to establish a correspondence between the plugin system and the components. For example, the component identifier is a GUID.
[0094] When a computer device needs to process data about a component, such as editing or running an instance of a component, it needs to obtain the plugin system corresponding to the component. Optionally, the computer device will obtain the class of the plugin system corresponding to the component based on the identifier of the component that makes up the instance, and then obtain the plugin system based on the class of the plugin system. The class of the plugin system includes code used to define the plugin system. Optionally, the class of the plugin system is written by the developers according to the required processing method for the component's data.
[0095] For example, the code for the plugin system class is as follows:
[0096]
[0097] The plugin system's classes include the GUIDs of its components, thereby establishing the correspondence between the plugin system's components.
[0098] Step 406: Add or remove target attributes for the instance using the plugin system.
[0099] The aforementioned components reflect the attributes of an instance, and the corresponding plugin system adds components to the instance. For example, the `addComponent()` function in the plugin system class defines this functionality. In response to the operation of adding a target attribute to an instance, the computer device adds the target component to the components that make up the instance through the plugin system, thereby adding the target attribute to the instance. The target component is the component corresponding to the target attribute.
[0100] The plugin system corresponding to this component can also be used to remove components from an instance. For example, the `removeComponent()` function in the plugin system class defines this functionality. In response to the operation of removing a target property from an instance, the plugin system removes the target component from the components that make up the instance, thereby removing the target property from the instance. The target component is the component corresponding to the target property.
[0101] It should be noted that for the components of an instance, the computer device registers the corresponding components of the plugin system for the instance through a plugin system, thereby obtaining the components that make up the instance. Optionally, instances are also defined through classes. For example, the code for defining an instance class is as follows:
[0102]
[0103] The code above demonstrates that an instance (EntityActor) can be defined as being composed of components.
[0104] Computer devices can use a plug-in system to add or remove components corresponding to a specific plug-in system from an existing instance. For example, the code for registering (adding) a component to an instance is as follows:
[0105] EntityActor actor;
[0106] …
[0107] int id=QuadLightSystem:getlnstance()->addComponent(guid,pose);
[0108] actor.m_component_map.insert(std::make_pair(QuadLightSystem::getlnstance(),id));
[0109] The above code allows you to register the corresponding component of the plugin system QuadLightSystem for the instance EntityActor. This enables you to add the components TransformComponent and QuadLightComponent to the instance EntityActor through the plugin system QuadLightSystem, thus obtaining an instance EntityActor composed of components.
[0110] For example, Figure 6 This is a schematic diagram of the components of an exemplary embodiment provided in this application. For example... Figure 6 As shown in (a), in OOP mode, when defining an instance, its corresponding properties need to be written. For example, instance 2 includes camera field, effect field, light field, and sound field. When it is necessary to modify the properties of an instance, the corresponding code of the instance needs to be modified, which is a relatively complicated process and it is not possible to dynamically add or remove properties from an instance.
[0111] like Figure 6 As shown in (b), Instance 1 and Instance 2 are composed of components. When it is necessary to remove an instance's attribute, such as an attribute corresponding to component A, this can be achieved through the plugin system A corresponding to component A. Similarly, to add an instance's attribute, this can also be achieved through the plugin system A corresponding to component A.
[0112] Step 408: During the instance's runtime phase, the plugin system is invoked through the game scene editor to convert the editing parameters in the component, thereby obtaining the component's runtime parameters.
[0113] The execution phase of an instance can also be called runtime. This transformation process is determined based on the data structure of the parameters used by the game engine when running the instance. Optionally, the data structures of the edit-time parameters in the component and the parameters used by the game engine when running the instance are defined by the game developers. The edit-time parameters in the component are defined in the component's class. This plugin system can also provide parameter transformation functionality for its corresponding components; for example, the `void tick()` function in the plugin system's class defines this functionality.
[0114] For example, the following code defines the data structure for the runtime parameters of an instance QuadLightActor when it runs in the game engine:
[0115]
[0116] Optionally, the plugin system's function to convert parameters for its corresponding components is implemented through a processing function. This processing function, such as the `tick` function, is defined within the plugin system. By calling this processing function through the game scene editor, the editing parameters within the component can be converted, thus obtaining the component's runtime parameters.
[0117] For example, the tick function (tick logic) of the plugin system can be implemented using the following code:
[0118]
[0119]
[0120] The data structure transformation section in the code above defines the parameter transformation process.
[0121] The parameter conversion process described above involves using the game scene editor to convert the edit-time parameters in the component to obtain the component's runtime parameters, based on the logical mapping relationship between edit-time parameters and runtime parameters. This logical mapping relationship is determined by the edit-time parameters and the data structure of the game engine's runtime instance. It should be noted that the edit-time parameters and corresponding runtime parameters may differ for different components; this logical mapping relationship is determined by the developers based on the specific edit-time parameters and corresponding runtime parameters. Optionally, this logical mapping relationship is defined and implemented through code.
[0122] Step 410: Run the instance using the game engine, based on the components and runtime parameters.
[0123] When the game engine runs (renders) an instance, it uses the corresponding components of that instance along with the transformed runtime parameters described above. Optionally, these runtime parameters are synchronized to the game engine via the game scene editor.
[0124] Additionally, after creating an instance, it will be as follows: Figure 1 The game scene editor panel displays the icon of the created instance. At this time, the game scene editor displays the instance's icon and the virtual environment it is editing. In response to a drag-and-drop operation where the instance's icon is dragged from the game scene editor to the virtual environment, the computer device displays the instance in that virtual environment via the game scene editor.
[0125] For example, Figure 7 This is a schematic diagram of a virtual environment provided in an exemplary embodiment of this application. For example... Figure 7 As shown, after receiving a drag operation that drags the icon of a rectangular light source instance to the virtual environment 701 displayed in the game scene editor, the computer device will display the rectangular light source instance 702 in the virtual environment 701 through the game scene editor.
[0126] Optionally, the game scene editor will also display the edit-time parameters of the instance's components in the editing panel. For example, Figure 8 This is a schematic diagram of editing parameters provided in an exemplary embodiment of this application. For example... Figure 8As shown, the editing panel displays the parameters of the general properties provided by the TransformComponent component and the parameters of the unique properties provided by the QuadLightComponent component. The editing panel allows you to edit the parameters provided by both the TransformComponent and QuadLightComponent components. All of these parameters are for editing purposes.
[0127] It should be noted that the method provided in the embodiments of this application can provide the following effects:
[0128] (1) Improve scalability
[0129] Scalability is a design concept that, based on the architecture or design of related technologies, allows for adaptation to changes in certain aspects of an instance with minimal modifications, as provided in this embodiment. This process requires minimal code changes and exhibits good adaptability to instance changes, thus demonstrating good scalability. This design can also accommodate uncertain future changes to components.
[0130] The method provided in this embodiment enables the separation of technical data and operations. The Component stores only data, and the System stores only operations of the same type of Component. If a new type of Actor needs to be added, only the Component and System need to be added; the existing Actors do not need to be modified. That is, when requirements change, the code does not need to be rewritten. Modifications to local code will not cause large-scale changes. New functions and modules can be easily introduced.
[0131] (2) Separation of editor and engine runtime logic
[0132] Because editing instances requires a user-friendly interface, it necessitates providing editing parameters that are more intuitive and easier to understand. Meanwhile, game engines prioritize computational performance and memory access speed during runtime, requiring more efficient data structures. Therefore, the parameters used during editing need to be transformed into runtime-usable data.
[0133] The method provided in this embodiment encapsulates the runtime system using ECS. Component provides user-friendly editing parameters, and System translates and synchronizes Component to runtime data structures. This allows all data processing logic related to the game scene editor to be placed on the game scene editor side. The game engine does not need to consider editor-related logic during runtime, resulting in a lighter and cleaner overall logic and a more streamlined architecture.
[0134] In summary, the method provided in this embodiment converts the editing parameters of components into runtime parameters through the game scene editor, thereby implementing the data processing logic for parameter conversion within the game scene editor. This places all editor-related data processing logic on the editor side. The game engine does not need to consider the data processing logic of instances in the game scene editor during runtime, decoupling the data processing logic between the game engine and the game scene editor. This results in a lighter and cleaner overall processing logic and a more streamlined overall runtime architecture. Furthermore, it eliminates the need to maintain the data processing logic within the game engine, reducing the complexity of maintaining such logic.
[0135] Furthermore, by using components within the ECS architecture to construct instances, attributes can be dynamically added or removed to instances without modifying the instance's code. And because the attributes provided by components are stored contiguously in memory, performance is improved.
[0136] Figure 9 This is a flowchart illustrating an example of an editing method provided in an exemplary embodiment of this application. The method can be used in a computer device. Figure 9 As shown, the method includes:
[0137] Step 902: Obtain the components from the game scene editor.
[0138] This component is built on the ECS architecture; it refers to a Component within the ECS architecture. Computer devices can access the component by obtaining its class. This component class contains the code used to define the component. Optionally, the component class is written by the developers.
[0139] This component can be loaded by the game scene editor, and can be considered as being defined within the game scene editor. The game scene editor is used to edit virtual scenes within virtual environment-based applications, such as an editor used to edit game scenes (levels) during game development.
[0140] Step 904: In response to the registration operation, register the components for the instance to obtain the components that make up the instance.
[0141] This instance is an editing unit within the game scene editor, such as the smallest unit in the game scene editor. For example, this instance includes virtual characters and objects that make up the virtual environment within the game. Components registered by computer devices within the instance are the components that make up the instance. The process of registering components is triggered by a registration operation on the instance, which can be performed by the user within the game scene editor; that is, the registration operation is triggered within the game scene editor.
[0142] During instance initialization, the computer device needs to register the components that make up the instance, enabling the instance to possess the corresponding attributes or functions of the components. Optionally, this component corresponds to a plugin system, which is built on the ECS architecture. This plugin system refers to the System within the ECS architecture, and it is used to process the component's data. Optionally, the plugin system includes a component identifier, which establishes the correspondence between the plugin system and the component.
[0143] When a computer device needs to process component data, such as registering a component for an instance, editing an instance of a component, or running an instance of a component, it needs to obtain the plugin system corresponding to the component. Optionally, the computer device will obtain the class of the plugin system corresponding to the component based on the identifier of the component that makes up the instance, and then obtain the plugin system based on the class of the plugin system. The class of the plugin system includes code used to define the plugin system. Optionally, the class of the plugin system is written by developers according to the required processing method for the component's data. When registering a component for an instance, the computer device will register the component for the instance through the plugin system corresponding to the component, thereby obtaining the component that makes up the instance.
[0144] Step 906: In response to the edit operation on the instance, add or delete components in the components that make up the instance.
[0145] This editing operation is a user-initiated action to modify an instance, such as adding or deleting attributes for a component. This editing operation can be performed in the game scene editor; that is, the editing operation is triggered within the game scene editor. Optionally, the component reflects the instance's attributes, and the corresponding plugin system is used to add or remove components from the instance.
[0146] In response to the operation of adding a target attribute to an instance, the computer device adds a target component to the components that make up the instance through a plug-in system, thereby adding the target attribute to the instance. The target component is the component corresponding to the target attribute.
[0147] In response to an operation that removes a target attribute from an instance, the computer device removes the target component from the components that make up the instance through a plug-in system, thereby removing the target attribute from the instance. The target component is the component corresponding to the target attribute.
[0148] It should be noted that during the instance's runtime phase, computer devices can, for example, Figure 3 or Figure 4 The method shown converts the runtime parameters of the instance's components using a game scene editor to obtain the component's runtime parameters. Then, the game engine runs the instance based on the components and runtime parameters. The specific process can be found in the foregoing embodiments, and will not be repeated here.
[0149] In summary, the method provided in this embodiment, by using components under the ECS architecture to construct instances, enables instance editing by adding or removing components without modifying the instance's code, thus improving the efficiency of instance editing. Furthermore, because the components are stored contiguously in memory, performance is improved.
[0150] Figure 10 This is a flowchart illustrating an example of an editing method provided in an exemplary embodiment of this application. The method can be used in a computer device. Figure 10 As shown, the method includes:
[0151] Step 1002: Obtain the components from the game scene editor.
[0152] This component is built on the ECS architecture and refers to a Component within the ECS architecture. Computer devices can access the component by obtaining its class. This component can be loaded by the game scene editor, which is used during game development to edit game scenes (levels).
[0153] Step 1004: Register the components corresponding to the plugin system for the instance through the plugin system to obtain the components that make up the instance.
[0154] This instance is an editing unit in the game scene editor, such as the smallest unit in the game scene editor. For example, this instance includes virtual characters and objects that make up the virtual environment in the game. When initializing an instance, the computer device needs to register the components that make up the instance, so that the instance can have corresponding attributes or functions. Optionally, the components correspond to a plugin system, which is built on the ECS architecture. This plugin system refers to the System under the ECS architecture, and it is used to process the component's data. Optionally, the plugin system includes a component identifier, which establishes the correspondence between the plugin system and the component.
[0155] When a computer device needs to register components for an instance, it needs to obtain the plugin system corresponding to the component. Optionally, the computer device will obtain the class of the plugin system corresponding to the component based on the identifier of the component that makes up the instance, and then obtain the plugin system based on the class of the plugin system. When registering components for an instance, the computer device will register the components for the instance through the plugin system corresponding to the component, thereby obtaining the components that make up the instance.
[0156] For example, continue to refer to Figure 5Computer devices can provide corresponding properties (functions) to a rectangular light source instance (QuadLightActor) by registering a TransformComponent and a QuadLightComponent with the QuadLightActor.
[0157] Step 1006: In response to the operation of adding a target attribute to an instance, add the target component to the components that make up the instance through the plugin system.
[0158] Adding a target attribute to an instance is a user-defined editing operation. The components that make up an instance reflect its attributes, and each component can provide one attribute for the instance. The target component is the component corresponding to the target attribute. Computer devices add target components to instances through a plug-in system corresponding to the target component, thus enabling the addition of target attributes to instances.
[0159] Step 1008: In response to the operation of removing the target property from the instance, remove the target component from the components that make up the instance through the plugin system.
[0160] Adding a target attribute to an instance is a user-defined editing operation. The components that make up an instance reflect its attributes, with each component providing one attribute. The target component is the component corresponding to the target attribute. Computer devices can remove (delete) the target attribute from an instance by using a plug-in system corresponding to the target component.
[0161] For example, continue to refer to Figure 6 (b) When the computer device receives an operation to remove the attribute provided by component A for instance 1, the computer device will remove component A from the components that make up instance 1 through plug-in system A, thereby deleting the attribute provided by component A for instance 1.
[0162] It should be noted that during the instance's runtime phase, computer devices can, for example, Figure 3 or Figure 4 The method shown converts the runtime parameters of the instance's components using a game scene editor to obtain the component's runtime parameters. Then, the game engine runs the instance based on the components and runtime parameters. The specific process can be found in the foregoing embodiments, and will not be repeated here.
[0163] In summary, the method provided in this embodiment, by using components under the ECS architecture to construct instances, can dynamically add or remove attributes for instances without modifying the instance's code, thus improving the efficiency of instance editing. Furthermore, since the attributes provided by the components are stored contiguously in memory, performance is improved.
[0164] It should be noted that the order of the method steps provided in the embodiments of this application can be appropriately adjusted, and the steps can also be added or removed as appropriate. Any method variations that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the protection scope of this application, and therefore will not be elaborated further.
[0165] Figure 11 This is a schematic diagram of the structure of an operating apparatus provided in an exemplary embodiment of this application. This apparatus can be used in a computer device. Figure 11 As shown, the device includes:
[0166] The acquisition module 1101 is used to acquire the components that make up the instance. The components are built based on the ECS architecture. The instance is an editing unit in the game scene editor. The game scene editor is used to edit virtual scenes in a virtual environment-based application.
[0167] The conversion module 1102 is used to convert the editing parameters in the component to obtain the running parameters of the component through the game scene editor during the running phase of the instance. The conversion process is determined according to the data structure of the parameters used by the game engine when running the instance.
[0168] The runtime module 1103 is used to run the instance based on the components and runtime parameters through the game engine.
[0169] In an optional design, the conversion module 1102 is used for:
[0170] Based on the logical mapping relationship between the editing parameters and the running parameters, the running parameters of the component are obtained by converting the editing parameters in the component through the game scene editor;
[0171] The logical mapping relationship is determined based on the editing parameters and the data structure.
[0172] In an optional design, the conversion module 1102 is used for:
[0173] The game scene editor calls the plugin system to convert the editing parameters in the component, thereby obtaining the component's runtime parameters;
[0174] The plug-in system is used to process the data of the components, and the plug-in system is built on the ECS architecture.
[0175] In an optional design, the plug-in system defines processing functions; the conversion module 1102 is used for:
[0176] The game scene editor calls the plugin system to run the processing function, which converts the editing parameters in the component to obtain the component's running parameters.
[0177] In an optional design, such as Figure 12 As shown, the device further includes:
[0178] The registration module 1104 is used to register the components corresponding to the plugin system for the instance through the plugin system, so as to obtain the components that make up the instance.
[0179] In an optional design, the acquisition module 1101 is used for:
[0180] Based on the identifiers of the components that make up the instance, obtain the class of the plugin system corresponding to the component;
[0181] The plugin system is obtained based on its class.
[0182] In an optional design, the game scene editor displays the instance's icon and the virtual environment; such as Figure 13 As shown, the device further includes:
[0183] Display module 1105 is configured to display the instance in the virtual environment in response to a drag operation in the game scene editor where the icon of the instance is dragged to the virtual environment.
[0184] Figure 14 This is a schematic diagram of the structure of an editing apparatus provided in an exemplary embodiment of this application. This apparatus can be used in a computer device. Figure 14 As shown, the device includes:
[0185] The acquisition module 1401 is used to acquire components in the game scene editor, the components being built on the ECS architecture, and the game scene editor being used to edit virtual scenes in a virtual environment-based application;
[0186] Registration module 1402 is used to register the components for the instance in response to the registration operation, thereby obtaining the components that make up the instance, wherein the instance is an editing unit in the game scene editor, and the registration operation is triggered in the game scene editor;
[0187] The editing module 1403 is configured to add or delete components among the components constituting the instance in response to an editing operation on the instance, the editing operation being triggered in the game scene editor.
[0188] In an optional design, the components constituting the instance are used to reflect the attributes of the instance; the editing module 1403 is used to:
[0189] In response to the operation of adding a target attribute to the instance, the target component is added to the components that make up the instance through the plugin system;
[0190] The target component is the component corresponding to the target attribute, and the plug-in system is used to process the data of the target component. The plug-in system is built on the ECS architecture.
[0191] In an optional design, the components constituting the instance are used to reflect the attributes of the instance; the editing module 1403 is used to:
[0192] In response to the operation of removing the target attribute for the instance, the target component is removed from the components that make up the instance through the plugin system;
[0193] The target component is the component corresponding to the target attribute, and the plug-in system is used to process the data of the target component. The plug-in system is built on the ECS architecture.
[0194] In an optional design, the acquisition module 1401 is used for:
[0195] Based on the identifier of the target component, obtain the class of the plugin system corresponding to the target component;
[0196] The plugin system is obtained based on its class.
[0197] In an optional design, the registration module 1402 is used for:
[0198] By registering the components corresponding to the plugin system for the instance through the plugin system, the components that make up the instance are obtained;
[0199] The plug-in system is used to process data of the components corresponding to the plug-in system, and the plug-in system is built on the ECS architecture.
[0200] It should be noted that the operating device of the above embodiments is only an example of the division of the above functional modules. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. In addition, the operating device and the operating method of the above embodiments belong to the same concept, and the specific implementation process can be found in the method embodiments, which will not be repeated here.
[0201] Similarly, the editing device for the examples provided in the above embodiments is only illustrated by the division of the above functional modules. In practical applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. In addition, the editing device for the examples provided in the above embodiments and the editing method embodiments for the examples belong to the same concept, and the specific implementation process can be found in the method embodiments, which will not be repeated here.
[0202] Embodiments of this application also provide a computer device, which includes a processor and a memory. The memory stores at least one instruction, at least one program, code set, or instruction set. The at least one instruction, at least one program, code set, or instruction set is loaded and executed by the processor to implement the running method of the instances provided in the above-described method embodiments.
[0203] Alternatively, the computer device is a server. For example, Figure 15 This is a schematic diagram of the structure of a computer device provided in an exemplary embodiment of this application.
[0204] The computer device 1500 includes a central processing unit (CPU) 1501, a system memory 1504 including random access memory (RAM) 1502 and read-only memory (ROM) 1503, and a system bus 1505 connecting the system memory 1504 and the CPU 1501. The computer device 1500 also includes a basic input / output system (I / O system) 1506 to facilitate information transfer between various components within the computer device, and a mass storage device 1507 for storing the operating system 1513, application programs 1514, and other program modules 1515.
[0205] The basic input / output system 1506 includes a display 1508 for displaying information and an input device 1509 for user input, such as a mouse or keyboard. Both the display 1508 and the input device 1509 are connected to the central processing unit 1501 via an input / output controller 1510 connected to the system bus 1505. The basic input / output system 1506 may also include the input / output controller 1510 for receiving and processing input from multiple other devices such as a keyboard, mouse, or electronic stylus. Similarly, the input / output controller 1510 also provides output to a display screen, printer, or other types of output devices.
[0206] The mass storage device 1507 is connected to the central processing unit 1501 via a mass storage controller (not shown) connected to the system bus 1505. The mass storage device 1507 and its associated computer-readable storage media provide non-volatile storage for the computer device 1500. That is, the mass storage device 1507 may include computer-readable storage media (not shown), such as a hard disk or a compact disc read-only memory (CD-ROM) drive.
[0207] Without loss of generality, the computer-readable storage medium may include computer storage media and communication media. Computer storage media include volatile and non-volatile, removable and non-removable media implemented using any method or technology for storing information such as computer-readable storage instructions, data structures, program modules, or other data. Computer storage media include RAM, ROM, erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other solid-state storage devices, CD-ROM, digital versatile disc (DVD) or other optical storage, magnetic tape cassettes, magnetic tape, disk storage, or other magnetic storage devices. Of course, those skilled in the art will recognize that the computer storage medium is not limited to the above-mentioned types. The system memory 1504 and mass storage device 1507 described above can be collectively referred to as memory.
[0208] The memory stores one or more programs, which are configured to be executed by one or more central processing units 1501. The one or more programs contain instructions for implementing the above method embodiments, and the central processing unit 1501 executes the one or more programs to implement the methods provided by the various method embodiments described above.
[0209] According to various embodiments of this application, the computer device 1500 can also be connected to a remote computer device on a network, such as the Internet. That is, the computer device 1500 can be connected to a network 1512 via a network interface unit 1511 connected to the system bus 1505, or the network interface unit 1511 can be used to connect to other types of networks or remote computer device systems (not shown).
[0210] The memory further includes one or more programs stored in the memory, and the one or more programs include steps performed by a computer device in the methods provided in the embodiments of this application.
[0211] This application also provides a computer-readable storage medium storing at least one instruction, at least one program, code set, or instruction set. When the at least one instruction, at least one program, code set, or instruction set is loaded and executed by the processor of a computer device, the running method of the instances provided in the above-described method embodiments is implemented.
[0212] This application also provides a computer program product or computer program that includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the operating methods of the examples provided in the above-described method embodiments.
[0213] Those skilled in the art will understand that all or part of the steps of the above embodiments can be implemented by hardware or by a program instructing related hardware. The program can be stored in a computer-readable storage medium, such as a read-only memory, a disk, or an optical disk.
[0214] The above description is merely an optional embodiment of this application and is not intended to limit this application. Any modifications, equivalent switching, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.
Claims
1. A method for running an instance, characterized in that, The method includes: Obtain the components that make up the instance, the components are built on the entity component system ECS architecture, the instance is an editing unit in the game scene editor, the game scene editor is used to edit virtual scenes in a virtual environment-based application; During the runtime phase of the instance, the runtime parameters of the component are obtained by converting the editing parameters in the component through the game scene editor. The conversion process is determined based on the data structure of the parameters used by the game engine when running the instance. The instance is run using the game engine, based on the components and the running parameters, which are synchronized from the game scene editor to the game engine.
2. The method according to claim 1, characterized in that, The step of obtaining the component's runtime parameters by converting the edit-time parameters in the component through the game scene editor includes: Based on the logical mapping relationship between the editing parameters and the running parameters, the running parameters of the component are obtained by converting the editing parameters in the component through the game scene editor; The logical mapping relationship is determined based on the editing parameters and the data structure.
3. The method according to claim 1, characterized in that, The step of obtaining the component's runtime parameters by converting the edit-time parameters in the component through the game scene editor includes: The game scene editor calls the plugin system to convert the editing parameters in the component, thereby obtaining the component's running parameters; The plug-in system is used to process the data of the components, and the plug-in system is built on the ECS architecture.
4. The method according to claim 3, characterized in that, The plugin system defines processing functions; the step of calling the plugin system through the game scene editor to convert the editing parameters in the component and obtain the component's running parameters includes: The game scene editor calls the plugin system to run the processing function, which converts the editing parameters in the component to obtain the component's running parameters.
5. The method according to claim 3, characterized in that, The method further includes: By registering the components corresponding to the plugin system for the instance through the plugin system, the components that make up the instance are obtained.
6. The method according to claim 3, characterized in that, The method further includes: Based on the identifiers of the components that make up the instance, obtain the class of the plugin system corresponding to the component; The plugin system is obtained based on its class.
7. The method according to any one of claims 1 to 6, characterized in that, The game scene editor displays the icon of the instance and the virtual environment; the method further includes: In response to a drag operation in the game scene editor where the icon of the instance is dragged to the virtual environment, the instance is displayed in the virtual environment.
8. An example of an operating device, characterized in that, The device includes: The acquisition module is used to acquire the components that make up the instance. The components are built on the ECS architecture. The instance is an editing unit in the game scene editor, which is used to edit virtual scenes in a virtual environment-based application. A conversion module is used to convert the editing parameters in the component to obtain the running parameters of the component through the game scene editor during the runtime phase of the instance. The conversion process is determined according to the data structure of the parameters used by the game engine when running the instance. The runtime module is used to run the instance through the game engine, based on the components and the runtime parameters, wherein the runtime parameters are synchronized from the game scene editor to the game engine.
9. A computer device, characterized in that, The computer device includes a processor and a memory, the memory storing at least one program, which is loaded and executed by the processor to implement the running method of any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, The readable storage medium stores at least one program segment, which is loaded and executed by a processor to implement the running method of the instance as described in any one of claims 1 to 7.
11. A computer program product, characterized in that, The computer program product includes computer instructions stored in a computer-readable storage medium, a processor of a computer device reading the computer instructions from the computer-readable storage medium, and the processor executing the computer instructions to cause the computer device to perform the running method of any one of claims 1 to 7.