A serialization persistence publishing method for Unity scene

CN116243890BActive Publication Date: 2026-08-18NARI INFORMATION & COMM TECH
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202211721111.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-30
Publication Date
2026-08-18
Estimated Expiration
2042-12-30

AI Technical Summary

Technical Problem

[0002]常规Unity场景发布需要经过对Scene场景编辑、编译、打包发布,在进行打包时,Unity会将Resources文件夹中的所有资源全部打进包体当中,因此发布的工程文件较大,每次场景内容变更时都需要对场景、脚本、资源文件进行全量编译打包发布,虽然Unity针对此情况,提供了AssetBoundle打包模式,但需要前期定好资源目录结构,而且资源变更时需要去打包AssetBoundle包,对于需求变更频繁的场景将显得非常的低效,需要有一种简单快捷的序列化、反序列化的场景快速发布的模式

Benefits of technology

[0047]本发明一方面通过将Unity场景分为序列化组件,实现了序列化处理和持久化处理;另一方面,通过序列化组件的反序列化实例化处理,实现了Unity场景的反序列化渲染展示发布,解决了常规Unity场景编译、打包、部署流程繁琐,效率低的问题,绕过了Unity场景繁琐复杂的打包流程,大大提高了项目发布速度和项目发布大小,提高了项目发布效率。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116243890B_ABST
    Figure CN116243890B_ABST
Patent Text Reader

Abstract

The application discloses a serialization persistence publishing method for a Unity scene, and comprises the following steps: acquiring the Unity scene; performing page layout description document structure definition according to the Unity scene to obtain a serialization component; performing serialization processing according to the serialization component to obtain a serialization file; performing persistence processing according to the serialization file to obtain a persistence storage database; and performing deserialization instantiation of the serialization component according to the persistence storage database to realize deserialization rendering and display publishing of the Unity scene. The application realizes serialization processing, persistence processing and deserialization rendering and display publishing of the Unity scene, bypasses a complicated and complex packaging process of the Unity scene, greatly improves project publishing speed and project publishing size, and improves project publishing efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to a serialization and persistent publishing method for Unity scenes, belonging to the field of 3D visualization technology. Background Technology

[0002] Conventional Unity scene publishing requires editing, compiling, and packaging the Scene. During packaging, Unity includes all resources in the Resources folder into the package body, resulting in a large project file. Every time the scene content changes, a full compilation, packaging, and publishing of the scene, scripts, and resource files is required. Although Unity provides the AssetBoundle packaging mode for this situation, it requires defining the resource directory structure in advance, and the AssetBoundle package needs to be packaged every time resources change. This is very inefficient for scenes with frequent changes in requirements. A simple and fast serialization and deserialization mode for rapid scene publishing is needed.

[0003] The information disclosed in this background section is intended only to enhance the understanding of the overall background of the invention and should not be construed as an admission or in any way implying that the information constitutes prior art known to those skilled in the art. Summary of the Invention

[0004] The purpose of this invention is to overcome the shortcomings of the existing technology and provide a serialization and persistence publishing method for Unity scenes. This method realizes the serialization, persistence, deserialization, rendering, display, and publishing of Unity scenes, bypassing the cumbersome and complex packaging process of Unity scenes, greatly improving the project publishing speed and size, and increasing the efficiency of project publishing.

[0005] To achieve the above objectives, the present invention is implemented using the following technical solution:

[0006] This invention discloses a serialization and persistent publishing method for Unity scenarios, comprising the following steps:

[0007] Get the Unity scene;

[0008] Based on the Unity scene, define the page layout description document structure to obtain serializable components;

[0009] Based on the serialization component, serialization processing is performed to obtain a serialized file;

[0010] Based on the serialized file, persistent processing is performed to obtain a persistent storage database;

[0011] Based on the persistent storage database, the serialized components are deserialized and instantiated to achieve deserialized rendering, display, and publishing of the Unity scene.

[0012] Furthermore, the serialization component includes a regular attribute component, a custom component, a built-in component, and a resource type component;

[0013] The common attribute components include string, int, float, char, and bool;

[0014] The custom components include the dataset SQL dataset VSDataSQL, the Excel dataset VSDataSheet, and the data source VSHttp component;

[0015] The built-in components include Camera, Canvas, CanvasGroup, CanvasScaler, GraphicRaycaster, Color, ColorsGroup, RectTransform, Transform, UnityEvent, 2D data Vector2, 3D data Vector3, Image, Mask, and Text;

[0016] The resource type components include GameObject, Material, Effect, Font, Sprite, and 3D model.

[0017] Furthermore, the serialization process includes:

