CN114741068A - Object access method, code generation method, device, equipment and storage medium - Google Patents

Object access method, code generation method, device, equipment and storage medium Download PDF

Info

Publication number
CN114741068A
CN114741068A CN202210365488.2A CN202210365488A CN114741068A CN 114741068 A CN114741068 A CN 114741068A CN 202210365488 A CN202210365488 A CN 202210365488A CN 114741068 A CN114741068 A CN 114741068A
Authority
CN
China
Prior art keywords
unit
identifier
target
code
lua
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210365488.2A
Other languages
Chinese (zh)
Inventor
卢鹏丹
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Netease Hangzhou Network Co Ltd
Original Assignee
Netease Hangzhou Network Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Netease Hangzhou Network Co Ltd filed Critical Netease Hangzhou Network Co Ltd
Priority to CN202210365488.2A priority Critical patent/CN114741068A/en
Publication of CN114741068A publication Critical patent/CN114741068A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/34Graphical or visual programming
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/42Syntactic analysis
    • G06F8/427Parsing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/44Encoding
    • G06F8/447Target code generation

Landscapes

  • Engineering & Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

The embodiment of the application provides an object access method, a code generation method, a device, equipment and a storage medium, when a user wants to access a particular unit object that needs to be accessed in the lua runtime environment, a parse triggering operation may be performed causing the computer device to parse the object access code in the destination lua code file, displaying an object identification selection page on the user operation interface, wherein the user can directly select the object identification of the specific unit object which the user wants to access, when the computer device determines that the object identifier corresponds to the data lookup identifier of the specific unit object, the specific unit object which is required to be accessed can be accessed according to the object identification selected by the user and the determined data searching identification, the query path of the unit object which is required to be accessed is prevented from being artificially spelled by the user in the lua running environment, and the development efficiency of the unit project is improved.

Description