[0018] Use JsonObject to mark the serializable component, that is, create a JSON object JObject for the serializable component, where the full path of the component is used as the property name and the serialized JSON string is used as the property value;

[0019] For the marked regular property components, use the JsonProperty attribute to mark the fields that need to be serialized, and then use JsonConverter to serialize them to obtain the corresponding serialized file;

[0020] For tagged custom components, built-in components, or resource type components, use the corresponding custom serialization converter to obtain the corresponding serialized file.

[0021] Furthermore, for tagged custom components, a serialization converter based on a custom type is available:

[0022] Get an instance of the custom type serialization converter, JObject;

[0023] Execute the corresponding serialization method of the component and assign the result to the customJson property of JObject;

[0024] The remaining properties marked as JsonProperty are serialized using JsonConvert, and the result is assigned to the selfJson property of JObject.

[0025] Finally, the JObject is serialized, and the custom component class name and the serialized string are combined to form a key-value pair JSON object, resulting in the corresponding serialized file.

[0026] Furthermore, for the tagged built-in components, a serialization converter based on the built-in components is also available.

[0027] Get the JObject instance of the serializer converter for the built-in component;

[0028] Execute the corresponding serialization method of the component, and use the built-in component class name and the serialized string to form a key-value pair JSON object to obtain the corresponding serialized file.

[0029] Furthermore, for the marked resource type components, the serialization converter based on the resource type components obtains the resource path as the serialization attribute value, and uses the resource type component class name and the serialized string to form a key-value pair JSON object to obtain the corresponding serialized file.

[0030] Furthermore, the persistent storage database includes a template type data table, a screen group directory data table, a screen template data table, and a screen file data table;

[0031] The template type data table is used to store the length, width, number of rows, number of columns, and other attributes of a single screen that defines the rendering and display container;

[0032] The screen grouping directory data table is used to store grouping directory information that defines the scene;

[0033] The screen template data table is used to store the attribute information of the design page, including screen name, template type, group directory information, deletion status, sub-screen ID, etc.

[0034] The image file data table is used to store the scene content serialization file, and the file data stream is stored in the table field of type BLOG.

[0035] Furthermore, the persistence process includes:

[0036] Construct separate data tables for template types, screen grouping directories, screen templates, and screen files.

[0037] Based on the serialized file, the template type, screen group directory, and screen template are configured.

[0038] Generate a template type object based on the template type, and persist it to the template type data table using Hibernate;

[0039] Generate a screen group directory object based on the screen group directory, and persist it to the screen group directory data table using Hibernate.

[0040] A screen template object is generated based on the screen template, and persisted to the screen template data table using Hibernate.

[0041] The JSON file in the serialized file is used to generate a screen file entity object in the form of a byte array, and then persisted to the screen file data table using Hibernate.

[0042] Furthermore, the deserialization rendering and display of the Unity scene includes:

[0043] Based on the persistent storage database, a serialized file of the scene is obtained;

[0044] The serialized file of the scene is deserialized, and each component in the scene is traversed and deserialized one by one to realize the instantiation of the scene.

[0045] Among them, the preset scene control management component can realize the switching of screen scenes.

[0046] Compared with the prior art, the beneficial effects achieved by the present invention are as follows:

[0047] This invention, on the one hand, divides Unity scenes into serialization components, realizing serialization and persistence processing; on the other hand, through the deserialization and instantiation processing of serialization components, it realizes the deserialization rendering, display, and publishing of Unity scenes. This solves the problems of cumbersome and inefficient compilation, packaging, and deployment processes of conventional Unity scenes, bypasses the cumbersome and complex packaging process of Unity scenes, greatly improves the speed and size of project releases, and enhances project release efficiency. Attached Figure Description

[0048] Figure 1 This is a flowchart of a serialization and persistence publishing method for Unity scenarios;

[0049] Figure 2 This is a flowchart of the serialization process;

[0050] Figure 3 This is a flowchart of the persistence process;

[0051] Figure 4 This is a flowchart of the serialization rendering and display process;

[0052] Figure 5 It is a cascading relationship of data tables. Detailed Implementation

[0053] The present invention will be further described below with reference to the accompanying drawings. The following embodiments are only used to more clearly illustrate the technical solution of the present invention, and should not be used to limit the scope of protection of the present invention.

[0054] This invention discloses a serialization and persistent publishing method for Unity scenarios, such as... Figure 1 As shown, it includes the following steps:

[0055] Get the Unity scene;

[0056] Based on the Unity scene, define the page layout description document structure to obtain serializable components;

[0057] The serialization component performs serialization processing to obtain a serialized file;

[0058] Based on the serialized file, perform persistent processing to obtain a persistent storage database;

[0059] Based on the persistent storage database, serialized components are deserialized and instantiated to achieve deserialized rendering, display, and publishing of Unity scenes.

[0060] The technical concept of this invention is as follows: on the one hand, by dividing the Unity scene into serialization components, serialization and persistence processing are realized; on the other hand, by deserializing and instantiating the serialization components, the deserialization rendering, display and publishing of the Unity scene are realized. This solves the problem of cumbersome and inefficient compilation, packaging and deployment processes of conventional Unity scenes, bypasses the cumbersome and complex packaging process of Unity scenes, greatly improves the project release speed and project release size, and improves the project release efficiency.

[0061] The specific steps are as follows:

[0062] Step 1: Serialization component.

[0063] First, define the directory structure of the Unity scene editor and the document structure of the serialized page layout description file. The scene serialization file is described in key-value pairs, including whether the scene is loaded, the scene name, the template scene, and the scene component structure. The scene content is the information of all the components that make up the scene. The elements in the scene are mainly divided into regular attribute components, custom components, built-in components, and resource type components. The elements in the scene mainly include node elements such as scene, camera component, custom control, built-in control, dataset, event, operator, animation, and 3D model. The specific attribute list can be added or removed as needed.

[0064] Specifically, the common property components include string, int, float, char, and bool;

[0065] Custom components, including the SQL dataset VSDataSQL, the Excel dataset VSDataSheet, and the data source VSHttp component;

[0066] Built-in components include Camera, Canvas, CanvasGroup, CanvasScaler, GraphicRaycaster, Color, ColorsGroup, RectTransform, Transform, UnityEvent, 2D data Vector2, 3D data Vector3, Image, Mask, and Text;

[0067] Resource type components include GameObject, Material, Effect, Font, Sprite, and 3D model.

[0068] The document template structure for describing the specific scenario page layout is as follows:

[0069] (I) Scenario:

[0070]

[0071]

[0072] (II) Regular Attribute Components:

[0073]

[0074]

[0075] (III) Custom Components:

[0076]

[0077]

[0078]

[0079]

[0080]

[0081] (iv) Built-in components:

[0082]

[0083]

[0084]

[0085]

[0086]

[0087] (V) Resource Components:

[0088]

[0089]

[0090] (vi) Scene control and management components:

[0091]

[0092] Step 2: Serialize the file.

[0093] When serializing Unity scene content, the serializable component class is first marked with [JsonObject(MemberSerialization.OptIn)]. For regular type properties, the field to be serialized is marked with the [JsonProperty] attribute. For complex type properties, including custom components, built-in components, and resource components, a custom serialization converter is required, and the property field is associated with [JsonConverter(typeof(XXJsonConverter))]. When the serialization method of the entire component class is executed, the corresponding serialization converter will be called to achieve serialization.

[0094] Specifically, such as Figure 2 As shown:

[0095] Use [JsonObject(MemberSerialization.OptIn)] to mark the serialization component, that is, create a JSON object JObject for the serialization component, where the full path of the component is used as the property name and the serialized JSON string is used as the property value;

[0096] For regular property components that have been marked, such as string, int, float, char, bool, etc., use the JsonProperty attribute to mark the fields that need to be serialized. Fields that are not marked will not be serialized by default. Then use JsonConverter to serialize them to obtain the corresponding serialized file.

[0097] For tagged custom components, built-in components, or resource type components, use the corresponding custom serialization converter and associate the attribute fields with [JsonConverter(typeof(XXJsonConverter))] to obtain the corresponding serialized file.

[0098] Furthermore, for tagged custom components, a serialization converter based on a custom type is available:

[0099] Create a custom component's JSON object JObject, and obtain an instance of the custom type's serialization converter JObject;

[0100] Execute the corresponding serialization method of the component and assign the result to the customJson property of JObject;

[0101] The remaining properties marked as JsonProperty are serialized using JsonConvert, and the result is assigned to the selfJson property of JObject.

[0102] Finally, the JObject is serialized, and the custom component class name and the serialized string are combined to form a key-value pair JSON object, resulting in the corresponding serialized file.

[0103] Furthermore, for the tagged built-in components, a serialization converter based on the built-in components is also available.

[0104] Get the JObject instance of the serializer converter for the built-in component;

[0105] The corresponding serialization method ComponentToJson() is executed to create a key-value JSON object using the built-in component class name and the serialized string, thus obtaining the corresponding serialized file.

[0106] Furthermore, for the marked resource type components, the serialization converter based on the resource type components obtains the resource path as the serialization attribute value, and uses the resource type component class name and the serialized string to form a key-value pair JSON object to obtain the corresponding serialized file.