Object access method, code generation method, device, equipment and storage medium
Technical Field
The present application relates to the field of computer technologies, and in particular, to an object access method, a code generation method, an apparatus, a device, and a storage medium.
Background
In the game item of the unity, there are a lot of cases of finding and caching the unity object in the lua running environment, when finding the unity object through Xlua (for realizing the interaction between the lua language and the C # language in the unity) in the lua running environment, the query path of the unity object needs to be transmitted to the lua running environment through Xlua in the form of character strings, and the developer needs to realize the logic code of the unity object through the query path of the artificial spelling unity object in the lua running environment, however, if the query path of the unity object is too long, the artificial spelling is easy to make mistakes, and the check is difficult, the development efficiency of the unity item is low.
Disclosure of Invention
The embodiment of the application provides an object access method, a code generation device, equipment and a storage medium, and can improve the development efficiency of a unity project.
An embodiment of the present application provides an object access method, including:
responding to an analysis triggering operation aiming at a target lua code file under a lua running environment, and acquiring the target lua code file, wherein the target lua code file comprises an object access code of a lua language, the object access code is generated based on a unit preset body code and comprises an object identifier and a data searching identifier of a specific unit object needing to be accessed under the lua running environment in a unit preset body, and the data searching identifier is used for acquiring object data of the specific unit object;
analyzing the object access code in the target lua code file, and displaying an object identifier selection page on a user operation interface based on an analysis result, wherein the object identifier selection page comprises the object identifier of the specific unit object;
and responding to the selection operation of the object identification in the object identification selection page, and accessing a specific unity object corresponding to the selected object identification based on the data search identification.
Correspondingly, an embodiment of the present application provides a code generation method, including:
determining a specific unit object which needs to be accessed in the lua running environment in the unit objects included in the target unit preset body;
acquiring a data search identifier of the specific unit object based on the target unit preset body, recording the data search identifier in a preset data structure to obtain object recording information, wherein the position information of the data search identifier recorded in the preset data structure is integer data;
importing the target unit preset body and the object record information into the lua operating environment;
acquiring an object access code template of a lua language under the lua operating environment, wherein the object access code template is used for accessing a unity object under the lua operating environment and comprises a plurality of code segments to be replaced related to the specific unity object;
performing code replacement in a code segment to be replaced of the object access code template based on the object identifier of the specific unit object, the data search identifier in the object record information and the object data of the target unit preset body to obtain an object access code, wherein the object access code comprises the object identifier and the data search identifier of the specific unit object;
and obtaining a target lua code file based on the object access code, wherein the target lua code file is used for displaying the object identifier of the specific unit object for a user to select after being analyzed, and searching and accessing the specific unit object corresponding to the selected object identifier based on the data identifier after selection.
Correspondingly, an embodiment of the present application further provides an object access apparatus, including:
a code file obtaining unit, configured to obtain a target Lua code file in response to a parsing trigger operation for the target Lua code file in a Lua operating environment, where the target Lua code file includes an object access code in a Lua language, the object access code is generated based on a unit preset body code and includes an object identifier and a data lookup identifier of a specific unit object that needs to be accessed in the unit preset body under the Lua operating environment, and the data lookup identifier is used to obtain object data of the specific unit object;
an identifier display unit, configured to parse the object access code in the target lua code file, and display an object identifier selection page on a user operation interface based on a parsing result, where the object identifier selection page includes an object identifier of the specific unit object;
and the access unit is used for responding to the selection operation of the object identifier in the object identifier selection page and accessing the specific unit object corresponding to the selected object identifier based on the data searching identifier.
Optionally, the object access code includes an object ontology access code and a component access code of a mount component of each specific unit object, the component access code includes an object identifier of the specific unit object and a component identifier of the mount component, and the object data includes a component identifier of the mount component and component data;
the access unit is further configured to:
responding to the selection operation of the object identification in the object identification selection page, and determining a specific unit object corresponding to the selected object identification as a target unit object for access;
displaying a component identifier selection page on the user operation interface based on the analysis result, wherein the component identifier selection page comprises a target component identifier of a target mounted component of the target unit object;
and responding to the selection operation of the target component identification in the component identification selection page, searching the identification based on the data of the target unit object, and accessing the target mounting component corresponding to the selected target component identification.
Correspondingly, an embodiment of the present application further provides a code generation apparatus, including:
the object determining unit is used for determining a specific unit object which needs to be accessed in the lua running environment in the unit objects included in the target unit preset body;
the recording unit is used for acquiring a data search identifier of the specific unit object based on the target unit preset body, recording the data search identifier in a preset data structure to obtain object recording information, wherein the position information of the data search identifier recorded in the preset data structure is integer data;
an importing unit, configured to import the target unit default and the object record information into the lua operating environment;
a code template obtaining unit, configured to obtain an object access code template in the lua language in the lua runtime environment, where the object access code template is used to access a unit object in the lua runtime environment and includes a number of code segments to be replaced associated with the specific unit object;
a replacement unit, configured to perform code replacement in a to-be-replaced code segment of the object access code template based on an object identifier of the specific unit object, the data search identifier in the object record information, and object data of the target unit preset body, to obtain an object access code, where the object access code includes the object identifier and the data search identifier of the specific unit object;
and the code file obtaining unit is used for obtaining a target lua code file based on the object access code, wherein the target lua code file is used for displaying the object identifier of the specific unit object after being analyzed so as to be selected by a user, and searching and accessing the specific unit object corresponding to the selected object identifier based on the data after being selected.
Optionally, the object determination unit is further configured to:
displaying a setting sub-page of the target unit preset body in a Unity running environment based on the code of the target unit preset body, wherein the setting sub-page comprises an object identifier of a unit object contained in the target unit preset body and an object setting area;
when the target object identifier of the unit object included in the target unit preset body is selected, in response to an access marking operation in the object setting area corresponding to the target object identifier, determining that the unit object corresponding to the target object identifier is the specific unit object that needs to be accessed in the lua operating environment.
Optionally, the object determining unit is further configured to:
when a target object identifier of a unit object contained in the target unit preset body is selected, displaying a target object setting area of the selected unit object corresponding to the target object identifier in the Unity running environment, wherein the target object setting area comprises an object attribute of the selected unit object;
and in response to the operation of adding a label to the object attribute of the selected unit object in the target object setting area, determining that the selected unit object is the specific unit object which needs to be accessed in the lua operating environment.
Optionally, the preset data structure is an array structure, and the recording unit is further configured to:
acquiring a data search identifier of the specific unit object based on the target unit preset body;
and if the number of the specific unit objects is multiple, sequentially recording the data search identification of each specific unit object into the array structure according to a preset sequence to obtain the object record information.
Optionally, the recording unit is further configured to:
mounting an access record component for the target unit default;
storing the object record information into the access record component;
the import unit is further configured to:
and in response to the object data aiming at the target unit preset body and the import operation of the access record component from the unit operation environment to the lua operation environment, importing the target unit preset body and the object record information into the lua operation environment.
Optionally, the replacing unit is further configured to:
generating target replacement code segments corresponding to the code segments to be replaced based on the object identification of the specific unit object, the data search identification in the object record information and the object data of the target unit preset body;
and replacing the corresponding code segment to be replaced in the object access code template by using each target replacing code segment to obtain the object access code.
Optionally, the to-be-replaced code segment includes an to-be-replaced identification code segment, an to-be-replaced object ontology accessing code segment, and an to-be-replaced component accessing code segment, and the replacement unit is further configured to:
acquiring a preset body identifier of the target unit preset body from the object data of the target unit preset body, and using the preset body identifier as a target replacement code segment corresponding to the identifier code segment to be replaced;
generating a code segment for querying and caching the specific unit object based on the data search identifier in the object record information and the object data of the target unit preset body, and taking the code segment as a target replacement code segment corresponding to the access code segment of the object body to be replaced;
and generating a target replacement code segment corresponding to the component access code segment to be replaced based on the target replacement code segment corresponding to the object body access code segment to be replaced and the object identifier of the specific unit object.
Optionally, the preset data structure in the object record information is an array structure, and the replacement unit is further configured to:
determining a data lookup identifier for each of the particular unit objects as a subscript recorded in the array structure;
generating a first code segment that determines a data lookup identification for the particular unit object in the array structure based on the subscript;
generating a second code segment which is used for inquiring and caching the object data of the specific unit object in the object data of the target unit preset body according to the determined data searching identification;
and merging the first code segment and the second code segment to be used as a target replacing code segment corresponding to the to-be-replaced object ontology access code segment.
Optionally, the replacing unit is further configured to:
acquiring a data search identifier of the specific unit object according to the first code segment;
acquiring a component identifier of a mounted component of the specific unit object according to the object data of the specific unit object cached by the second code segment;
and generating a target replacement code segment corresponding to the component access code segment to be replaced based on the object identifier of the specific unit object, the data search identifier and the component identifier.
Optionally, the replacing unit is further configured to:
if the number of the mounted components of the specific unit object is multiple, generating a code segment for accessing each mounted component based on the object identifier of the specific unit object, the data search identifier and the component identifier of each mounted component;
and splicing the code segments for accessing each mounting component to generate a target replacing code segment corresponding to the component access code segment to be replaced.
Optionally, the replacing unit is further configured to:
and replacing the corresponding to-be-replaced identification code segment, the to-be-replaced object body access code segment and the to-be-replaced component access code segment in the object access code template by using each target replacement code segment to obtain the object access code comprising the identification code segment, the object body access code segment and the component access code segment.
Similarly, an embodiment of the present application further provides a computer device, including:
a memory for storing a computer program;
a processor for performing the steps of any one of the object access method and the code generation method.
Furthermore, an embodiment of the present application also provides a computer-readable storage medium, on which a computer program is stored, and the computer program, when executed by a processor, implements the steps of any one of the object access method and the code generation method.
The embodiment of the application provides an object access method, a code generation method, a device, an apparatus and a storage medium, when a user wants to access a specific unit object to be accessed in a lua operating environment, an analysis trigger operation can be executed to enable a computer device to analyze an object access code in a target lua code file, an object identification selection page comprising an object identification of the specific unit object is displayed on a user operation interface, the user can directly select the object identification of the specific unit object to be accessed at this time in the object identification selection page, after the computer device determines a data search identification of the specific unit object corresponding to the object identification, the computer device can access the specific unit object to be accessed according to the object identification selected by the user and the determined data search identification, and the query path of the user for artificially spelling the unit object to be accessed in the lua operating environment is avoided, therefore, errors of the query path of the unit object artificially spelled in the lua running environment are avoided, and the development efficiency of the unit project is improved.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings to be recalled in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings without creative efforts.
Fig. 1 is a system diagram of an object access device provided in an embodiment of the present application;
fig. 2 is a schematic flowchart of an object access method provided in an embodiment of the present application;
FIG. 3 is a schematic diagram of an object identifier selection page provided in an embodiment of the present application;
FIG. 4 is a schematic diagram of a component identifier selection page provided by an embodiment of the present application;
FIG. 5 is a flowchart illustrating a method for generating code according to an embodiment of the present application;
FIG. 6 is a schematic diagram of a setup sub-page provided by an embodiment of the present application;
FIG. 7 is a schematic diagram of an array join provided in an embodiment of the present application;
FIG. 8 is a schematic diagram of an alternative process provided by an embodiment of the present application;
FIG. 9 is a template code diagram of a to-be-replaced component access code segment according to an embodiment of the present application;
fig. 10 is a schematic structural diagram of an object access device provided in an embodiment of the present application;
FIG. 11 is a schematic structural diagram of a code generation apparatus provided in an embodiment of the present application;
fig. 12 is a schematic structural diagram of a computer device provided in an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application. It should be apparent that the described embodiments are only some embodiments of the present invention, and not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The embodiment of the application provides an object access method, a code generation device, equipment and a storage medium. Specifically, the object accessing party and the code generating method according to the embodiment of the present application may be executed by a computer device, where the computer device may 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 machine, a Personal Computer (PC), a Personal Digital Assistant (PDA), and the like, and the terminal can also include a client, which can be a game application client, a front-end browser client carrying a game program, or an instant messaging client, and the like. The server may be an independent physical server, a server cluster or a distributed system formed by a plurality of physical servers, or a cloud server providing basic cloud computing services such as cloud service, a cloud database, cloud computing, a cloud function, cloud storage, network service, cloud communication, middleware service, domain name service, security service, content distribution network service, big data and an artificial intelligence platform.
For example, when the object access method is executed in the terminal, the terminal device stores a lua code writing application program that generates a lua execution environment and is used to present a scene in the user operation interface. The terminal device is used for interacting with a user through the user operation interface, so that the user can write codes in the user operation interface, for example, the Lua code writing application program (for example, AndroLua, Qlua, Lua editor and the like) is downloaded and installed through the terminal device and is run. The manner in which the terminal device provides the user operation interface to the user may include various manners, for example, the user operation interface may be rendered and displayed on a display screen of the terminal device, or the user operation interface may be presented through holographic projection. For example, the terminal device may include a touch display screen for presenting a user operation interface including a code writing interface and receiving an operation instruction generated by a user acting on the user operation interface, and a processor for running a lua code writing application, generating the user operation interface, responding to the operation instruction, and controlling display of the user operation interface on the touch display screen.
For example, when the code generation method is executed in the terminal, the terminal device stores a Lua code writing application (e.g., AndroLua, Qlua, Lua editor, etc.) that generates a Lua execution environment and a code writing application (e.g., unity, Microsoft Visual Studio, etc.) that generates a unity execution environment, and presents a scene in the user operation interface. The terminal device is used for interacting with a user through the user operation interface, so that the user can write codes in the user operation interface, for example, the lua code writing application program is downloaded and installed through the terminal device and runs. The manner in which the terminal device provides the user operation interface to the user may include various manners, for example, the user operation interface may be rendered and displayed on a display screen of the terminal device, or the user operation interface may be presented through holographic projection. For example, the terminal device may include a touch display screen for presenting a user operation interface including a code writing interface and receiving an operation instruction generated by a user acting on the user operation interface, and a processor for executing a lua code writing application, generating the user operation interface, responding to the operation instruction, and controlling display of the user operation interface on the touch display screen.
Referring to fig. 1, fig. 1 is a system diagram of an object access device according to an embodiment of the present disclosure. The system may include at least one terminal. The terminal is used for responding to the analysis triggering operation aiming at the target lua code file in the lua running environment, and acquiring the target lua code file, wherein the target lua code file comprises an object access code of the lua language, the object access code is generated based on a unit preset body code and comprises an object identifier and a data searching identifier of a specific unit object needing to be accessed in the unit preset body under the lua running environment, and the data searching identifier is used for acquiring object data of the specific unit object; analyzing the object access code in the target lua code file, and displaying an object identification selection page on a user operation interface based on an analysis result, wherein the object identification selection page comprises an object identification of a specific unity object; and in response to the selection operation of the object identification in the object identification selection page, accessing the specific unit object corresponding to the selected object identification based on the data search identification.
The following are detailed below. It should be noted that the following description of the embodiments is not intended to limit the preferred order of the embodiments.
The present embodiment will be described from the perspective of an object access device, which may be specifically integrated in a terminal device, where the terminal device may include a smart phone, a notebook computer, a tablet computer, a personal computer, and other devices.
An object access method provided in an embodiment of the present application may be executed by a processor of a terminal, as shown in fig. 2, a specific flow of the object access method mainly includes steps 201 to 203, which are described in detail as follows:
step 201, responding to an analysis triggering operation aiming at the target lua code file in the lua running environment, and acquiring the target lua code file, wherein the target lua code file comprises an object access code of the lua language, the object access code is generated based on a unit preset body code and comprises an object identifier and a data search identifier of a specific unit object needing to be accessed in the unit preset body under the lua running environment, and the data search identifier is used for acquiring object data of the specific unit object.
In the embodiment of the present application, the specific unit object is a unit object that needs to be accessed by the user in the lua runtime environment among the objects created in the unit runtime environment, where the unit object is a basic object in the unit runtime environment, and represents anything that may exist in the game scene, such as a character, a prop, a scene, and the like in the game scene.
In the embodiment of the present application, the unit preset body is a unit object that can be repeatedly used in a game scene, the unit preset body may be one unit object, such as a wall model, a tree model, and the like, or the unit preset body may be formed by combining a plurality of associated unit objects, such as a building model composed of a multi-wall model, a roof model, a window model, a door model, and the like. When the unit preset body is composed of a plurality of associated unit objects, the plurality of associated unit objects may be tree-structured units, that is, the unit preset body is a root node, the associated unit objects are child nodes corresponding to the root node, for example, a building model is the root node, and a wall model, a roof model, a window model, a door model, etc. are child nodes included in the root node. In addition, the unit preset body and the unit object can be obtained by writing codes in the unit running environment.
In the embodiment of the present application, the object access code is a code for accessing the unity object in the Lua runtime environment, and since the object access code is used in the Lua runtime environment, the object access code may be a code belonging to the Lua language.
In the embodiment of the present application, when a user wants to access a specific unit object that needs to be accessed in an lua operating environment, a parsing trigger operation may be performed on a target lua code file storing an object access code, so as to trigger a terminal to parse the object access code in the target lua code file. Furthermore, the parsing trigger operation is not limited, and may be flexibly set according to the actual situation, for example, a character that triggers the terminal to parse the target lua code file may be input in the user operation interface of the lua runtime environment, that is, if the target lua code file is an ExampleWrap file, the parsing trigger operation of the user may be to input local uiwrap ═ require (' ui.
Step 202, analyzing the object access code in the target lua code file, and displaying an object identifier selection page on the user operation interface based on the analysis result, wherein the object identifier selection page comprises the object identifier of the specific unity object.
In the embodiment of the application, the object access code is a code which can access a specific unit object, and the object access code is analyzed to display an object identification selection page on the user operation interface, so that the user is provided with code completion and prompt information when the unit object is accessed. For example, as shown in the schematic diagram of the object identifier selection page in fig. 3, when the user inputs local uiwrap ═ require ('ui.examplewrap'). nue (rootgo), the terminal then generates the object identifier selection page 301 in the form of a list by parsing the object access code in the ExampleWrap file, and the object identifier selection page 301 displays the object identifiers of different specific units.
Step 203, responding to the selection operation of the object identifier in the object identifier selection page, and accessing the specific unity object corresponding to the selected object identifier based on the data search identifier.
In this embodiment of the application, the user may select an object identifier of a unit object that the user wants to access in the object selection page, and specifically, the selection operation may be to click on the object identifier that the user wants to select. After the object identifier is selected, the data search identifier corresponding to the selected object identifier can be determined, so that the object data which is required to access the specific unit object is obtained according to the determined data search identifier, and the access to the selected specific unit object is realized.
In the embodiment of the application, the specific unit object comprises a mounting component, the mounting component defines the behavior of the corresponding specific unit object, the mounting component comprises self-contained components of the unit, such as a light source, a model, animation and the like, and a developer adds a self-defined component through C # code.
In this embodiment of the application, accessing a specific unit object may be accessing a mount component of the specific unit object, that is, the object access code may include an object ontology access code and a component access code of the mount component of each specific unit object, the component access code includes an object identifier of the specific unit object and a component identifier of the mount component, and the object data includes a component identifier of the mount component and component data, where the object ontology access code may be a code for querying and caching object data of the specific unit object, and the component access code is used to access the mount component of the specific unit object.
Specifically, when accessing the mounted component of the specific unit object, the step 203 "responding to the selection operation of the object identifier in the object identifier selection page, accessing the specific unit object corresponding to the selected object identifier based on the data lookup identifier" may be:
responding to the selection operation of the object identification in the object identification selection page, determining a specific unit object corresponding to the selected object identification as a target unit object for access;
displaying a component identifier selection page on the user operation interface based on the analysis result, wherein the component identifier selection page comprises a target component identifier of a target mounting component of the target unit object;
and responding to the selection operation of the target component identification in the component identification selection page, searching the identification based on the data of the target unit object, and accessing the target mounting component corresponding to the selected target component identification.
For example, as shown in the component identifier selection page diagram shown in fig. 4, after the user selects the object identifier of the target unit object to be accessed in the object identifier selection page, the component identifier selection page 401 may be generated in a form of a list, the target component identifier of the mount component corresponding to the target unit object is displayed in the component identifier selection page 401 so that the user can select the specific target mount component to be accessed, the object data of the target unit object may be obtained by searching for the identifier according to the data of the target unit object, and the component data corresponding to the selected target component identifier is obtained in the object data of the target unit object.
All the above technical solutions can be combined arbitrarily to form the optional embodiments of the present application, and are not described herein again.
According to the object access method provided by the embodiment of the application, when a user wants to access a specific unit object to be accessed in a lua operating environment, an analysis trigger operation can be executed to enable the computer device to analyze an object access code in a target lua code file, an object identification selection page including an object identification of the specific unit object is displayed on a user operation interface, the user can directly select the object identification of the specific unit object to be accessed at this time in the object identification selection page, after the computer device determines a data search identification of the specific unit object corresponding to the object identification, the computer device can access the specific unit object to be accessed according to the object identification selected by the user and the determined data search identification, the user is prevented from artificially spelling an inquiry path of the unit object to be accessed in the lua operating environment, and therefore, an error of the inquiry path of the artificially spelling unit object in the lua operating environment is avoided, the development efficiency of the unity project is improved.
The embodiment will be described from the perspective of a code generation apparatus, which may be specifically integrated in a terminal device, which may include a smartphone, a notebook computer, a tablet computer, a personal computer, and the like.
A code generation method provided in an embodiment of the present application is configured to generate an object access code used in the object access method, and the method may be executed by a processor of a terminal, as shown in fig. 5, a specific flow of the code generation method mainly includes steps 501 to 506, which are described in detail as follows:
step 501, determining a specific unit object which needs to be accessed in the lua operating environment in the unit objects included in the target unit preset body.
In this embodiment of the present application, in order to generate an object access code that can access a specific unit object, it is necessary to determine in advance which unit objects belong to the specific unit object that needs to be accessed in a target unit preset generated in a unit runtime environment. Specifically, the specific unit object may be determined according to a visualization operation of the user in the unit runtime environment, and in the step 501, "determining the unit object included in the target unit preset body, the specific unit object that needs to be accessed in the lua runtime environment" may be:
displaying a setting sub-page of the target unit preset body under a unit operation environment based on the code of the target unit preset body, wherein the setting sub-page comprises an object identifier of a unit object contained in the target unit preset body and an object setting area;
when the target object identifier of the unit object contained in the target unit preset body is selected, in response to an access flag operation in an object setting area corresponding to the target object identifier, it is determined that the unit object corresponding to the target object identifier is a specific unit object that needs to be accessed in the lua operating environment.
In this embodiment, after the code of the target unit preset body is written, a setting sub-page of the target unit preset body may be displayed in the unit runtime environment, for example, as shown in the schematic diagram of the setting sub-page in fig. 6, the setting sub-page 60 may include an object identifier display area 601 and an object setting area 602, the preset body identifier exemplar of the target unit preset body and the object identifiers (close _ btn, detail, etc.) of the unit objects included therein are displayed in the object identifier display area 601, and when one selected object is identified as the unit object of close _ btn in the object identifier display area 601, the object setting area 602 of the unit object identified as close _ btn is displayed, so that an access flag operation may be performed in the object setting area 602.
In this embodiment of the application, the access flag operation may be an operation of adding a tag in an object setting area, and specifically, the step "after a target object identifier of a unit object included in the target unit preset body is selected, in response to the access flag operation in the object setting area corresponding to the target object identifier, determining that the unit object corresponding to the target object identifier is a specific unit object that needs to be accessed in the lua runtime environment" may be:
when a target object identifier of a unit object contained in a preset target unit is selected, displaying a target object setting area of the selected unit object corresponding to the target object identifier under a unit operation environment, wherein the target object setting area comprises an object attribute of the selected unit object;
and determining the selected unit object as the specific unit object which needs to be accessed under the lua operating environment in response to the operation of adding the label to the object attribute of the selected unit object in the target object setting area.
For example, as shown in the setup sub-page diagram of fig. 6, the object property Layer is included in the object setup area 602 of the unit object whose object is identified as close _ btn, and the LuaWrap tag is added to the object property Layer, so as to determine that the unit object whose object is identified as close _ btn is a specific unit object that needs to be accessed in the lua runtime environment.
Step 502, obtaining a data search identifier of a specific unit object based on a target unit preset body, recording the data search identifier in a preset data structure to obtain object record information, wherein the position information of the data search identifier recorded in the preset data structure is integer data.
In this embodiment of the application, after the specific unit object is determined, the data search identifier of the specific unit object may be obtained from the object data of the target unit preset body to which the specific unit object belongs, and the data search identifier of each specific unit object may be recorded. In order to avoid acquiring the data search identifier of the unit object in the lua operating environment in the form of a character string, thereby avoiding frequent memory recovery of the system caused by the transmission of the character string from the unit operating environment to the lua operating environment, the position information of the data search identifier recorded in the preset data structure may be set as integer data, thereby acquiring the data search identifier in the lua operating environment in the integer manner.
Specifically, since the subscript of the array is integer, the preset data structure may be an array structure, and the subscript is used to identify the location information of the data lookup identifier in the array structure. At this time, in the step 502, "obtaining the data search identifier of the specific unit object based on the target unit preset body, and recording the data search identifier in the preset data structure to obtain the object record information" may be:
acquiring a data searching identifier of a specific unit object based on a target unit preset body;
and if the number of the specific unit objects is multiple, sequentially recording the data search identification of each specific unit object into an array structure according to a preset sequence to obtain object record information.
In this embodiment of the application, the preset order may be a sequence in which each unit object is determined to be a specific unit object, that is, data search information corresponding to the unit object that is preferentially determined to be the specific unit object is preferentially added to the array structure.
Step 503, importing the target unit default and the object record information into the lua operating environment.
In this embodiment of the present application, after the step "obtaining the data search identifier of the specific unit object based on the target unit preset body, and recording the data search identifier in the preset data structure to obtain the object record information", the method further includes: mounting an access record component for a target unit presetting body; storing the object record information into an access record component; at this time, the step 503 of "importing the target unit default and the object record information into the lua runtime environment" may be: and in response to the import operation of the object data and the access record component aiming at the target unit preset body from the unit running environment to the lua running environment, importing the target unit preset body and the object record information into the lua running environment.
In an embodiment of the application, the mounting of the access record component for the target unit entity may be that the terminal automatically mounts the access record component for the target unit entity in response to a code generation trigger operation in the unit runtime environment. That is, the terminal traverses each unit object of the target unit preset body, records the data lookup identifier of the unit object with the attribute Layer as LuaWrap in the preset data structure, and forms object record information, for example, as shown in fig. 7. Storing the object record information to an access record component. In addition, the access log component can be persisted with the target unit preset.
In this embodiment of the present application, the import operation is not limited, and may be that a user manually imports a file storing object data of a target unit preset volume and a file storing an access record component into the lua runtime environment.
Step 504, an object access code template of the lua language is obtained in the lua operating environment, the object access code template is used for accessing the unity object in the lua operating environment and comprises a plurality of code segments to be replaced, and the code segments are associated with the specific unity object.
In the embodiment of the present application, an object access code template is generated in advance in an lua execution environment, and when an object access code is desired to be generated, a user may execute a code template obtaining operation in the lua execution environment, so that a terminal obtains the object access code template. For example, the object access code template may be:
Figure BDA0003585694890000151
wherein < luaobj >, < upValueGoDefine > and < nodeDefine > may be code fragments to be replaced.
And 505, performing code replacement in a code segment to be replaced of the object access code template based on the object identifier of the specific unit object, the data search identifier in the object record information and the object data of the target unit preset body to obtain an object access code, wherein the object access code comprises the object identifier and the data search identifier of the specific unit object.
In this embodiment of the application, in the above step 505, "performing code replacement in a code segment to be replaced of an object access code template to obtain an object access code based on an object identifier of a specific unit object, a data search identifier in object record information, and object data of a target unit preset body" may be:
generating target replacement code segments corresponding to the code segments to be replaced based on the object identification of the specific unit object, the data search identification in the object record information and the object data of the target unit preset body;
and replacing the corresponding code segment to be replaced in the object access code template by using each target replacement code segment to obtain the object access code.
In this embodiment of the present application, the code segments to be replaced include a code segment to be replaced, an object body access code segment to be replaced, and a component access code segment to be replaced, where in this case, the step "generating a target replacement code segment corresponding to each code segment to be replaced based on an object identifier of a specific unit object, a data search identifier in object record information, and object data of a target unit preset body" may be:
acquiring a preset body identifier of the target unit preset body from object data of the target unit preset body, and using the preset body identifier as a target replacement code segment corresponding to the identifier code segment to be replaced;
generating a code segment for querying and caching a specific unit object based on the data search identifier in the object record information and the object data of the target unit preset body, and using the code segment as a target replacement code segment corresponding to the access code segment of the object body to be replaced;
and generating a target replacement code segment corresponding to the component access code segment to be replaced based on the target replacement code segment corresponding to the object body access code segment to be replaced and the object identifier of the specific unity object.
For example, as shown in the alternative process diagram of fig. 8, < luaobj >: the name of the default root node, that is, the name of the default in the default data, is replaced with the name of the default root node, which is mainly used to identify the generated lua code. The content of < upValueGoDefine > is replaced with the lua code for the query and cache unity object according to the Access records component (cmpcache). The content of < nodeDefine > is replaced with a component access code according to the lua template table of the component.
In this embodiment of the present application, when the preset data structure in the object record information is an array structure, the above-mentioned steps "search for an identifier based on the data in the object record information, and generate a code segment for querying and caching a specific unit object based on the object data of the target unit preset body, and the target replacement code segment corresponding to the access code segment of the object body to be replaced" may be:
determining a subscript of a data search identification record of each specific unit object in the array structure;
generating a first code segment for determining a data lookup identification of a specific unit object in an array structure based on the subscript;
generating a second code segment for querying and caching the object data of the specific unit object in the object data of the target unit preset body according to the determined data searching identifier;
and merging the first code segment and the second code segment to be used as a target replacing code segment corresponding to the object ontology access code segment to be replaced.
For example, the first code segment may be:
local cmpcache=rootGo:GetComponent(typeof(CS.CmpCache))
local closeBtnGo=cmpcache.GetCache(0)
the unit object on the Cmpcache array is obtained in an array subscript mode, so that the unit object is searched by using a query path instead, and the transmission of integer variables between the lua and the C # instead of character string variables avoids memory recovery of the lua operating environment.
In this embodiment of the present application, the step of "generating a target replacement code segment corresponding to an access code segment of a component to be replaced based on a target replacement code segment corresponding to an ontology access code segment of the object to be replaced and an object identifier of a specific unit object" may be:
acquiring a data search identifier of a specific unit object according to the first code segment;
acquiring a component identifier of a mounted component of the specific unit object according to the object data of the specific unit object cached by the second code segment;
and generating a target replacement code segment corresponding to the component access code segment to be replaced based on the object identifier, the data search identifier and the component identifier of the specific unit object.
For example, the component to be replaced accesses the template code diagram of the code segment as shown in fig. 9. And generating a target replacement code segment corresponding to the component access code segment based on the object identifier, the data search identifier and the component identifier replacement template code of the specific unit object. Specifically, the < name > tag is replaced by the unit object name (i.e., the object tag of the unit object), the lua code generated in < upValueGoDefine > contains the data lookup tags required for querying and caching the unit object, the unit object variable names (i.e., the data lookup tags) will eventually replace the < gameObject > tag, and the < CmpType > tag will be replaced by the component type name (i.e., the component tag) of the unit object.
In this embodiment of the present application, if there are multiple mount components of a specific unit object, the step "generating a target replacement code segment corresponding to a component access code segment to be replaced based on an object identifier, a data search identifier, and a component identifier of the specific unit object" may be:
if a plurality of mount components of the specific unit object exist, generating a code segment for accessing each mount component based on the object identifier, the data search identifier and the component identifier of each mount component of the specific unit object;
and splicing the code segments accessing each mounted component to generate a target replacement code segment corresponding to the component access code segment to be replaced.
In this embodiment of the present application, the step of replacing the corresponding code segment to be replaced in the object access code template with each target replacement code segment to obtain the object access code may be:
and replacing the corresponding mark code segment to be replaced, the object body access code segment to be replaced and the component access code segment to be replaced in the object access code template by using each target replacement code segment to obtain the object access code comprising the mark code segment, the object body access code segment and the component access code segment.
Step 506, a target lua code file is obtained based on the object access code, the target lua code file is used for displaying the object identifier of the specific unit object for the user to select after being analyzed, and accessing the specific unit object corresponding to the selected object identifier based on the data search identifier after selection.
According to the code generation method provided by the embodiment of the application, when a user wants to access a specific unit object to be accessed in a lua operating environment, an analysis trigger operation can be executed to enable the computer device to analyze an object access code in a target lua code file, an object identification selection page including object identifications of the specific unit object is displayed on a user operation interface, the user can directly select the object identification of the specific unit object to be accessed at this time in the object identification selection page, after the computer device determines a data search identification of the specific unit object corresponding to the object identification, the computer device can access the specific unit object to be accessed according to the object identification selected by the user and the determined data search identification, the query path of the unit object to be accessed by the user in the lua operating environment is prevented from being artificially spelled, and therefore the query path of the artificially spelled unit object in the lua operating environment is prevented from being wrong, the development efficiency of the unity project is improved.
In order to better implement the object access method of the embodiment of the present application, an embodiment of the present application further provides an object access device. Referring to fig. 10, fig. 10 is a schematic structural diagram of an object access device according to an embodiment of the present application. The object access device may include a code file acquisition unit 1001, an identification display unit 1002, and an access unit 1003.
The code file obtaining unit 1001 is configured to obtain a target lua code file in response to an analysis trigger operation for the target lua code file in a lua operating environment, where the target lua code file includes an object access code of a lua language, the object access code is generated based on a unit preset body code and includes an object identifier and a data search identifier of a specific unit object that needs to be accessed in the unit preset body in the lua operating environment, and the data search identifier is used to obtain object data of the specific unit object;
an identifier display unit 1002, configured to parse the object access code in the target lua code file, and display an object identifier selection page on the user operation interface based on the parsing result, where the object identifier selection page includes an object identifier of a specific unity object;
an accessing unit 1003, configured to, in response to a selection operation for selecting an object identifier in the object identifier selection page, access a specific unit object corresponding to the selected object identifier based on the data lookup identifier.
Optionally, the object access code includes an object ontology access code and a component access code of a mount component of each specific unit object, the component access code includes an object identifier of the specific unit object and a component identifier of the mount component, and the object data includes a component identifier of the mount component and component data;
the access unit 1003 is further configured to:
responding to the selection operation of the object identification in the object identification selection page, determining a specific unit object corresponding to the selected object identification as a target unit object for access;
displaying a component identifier selection page on the user operation interface based on the analysis result, wherein the component identifier selection page comprises a target component identifier of a target mounting component of the target unit object;
and responding to the selection operation of the target component identification in the component identification selection page, searching the identification based on the data of the target unit object, and accessing the target mounting component corresponding to the selected target component identification.
All the above technical solutions can be combined arbitrarily to form the optional embodiments of the present application, and are not described herein again.
In order to better implement the code generation method of the embodiment of the present application, an embodiment of the present application further provides a code generation apparatus. Referring to fig. 11, fig. 11 is a schematic structural diagram of a code generation apparatus according to an embodiment of the present application. The code generation apparatus may include an object determination unit 1101, a recording unit 1102, an import unit 1103, a code template acquisition unit 1104, a replacement unit 1105, and a code file derivation unit 1106.
The object determining unit 1101 is configured to determine a specific unit object that needs to be accessed in the lua runtime environment from the unit objects included in the target unit preset entity;
the recording unit 1102 is configured to obtain a data search identifier of a specific unit object based on a target unit preset body, record the data search identifier in a preset data structure to obtain object record information, where position information of the data search identifier recorded in the preset data structure is integer data;
an importing unit 1103, configured to import the target unit default and the object record information into the lua operating environment;
a code template obtaining unit 1104, configured to obtain an object access code template of the lua language in the lua runtime environment, where the object access code template is used to access the unity object in the lua runtime environment and includes a number of to-be-replaced code segments associated with a specific unity object;
a replacing unit 1105, configured to perform code replacement in a to-be-replaced code segment of the object access code template based on the object identifier of the specific unit object, the data search identifier in the object record information, and the object data of the target unit preset volume, to obtain an object access code, where the object access code includes the object identifier and the data search identifier of the specific unit object;
a code file obtaining unit 1106, configured to obtain a target lua code file based on the object access code, where the target lua code file is configured to display an object identifier of the specific unit object after being parsed for selection by a user, and to access the specific unit object corresponding to the selected object identifier based on the data lookup identifier after the selection.
Optionally, the object determination unit 1101 is further configured to:
displaying a setting sub-page of the target unit preset body under a unit operation environment based on the code of the target unit preset body, wherein the setting sub-page comprises an object identifier of a unit object contained in the target unit preset body and an object setting area;
when the target object identifier of the unit object contained in the target unit preset body is selected, the unit object corresponding to the target object identifier is determined to be a specific unit object which needs to be accessed under the lua operating environment in response to the access marking operation in the object setting area corresponding to the target object identifier.
Optionally, the object determination unit 1101 is further configured to:
when a target object identifier of a unit object contained in a preset target unit is selected, displaying a target object setting area of the selected unit object corresponding to the target object identifier under the Unity running environment, wherein the target object setting area comprises an object attribute of the selected unit object;
and determining the selected unit object as the specific unit object which needs to be accessed under the lua operating environment in response to the operation of adding the label to the object attribute of the selected unit object in the target object setting area.
Optionally, the preset data structure is an array structure, and the recording unit 1102 is further configured to:
acquiring a data searching identifier of a specific unit object based on a target unit preset body;
and if the number of the specific unit objects is multiple, sequentially recording the data search identification of each specific unit object into an array structure according to a preset sequence to obtain object record information.
Optionally, the recording unit 1102 is further configured to:
mounting an access record component for a target unit presetting body;
storing the object record information into an access record component;
the import unit 1103 is further configured to:
and in response to the import operation of the object data and the access record component aiming at the target unit preset body from the unit running environment to the lua running environment, importing the target unit preset body and the object record information into the lua running environment.
Optionally, the replacing unit 1105 is further configured to:
generating target replacement code segments corresponding to the code segments to be replaced based on the object identification of the specific unit object, the data search identification in the object record information and the object data of the target unit preset body;
and replacing the corresponding code segment to be replaced in the object access code template by using each target replacement code segment to obtain the object access code.
Optionally, the to-be-replaced code segment includes an to-be-replaced identification code segment, an to-be-replaced object ontology accessing code segment, and an to-be-replaced component accessing code segment, and the replacing unit 1105 is further configured to:
acquiring a preset body identifier of the target unit preset body from object data of the target unit preset body, and using the preset body identifier as a target replacement code segment corresponding to the identifier code segment to be replaced;
generating a code segment for querying and caching a specific unit object based on the data search identifier in the object record information and the object data of the target unit preset body, and using the code segment as a target replacement code segment corresponding to the access code segment of the object body to be replaced;
and generating a target replacement code segment corresponding to the component access code segment to be replaced based on the target replacement code segment corresponding to the object body access code segment to be replaced and the object identifier of the specific unity object.
Optionally, the preset data structure in the object record information is an array structure, and the replacing unit 1105 is further configured to:
determining a subscript of a data search identification record of each specific unit object in the array structure;
generating a first code segment for determining a data lookup identification of a specific unit object in an array structure based on the subscript;
generating a second code segment for querying and caching the object data of the specific unit object in the object data of the target unit preset body according to the determined data searching identifier;
and merging the first code segment and the second code segment to be used as a target replacing code segment corresponding to the object ontology access code segment to be replaced.
Optionally, the replacing unit 1105 is further configured to:
acquiring a data search identifier of a specific unit object according to the first code segment;
acquiring a component identifier of a mounted component of the specific unit object according to the object data of the specific unit object cached by the second code segment;
and generating a target replacement code segment corresponding to the component access code segment to be replaced based on the object identifier, the data search identifier and the component identifier of the specific unit object.
Optionally, the replacing unit 1105 is further configured to:
if a plurality of mount components of the specific unit object exist, generating a code segment for accessing each mount component based on the object identifier, the data search identifier and the component identifier of each mount component of the specific unit object;
and splicing the code segments accessing each mounted component to generate a target replacement code segment corresponding to the component access code segment to be replaced.
Optionally, the replacing unit 1105 is further configured to:
and replacing the corresponding to-be-replaced identification code segment, the to-be-replaced object body access code segment and the to-be-replaced component access code segment in the object access code template by using each target replacement code segment to obtain the object access code comprising the identification code segment, the object body access code segment and the component access code segment.
According to the object access method, the code generation device, the equipment and the storage medium provided by the embodiment of the application, when a user wants to access a specific unit object needing to be accessed in a lua running environment, the analysis triggering operation can be executed to enable the computer equipment to analyze an object access code in a target lua code file, an object identification selection page comprising an object identification of the specific unit object is displayed on a user operation interface, the user can directly select the object identification of the specific unit object needing to be accessed at this time in the object identification selection page, after the computer equipment determines a data search identification of the specific unit object corresponding to the object identification, the computer equipment can access the specific unit object needing to be accessed according to the object identification selected by the user and the determined data search identification, and the user is prevented from artificially spelling a query path of the unit object needing to be accessed in the lua running environment, therefore, errors of the query path of the unit object artificially spelled in the lua running environment are avoided, and the development efficiency of the unit project is improved.
Correspondingly, the embodiment of the application also provides a computer device, which can be a terminal, and the terminal can be a terminal device such as a smart phone, a tablet computer, a notebook computer, a touch screen, a game machine, a personal computer, a personal digital assistant and the like. As shown in fig. 12, fig. 12 is a schematic structural diagram of a computer device according to an embodiment of the present application. The computer apparatus 1200 includes a processor 1201 having one or more processing cores, a memory 1202 having one or more computer-readable storage media, and a computer program stored on the memory 1202 and executable on the processor. The processor 1201 is electrically connected to the memory 1202. Those skilled in the art will appreciate that the computer device configurations illustrated in the figures are not meant to be limiting of computer devices and may include more or fewer components than those illustrated, or some components may be combined, or a different arrangement of components.
The processor 1201 is a control center of the computer apparatus 1200, connects various parts of the entire computer apparatus 1200 using various interfaces and lines, performs various functions of the computer apparatus 1200 and processes data by running or loading software programs and/or modules stored in the memory 1202 and calling data stored in the memory 1202, thereby monitoring the computer apparatus 1200 as a whole.
In this embodiment, the processor 1201 in the computer device 1200 loads instructions corresponding to processes of one or more applications into the memory 1202 according to the following steps, and the processor 1201 runs the applications stored in the memory 1202, thereby implementing various functions:
responding to the analysis triggering operation aiming at the target lua code file in the lua running environment, and acquiring the target lua code file, wherein the target lua code file comprises an object access code of the lua language, the object access code is generated based on a unit preset body code and comprises an object identifier and a data searching identifier of a specific unit object needing to be accessed in the unit preset body under the lua running environment, and the data searching identifier is used for acquiring object data of the specific unit object;
analyzing an object access code in the target lua code file, and displaying an object identifier selection page on a user operation interface based on an analysis result, wherein the object identifier selection page comprises an object identifier of a specific unit object;
and in response to the selection operation of the object identification in the object identification selection page, accessing the specific unit object corresponding to the selected object identification based on the data search identification.
Determining a specific unit object which needs to be accessed in the lua operating environment in the unit objects included in the target unit preset body;
acquiring a data search identifier of a specific unit object based on a target unit preset body, recording the data search identifier in a preset data structure to obtain object record information, wherein the position information of the data search identifier recorded in the preset data structure is integer data;
importing the target unit preset body and the object record information into the lua operating environment;
the method comprises the steps that an object access code template of the lua language is obtained in the lua running environment, the object access code template is used for accessing a unit object in the lua running environment and comprises a plurality of code segments to be replaced, wherein the code segments are associated with a specific unit object;
performing code replacement in a code segment to be replaced of an object access code template based on an object identifier of a specific unit object, a data search identifier in object record information and object data of a target unit preset body to obtain an object access code, wherein the object access code comprises the object identifier and the data search identifier of the specific unit object;
and obtaining a target lua code file based on the object access code, wherein the target lua code file is used for displaying the object identification of the specific unit object after being analyzed for selection by a user, and accessing the specific unit object corresponding to the selected object identification based on the data searching identification after selection.
The above operations can be implemented in the foregoing embodiments, and are not described in detail herein.
Optionally, as shown in fig. 12, the computer device 1200 further includes: a touch display screen 1203, a radio frequency circuit 1204, an audio circuit 1205, an input unit 1206, and a power source 1207. The processor 1201 is electrically connected to the touch display 1203, the rf circuit 1204, the audio circuit 1205, the input unit 1206, and the power source 1207. Those skilled in the art will appreciate that the computer device configuration illustrated in FIG. 12 does not constitute a limitation of computer devices, and may include more or fewer components than those illustrated, or some components may be combined, or a different arrangement of components.
The touch display screen 1203 may be used for displaying a graphical user interface and receiving an operation instruction generated by a user acting on the graphical user interface. Touch display screen 1203 may include a display panel and a touch panel. The display panel may be used, among other things, to display information entered by or provided to a user and various graphical user interfaces of the computer device, which may be made up of graphics, text, icons, video, and any combination thereof. Alternatively, the Display panel may be configured in the form of a Liquid Crystal Display (LCD), an Organic Light-Emitting Diode (OLED), or the like. The touch panel can be used for collecting touch operations of a user on or near the touch panel (such as operations of the user on or near the touch panel by cashing a finger, a stylus pen and any other suitable object or accessory), and generating corresponding operation instructions, and the operation instructions execute corresponding programs. Alternatively, the touch panel may include two parts, a touch detection device and a touch controller. The touch detection device detects the touch direction of a user, detects a signal brought by touch operation and transmits the signal to the touch controller; the touch controller receives touch information from the touch detection device, converts the touch information into touch point coordinates, sends the touch point coordinates to the processor 1201, and can receive and execute commands sent by the processor 1201. The touch panel may overlay the display panel, and when the touch panel detects a touch operation thereon or nearby, the touch panel may be transmitted to the processor 1201 to determine the type of the touch event, and then the processor 1201 may provide a corresponding visual output on the display panel according to the type of the touch event. In the embodiment of the present application, the touch panel and the display panel may be integrated into the touch display screen 1203 to implement input and output functions. However, in some embodiments, the touch panel and the touch panel can be implemented as two separate components to perform the input and output functions. That is, the touch display screen 1203 may also be a part of the input unit 1206 to implement an input function.
The rf circuit 1204 may be used for transceiving rf signals to establish wireless communication with a network device or other computer device via wireless communication, and for transceiving signals with the network device or other computer device.
The audio circuit 1205 may be used to provide an audio interface between the user and the computer device through a speaker, microphone. The audio circuit 1205 can transmit the electrical signal converted from the received audio data to the speaker, and the electrical signal is converted into a sound signal by the speaker and output; on the other hand, the microphone converts a collected sound signal into an electric signal, converts the electric signal into audio data after being received by the audio circuit 1205, processes the audio data by the audio data output processor 1201, and sends the audio data to, for example, another computer device via the radio frequency circuit 1204, or outputs the audio data to the memory 1202 for further processing. The audio circuitry 1205 may also include an earbud jack to provide communication of peripheral headphones with the computer device.
The input unit 1206 may be used to receive input numbers, character information, or user characteristic information (e.g., fingerprint, iris, facial information, etc.), and to generate keyboard, mouse, joystick, optical, or trackball signal inputs related to user settings and function control.
The power supply 1207 is used to power the various components of the computer device 1200. Optionally, the power source 1207 may be logically connected to the processor 1201 through a power management system, so as to implement functions of managing charging, discharging, and power consumption management through the power management system. The power supply 1207 may also include one or more dc or ac power sources, recharging systems, power failure detection circuitry, power converters or inverters, power status indicators, or any other component.
Although not shown in fig. 12, the computer device 1200 may further include a camera, a sensor, a wireless fidelity module, a bluetooth module, etc., which are not described in detail herein.
In the foregoing embodiments, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.
As can be seen from the above, the computer device provided in this embodiment, when a user wants to access a specific unit object to be accessed in the lua operating environment, may execute a parsing triggering operation to enable the computer device to parse an object access code in the target lua code file, display an object identifier selection page including an object identifier of the specific unit object on the user operating interface, the user may directly select an object identifier of the specific unit object to be accessed this time in the object identifier selection page, and after the computer device determines a data lookup identifier of the specific unit object corresponding to the object identifier, the computer device may access the specific unit object to be accessed according to the object identifier selected by the user and the determined data lookup identifier, so as to avoid that the user artificially spells an inquiry path of the unit object to be accessed in the lua operating environment, thereby avoiding an error in the inquiry path of the artificially spelled unit object in the lua operating environment, the development efficiency of the unity project is improved.
It will be understood by those skilled in the art that all or part of the steps of the methods of the above embodiments may be performed by instructions or by associated hardware controlled by the instructions, which may be stored in a computer readable storage medium and loaded and executed by a processor.
To this end, the present application provides a computer-readable storage medium, in which a plurality of computer programs are stored, and the computer programs can be loaded by a processor to execute the steps in any one of the object access method and the code generation method provided by the present application. For example, the computer program may perform the steps of:
responding to the analysis triggering operation aiming at the target lua code file in the lua running environment, and acquiring the target lua code file, wherein the target lua code file comprises an object access code of the lua language, the object access code is generated based on a unit preset body code and comprises an object identifier and a data searching identifier of a specific unit object needing to be accessed in the unit preset body under the lua running environment, and the data searching identifier is used for acquiring object data of the specific unit object;
analyzing an object access code in the target lua code file, and displaying an object identifier selection page on a user operation interface based on an analysis result, wherein the object identifier selection page comprises an object identifier of a specific unit object;
and responding to the selection operation of the object identification in the object identification selection page, and accessing the specific unit object corresponding to the selected object identification based on the data searching identification.
Determining a specific unit object which needs to be accessed in the lua operating environment in the unit objects included in the target unit preset body;
acquiring a data search identifier of a specific unit object based on a target unit preset body, recording the data search identifier in a preset data structure to obtain object record information, wherein the position information of the data search identifier recorded in the preset data structure is integer data;
importing the target unit preset body and the object record information into the lua operating environment;
the method comprises the steps that an object access code template of the lua language is obtained in the lua running environment, the object access code template is used for accessing a unity object in the lua running environment and comprises a plurality of code segments to be replaced, wherein the code segments to be replaced are associated with a specific unity object;
performing code replacement in a code segment to be replaced of an object access code template based on an object identifier of a specific unit object, a data search identifier in object record information and object data of a target unit preset body to obtain an object access code, wherein the object access code comprises the object identifier and the data search identifier of the specific unit object;
and obtaining a target lua code file based on the object access code, wherein the target lua code file is used for displaying the object identification of the specific unit object after being analyzed for selection by a user, and accessing the specific unit object corresponding to the selected object identification based on the data searching identification after selection.
The above operations can be implemented in the foregoing embodiments, and are not described in detail herein.
Wherein the storage medium may include: read Only Memory (ROM), Random Access Memory (RAM), magnetic or optical disks, and the like.
Since the computer program stored in the storage medium can execute the steps in any object access method and code generation method provided in the embodiments of the present application, beneficial effects that can be achieved by any object access method and code generation method provided in the embodiments of the present application can be achieved, for details, see the foregoing embodiments, and are not described herein again.
In the foregoing embodiments, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.
The object access method, the code generation method, the device, the apparatus and the storage medium provided in the embodiments of the present application are described in detail above, and a specific example is applied in the present application to explain the principle and the implementation of the present invention, and the description of the above embodiments is only used to help understanding the technical scheme and the core idea of the present invention; those of ordinary skill in the art will understand that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.

Claims (17)

1. An object access method, comprising:
responding to an analysis triggering operation aiming at a target lua code file under a lua running environment, and acquiring the target lua code file, wherein the target lua code file comprises an object access code of a lua language, the object access code is generated based on a unit preset body code and comprises an object identifier and a data searching identifier of a specific unit object needing to be accessed under the lua running environment in a unit preset body, and the data searching identifier is used for acquiring object data of the specific unit object;
analyzing the object access code in the target lua code file, and displaying an object identifier selection page on a user operation interface based on an analysis result, wherein the object identifier selection page comprises the object identifier of the specific unity object;
and responding to the selection operation of the object identification in the object identification selection page, and accessing a specific unity object corresponding to the selected object identification based on the data search identification.
2. The method according to claim 1, wherein the object access code comprises an object ontology access code and a component access code of a mounted component of each specific unit object, the component access code comprises an object identifier of the specific unit object and a component identifier of the mounted component, and the object data comprises a component identifier of the mounted component and component data;
the accessing a specific unity object corresponding to the selected object identification based on the data lookup identification in response to the selection operation of the object identification in the object identification selection page comprises:
responding to the selection operation of the object identification in the object identification selection page, and determining a specific unit object corresponding to the selected object identification as a target unit object for access;
displaying a component identifier selection page on the user operation interface based on the analysis result, wherein the component identifier selection page comprises a target component identifier of a target mounted component of the target unit object;
and responding to the selection operation of the target component identification in the component identification selection page, searching the identification based on the data of the target unit object, and accessing the target mounting component corresponding to the selected target component identification.
3. A code generation method, comprising:
determining a specific unit object which needs to be accessed in the lua operating environment in the unit objects included in the target unit preset body;
acquiring a data search identifier of the specific unit object based on the target unit preset body, recording the data search identifier in a preset data structure to obtain object recording information, wherein the position information of the data search identifier recorded in the preset data structure is integer data;
importing the target unit preset body and the object record information into the lua operating environment;
acquiring an object access code template of a lua language under the lua operating environment, wherein the object access code template is used for accessing a unity object under the lua operating environment and comprises a plurality of code segments to be replaced related to the specific unity object;
performing code replacement in a code segment to be replaced of the object access code template based on the object identifier of the specific unit object, the data search identifier in the object record information and the object data of the target unit preset body to obtain an object access code, wherein the object access code comprises the object identifier and the data search identifier of the specific unit object;
and obtaining a target lua code file based on the object access code, wherein the target lua code file is used for displaying the object identifier of the specific unit object after being analyzed for selection by a user, and searching for the identifier to access the specific unit object corresponding to the selected object identifier based on the data after selection.
4. The method according to claim 3, wherein the determining the specific unit object that needs to be accessed in the lua runtime environment in the unit objects included in the target unit preset comprises:
displaying a setting subpage of the target unit preset body under a unit running environment based on the code of the target unit preset body, wherein the setting subpage comprises an object identifier of a unit object contained in the target unit preset body and an object setting area;
when the target object identifier of the unit object included in the target unit preset body is selected, in response to an access marking operation in the object setting area corresponding to the target object identifier, determining that the unit object corresponding to the target object identifier is the specific unit object that needs to be accessed in the lua operating environment.
5. The method according to claim 4, wherein the determining that the unit object corresponding to the target object id is the specific unit object that needs to be accessed in the lua runtime environment in response to an access marking operation in an object setting area corresponding to the target object id after the target object id of the unit object included in the target unit preset volume is selected comprises:
when a target object identifier of a unit object contained in the target unit preset body is selected, displaying a target object setting area of the selected unit object corresponding to the target object identifier in the Unity running environment, wherein the target object setting area comprises an object attribute of the selected unit object;
and in response to the operation of adding a label to the object attribute of the selected unit object in the target object setting area, determining that the selected unit object is the specific unit object which needs to be accessed in the lua operating environment.
6. The method according to claim 3, wherein the preset data structure is an array structure, and the obtaining the data search identifier of the specific unit object based on the target unit preset body and recording the data search identifier in a preset data structure to obtain object record information includes:
acquiring a data search identifier of the specific unit object based on the target unit preset body;
and if the number of the specific unit objects is multiple, sequentially recording the data search identification of each specific unit object into the array structure according to a preset sequence to obtain the object record information.
7. The method according to claim 3, wherein the obtaining a data search identifier of the specific unit object based on the target unit preset body, and recording the data search identifier in a preset data structure to obtain object record information further comprises:
mounting an access record component for the target unit default;
storing the object record information into the access record component;
the importing the target unit default and the object record information into the lua operating environment includes:
and in response to the object data for the target unit preset body and the import operation of the access record component from the unit operation environment to the lua operation environment, importing the target unit preset body and the object record information into the lua operation environment.
8. The method according to claim 3, wherein the performing code replacement in the code segment to be replaced of the object access code template based on the object identifier of the specific unit object, the data search identifier in the object record information, and the object data of the target unit preset body to obtain the object access code comprises:
generating target replacement code segments corresponding to the code segments to be replaced based on the object identification of the specific unit object, the data search identification in the object record information and the object data of the target unit preset body;
and replacing the corresponding code segment to be replaced in the object access code template by using each target replacing code segment to obtain the object access code.
9. The method according to claim 8, wherein the code segments to be replaced include a code segment to be replaced with an identifier, a code segment to be replaced with an object ontology access code, and a code segment to be replaced with a component access code, and the generating a target replacement code segment corresponding to each code segment to be replaced based on the object identifier of the specific unit object, the data search identifier in the object record information, and the object data of the target unit preset body includes:
acquiring a preset body identifier of the target unit preset body from the object data of the target unit preset body, and using the preset body identifier as a target replacement code segment corresponding to the identifier code segment to be replaced;
generating a code segment for querying and caching the specific unit object based on the data search identifier in the object record information and the object data of the target unit preset body, wherein the code segment is used as a target replacement code segment corresponding to the access code segment of the object body to be replaced;
and generating a target replacement code segment corresponding to the component access code segment to be replaced based on the target replacement code segment corresponding to the object body access code segment to be replaced and the object identifier of the specific unity object.
10. The method according to claim 9, wherein a preset data structure in the object record information is an array structure, and the searching for the identifier based on the data in the object record information and the object data of the target unit preset body generates a query and caches a code segment of the specific unit object as a target replacement code segment corresponding to the object to be replaced ontology access code segment, including:
determining a data lookup identifier for each of the particular unit objects as a subscript recorded in the array structure;
generating a first code segment that determines a data lookup identification for the particular unit object in the array structure based on the subscript;
generating a second code segment which is used for inquiring and caching the object data of the specific unit object in the object data of the target unit preset body according to the determined data searching identification;
and merging the first code segment and the second code segment to be used as a target replacing code segment corresponding to the to-be-replaced object ontology access code segment.
11. The method according to claim 10, wherein the generating a target replacement code segment corresponding to the to-be-replaced component access code segment based on the target replacement code segment corresponding to the to-be-replaced object ontology access code segment and the object identifier of the specific unity object comprises:
acquiring a data search identifier of the specific unit object according to the first code segment;
acquiring a component identifier of a mounted component of the specific unit object according to the object data of the specific unit object cached by the second code segment;
and generating a target replacement code segment corresponding to the component access code segment to be replaced based on the object identifier of the specific unit object, the data search identifier and the component identifier.
12. The method according to claim 11, wherein the generating a target replacement code segment corresponding to the component access code segment to be replaced based on the object identifier of the specific unit object, the data search identifier and the component identifier comprises:
if the number of the mounted components of the specific unit object is multiple, generating a code segment for accessing each mounted component based on the object identifier of the specific unit object, the data search identifier and the component identifier of each mounted component;
and splicing the code segments accessing each mounting component to generate a target replacement code segment corresponding to the component access code segment to be replaced.
13. The method of claim 9, wherein replacing the corresponding code segment to be replaced in the object access code template with each target replacement code segment to obtain the object access code comprises:
and replacing the corresponding to-be-replaced identification code segment, the to-be-replaced object body access code segment and the to-be-replaced component access code segment in the object access code template by using each target replacement code segment to obtain the object access code comprising the identification code segment, the object body access code segment and the component access code segment.
14. An object access apparatus, comprising:
a code file obtaining unit, configured to obtain a target lua code file in response to a parsing trigger operation for the target lua code file in a lua operating environment, where the target lua code file includes an object access code in a lua language, the object access code is generated based on a unit preset body code and includes an object identifier and a data lookup identifier of a specific unit object that needs to be accessed in the unit preset body under the lua operating environment, and the data lookup identifier is used to obtain object data of the specific unit object;
an identifier display unit, configured to parse the object access code in the target lua code file, and display an object identifier selection page on a user operation interface based on a parsing result, where the object identifier selection page includes an object identifier of the specific unit object;
and the access unit is used for responding to the selection operation of the object identification in the object identification selection page, and accessing the specific unit object corresponding to the selected object identification based on the data search identification.
15. A code generation apparatus, comprising:
the object determination unit is used for determining a specific unit object which needs to be accessed in the lua running environment in the unit objects included in the target unit preset body;
the recording unit is used for acquiring a data search identifier of the specific unit object based on the target unit preset body, recording the data search identifier in a preset data structure to obtain object recording information, wherein the position information of the data search identifier recorded in the preset data structure is integer data;
an importing unit, configured to import the target unit preset body and the object record information into the lua operating environment;
a code template obtaining unit, configured to obtain an object access code template in the lua language in the lua runtime environment, where the object access code template is used to access a unit object in the lua runtime environment and includes a number of code segments to be replaced associated with the specific unit object;
a replacing unit, configured to perform code replacement in a to-be-replaced code segment of the object access code template based on an object identifier of the specific unit object, the data search identifier in the object record information, and object data of the target unit preset body, to obtain an object access code, where the object access code includes the object identifier and the data search identifier of the specific unit object;
and the code file obtaining unit is used for obtaining a target lua code file based on the object access code, wherein the target lua code file is used for displaying the object identifier of the specific unit object after being analyzed so as to be selected by a user, and searching and accessing the specific unit object corresponding to the selected object identifier based on the data after being selected.
16. A computer device, comprising:
a memory for storing a computer program;
a processor for implementing the steps in the object access method and the code generation method according to any one of claims 1 to 13 when executing the computer program.
17. A computer-readable storage medium, having stored thereon a computer program which, when executed by a processor, implements the object access method and the steps in the code generation method according to any one of claims 1 to 13.
CN202210365488.2A 2022-04-07 2022-04-07 Object access method, code generation method, device, equipment and storage medium Pending CN114741068A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210365488.2A CN114741068A (en) 2022-04-07 2022-04-07 Object access method, code generation method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210365488.2A CN114741068A (en) 2022-04-07 2022-04-07 Object access method, code generation method, device, equipment and storage medium

Publications (1)

Publication Number Publication Date
CN114741068A true CN114741068A (en) 2022-07-12

Family

ID=82278401

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210365488.2A Pending CN114741068A (en) 2022-04-07 2022-04-07 Object access method, code generation method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN114741068A (en)

Similar Documents

Publication Publication Date Title
JP7200277B2 (en) Method and apparatus, electronic device, storage medium and computer program for identifying word slots
US11741002B2 (en) Test automation systems and methods using logical identifiers
CN112632919B (en) Document editing method and device, computer equipment and storage medium
CN112882764B (en) Component loading method and device, computer equipment and storage medium
CN112015468B (en) Interface document processing method and device, electronic equipment and storage medium
CN116360735A (en) Form generation method, device, equipment and medium
US9251267B2 (en) Generating behavior information for a link
CN108369589A (en) Automatic theme label recommendations for classifying to communication are provided
CN108694172B (en) Information output method and device
CN113094625A (en) Page element positioning method and device, electronic equipment and storage medium
CN111177247B (en) Data conversion method, device and storage medium
WO2023151397A1 (en) Application program deployment method and apparatus, device, and medium
US11966562B2 (en) Generating natural languages interface from graphic user interfaces
US11838294B2 (en) Method for identifying user, storage medium, and electronic device
CN114741068A (en) Object access method, code generation method, device, equipment and storage medium
CN113742716B (en) Code running method, device, electronic equipment, storage medium and program product
US20210382918A1 (en) Method and apparatus for labeling data
CN113609154A (en) Data query method and device, electronic equipment and storage medium
CN113110846A (en) Method and device for acquiring environment variable
CN114595449A (en) Safety scanning method and device
JP7293544B2 (en) Q&amp;A system update processing method and device
US11709691B2 (en) Software user assistance through image processing
CN113900895B (en) Information processing method, information processing apparatus, storage medium, and electronic device
CN114159797A (en) Text processing method and device, computer equipment and storage medium
CN114637942A (en) Page preview method and device, computer equipment and storage medium

Legal Events

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