[0107] It should be noted that custom components, built-in components, and resource components cannot be directly serialized. They require their own JSON converters, such as XXJsonConverter. These converters inherit from the IComponentConvertInterface interface. During component serialization, the necessary component data is manually retrieved and assembled into JSON object properties and values ​​before serialization. During deserialization, the data is then assigned back to the component object to achieve data conversion.

[0108] The custom component includes a scene control management component. The scene control management component is serialized. After each scene is designed, it is switched using keyboard keys. A unified switching management interface is needed to associate keyboard key values ​​with scenes. During serialization, it is only necessary to associate the keyboard key KeyCode with the scene name SceneName.

[0109] Step 3: Persistently store the database.

[0110] After scene serialization, the files are stored in a persistent storage database. This database includes tables for template types, screen group directories, screen templates, and screen files. These tables enable the persistence and management of scene serialization files. The cascading relationship between the tables is as follows: Figure 5 As shown.

[0111] Specific steps are as follows Figure 3 As shown:

[0112] (1) Construct template type data table, screen group directory data table, screen template data table and screen file data table respectively;

[0113] (2) Based on the serialization file, the template type, screen group directory, and screen template are configured;

[0114] (3) Generate template type objects based on the template type configured in the front end, and persist them to the template type data table using Hibernate;

[0115] (4) Generate a screen group directory object based on the screen group directory configured in the front end, and persist it to the screen group directory data table based on Hibernate;

[0116] (5) Generate a screen template object based on the screen template configured in the front end, and persist it to the screen template data table based on Hibernate;

[0117] (6) Generate a screen file entity object from the JSON file in the serialization file as a byte array, and persist it to the screen file data table based on Hibernate;

[0118] (7) Complete the persistence and management of template types, groups, templates and screen files.

[0119] The template type data table VISU_REVE_TEMPLATETYPE is used to define the length, width, number of rows, and number of columns of a single screen of the rendering and display container.

[0120] The scene grouping directory data table VISU_REVE_TEMPLATECATEGORY is used to define the scene grouping directory information; this data table implements a recursive mode for directory structure data through parentid.

[0121] The VISU_REVE_TEMPLATE table is used to store attribute information for the design page, including the screen name, template type, group directory information, deletion status, sub-screen ID, etc.

[0122] The VISU_REVE_TEMPLATE_FILE table stores the serialized files of the scene content. The file data stream is stored in a table field of type BLOG.

[0123] The detailed descriptions of each table's fields are shown in the table below.

[0124]

[0125]

[0126]

[0127]

[0128] Step 4: Deserialization, rendering, display, and publishing.

[0129] Scene deserialization and instantiation, such as Figure 4As shown, when the project starts, the scene control management file is loaded first, and keyboard key events are created. Then, the corresponding scene serialization file is loaded according to the configured scene name. The data content of multiple scene screens is merged and duplicate content is removed. Then, it is serialized into a scene file, and the components in the scene are instantiated one by one. Finally, the scene is instantiated. The scene control component executes the display and hide operation of the sub-scene in the keyboard event to realize the scene switching.

[0130] The specific steps are as follows:

[0131] (1) Load the scene control management component in step one, traverse the list of keyboard key codes and sub-screen scene association data, and generate a dictionary list.

[0132] (2) Create keyboard key events and listen for user key input.

[0133] (3) Based on the persistent storage database in step three, load the serialization files of each sub-scene and merge the serialization files into a single scene serialization file.

[0134] (4) Deserialize the merged scene files, traverse each component in the scene, and instantiate them one by one to complete the instantiation of the scene.

[0135] (5) After the keyboard key event is triggered, the sub-screen scene corresponding to the key is searched through the dictionary list, the sub-screen scene is displayed, and the previously switched sub-screen scene is hidden, thus realizing the screen scene switching function.

[0136] In summary, this invention addresses the cumbersome Unity release process by separating scene content into a page layout description file and an object library. The page layout description file describes the scene's layout, controls, animations, events, and other configuration information, while the object library contains entity class objects of controls, animations, events, etc. During serialization, it is only necessary to parse the native scene into a JSON file describing the layout and persist the file to a database service.

[0137] When publishing a scene, Unity scene elements are divided into regular attribute components, custom components, built-in components, and resource components. Different serialization methods are provided for different types of components, realizing the serialization processing of Unity scenes. The serialized files are then persisted. When displaying the scene, the page layout description files of each scene are parsed to deserialize the objects, and the components in the scene are instantiated one by one. Finally, the scene is instantiated, rendered, and displayed, solving the problems of cumbersome and inefficient compilation, packaging, and deployment processes of conventional Unity scenes.

[0138] The above description is only a preferred embodiment of the present invention. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.

Claims

1. A serialization-based persistent publishing method for Unity scenes, characterized in that, Includes the following steps: Get the Unity scene; Based on the Unity scene, define the page layout description document structure to obtain serializable components; Based on the serialization component, serialization processing is performed to obtain a serialized file; Based on the serialized file, persistent processing is performed to obtain a persistent storage database; Based on the persistent storage database, the serialization component is deserialized and instantiated to achieve deserialization rendering, display, and publishing of the Unity scene; The serialization process includes: Use JsonObject to mark the serializable component, that is, create a JSON object JObject for the serializable component, where the full path of the component is used as the property name and the serialized JSON string is used as the property value; For the marked regular property components, use the JsonProperty attribute to mark the fields that need to be serialized, and then use JsonConverter to serialize them to obtain the corresponding serialized file; For tagged custom components, built-in components, or resource type components, use the corresponding custom serialization converter to obtain the corresponding serialized file.

2. The serialization and persistent publishing method for Unity scenes according to claim 1, characterized in that, The serialization component includes a regular attribute component, a custom component, a built-in component, and a resource type component; The common attribute components include string, int, float, char, and bool; The custom components include the dataset SQL dataset VSDataSQL, the Excel dataset VSDataSheet, and the data source VSHttp component; The built-in components include Camera, Canvas, CanvasGroup, CanvasScaler, GraphicRaycaster, Color, ColorsGroup, RectTransform, Transform, UnityEvent, 2D data Vector2, 3D data Vector3, Image, Mask, and Text; The resource type components include GameObject, Material, Effect, Font, Sprite, and 3D model.

3. The serialization and persistent publishing method for Unity scenes according to claim 1, characterized in that, For tagged custom components, a serialization converter based on a custom type: Get an instance of the custom type serialization converter, JObject; Execute the corresponding serialization method of the component and assign the result to the customJson property of JObject; The remaining properties marked as JsonProperty are serialized using JsonConvert, and the result is assigned to the selfJson property of JObject. Finally, the JObject is serialized, and the custom component class name and the serialized string are combined to form a key-value pair JSON object, resulting in the corresponding serialized file.

4. The serialization and persistent publishing method for Unity scenes according to claim 1, characterized in that, For the tagged built-in components, a serialization converter based on the built-in components, Get the JObject instance of the serializer converter for the built-in component; Execute the corresponding serialization method of the component, and use the built-in component class name and the serialized string to form a key-value pair JSON object to obtain the corresponding serialized file.

5. The serialization and persistent publishing method for Unity scenes according to claim 1, characterized in that, For the marked resource type components, the serialization converter based on the resource type components obtains the resource path as the serialization attribute value, and uses the resource type component class name and the serialized string to form a key-value pair JSON object to obtain the corresponding serialized file.

6. The serialization and persistent publishing method for Unity scenes according to claim 1, characterized in that, The persistent storage database includes a template type data table, a screen group directory data table, a screen template data table, and a screen file data table; The template type data table is used to store the length, width, number of rows, number of columns, and other attributes of a single screen that defines the rendering and display container; The screen grouping directory data table is used to store grouping directory information that defines the scene; The screen template data table is used to store the attribute information of the design page, including screen name, template type, group directory information, deletion status, sub-screen ID, etc. The image file data table is used to store the scene content serialization file, and the file data stream is stored in the table field of type BLOG.

7. The serialization and persistent publishing method for Unity scenes according to claim 6, characterized in that, The persistence process includes: Construct separate data tables for template types, screen grouping directories, screen templates, and screen files. Based on the serialized file, the template type, screen group directory, and screen template are configured. Generate a template type object based on the template type, and persist it to the template type data table using Hibernate; Generate a screen group directory object based on the screen group directory, and persist it to the screen group directory data table using Hibernate. A screen template object is generated based on the screen template, and persisted to the screen template data table using Hibernate. The JSON file in the serialized file is used to generate a screen file entity object in the form of a byte array, and then persisted to the screen file data table using Hibernate.

8. The serialization and persistent publishing method for Unity scenes according to claim 1, characterized in that, The deserialization rendering and display of the Unity scene includes: Based on the persistent storage database, a serialized file of the scene is obtained; The serialized file of the scene is deserialized, and each component in the scene is traversed and deserialized one by one to realize the instantiation of the scene. Among them, the preset scene control management component can realize the switching of screen scenes.

Citation Information

Patent Citations

  • Runtime editing method and system based on 3D engine

    CN113191124A