Resource object difference processing method and apparatus, electronic device, and storage medium

CN123011250APending Publication Date: 2026-10-30SHENZHEN YUANUNIVERSE TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611519015.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-09-29
Publication Date
2026-10-30

AI Technical Summary

Technical Problem

上述方法能够在一定程度上帮助开发人员定位变更,但其关注点通常停留在实例覆盖、文本行、文件或资源依赖层面,难以直接映射到两个Prefab资产之间的GameObject节点、组件和序列化属性差异

Benefits of technology

1、对两个资源对象进行结构化解析,生成包含层级路径、组件列表、属性键值对及资源GUID的结构快照,而非保留原始的YAML文本行。在此基础上,从根节点递归构建差异树,按路径精确匹配左右两侧的节点。差异树中的每个差异节点都明确记录第一侧节点、第二侧节点以及差异类型(仅左、仅右、都有且有差异、都有且一致)。由此,两个资源对象之间的比较不再是文本字符的加减,而是树形节点的逻辑映射,能够直接回答“哪个节点对应哪个节点”、“哪个组件对应哪个组件”、“对象引用是否指向同一资源”等语义级问题;

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123011250A_ABST
    Figure CN123011250A_ABST
Patent Text Reader

Abstract

The application relates to the technical field of game development, in particular to a resource object difference processing method and device, electronic equipment and a storage medium, wherein a first and a second resource object are acquired and are respectively structured and parsed to generate corresponding structure snapshots, a difference tree is recursively constructed from a root node based on the two structure snapshots, a difference node records a first side node, a second side node and a difference type, the difference type comprises only the first side, only the second side, a difference between the two sides and consistency between the two sides, in response to a selection operation of a user on a target difference item in the difference tree, corresponding content of the target difference item is copied from the first side to the second side or vice versa, the content after synchronization is written back to the target resource object, and structured parsing and difference tree construction are re-executed to update the difference tree. The application can accurately identify the structure and attribute differences of the resource object, supports bidirectional selective synchronization and closed loop verification, and improves the difference processing accuracy and operability.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of game development technology, and in particular to a method, apparatus, electronic device and storage medium for processing resource object differences. Background Technology

[0002] In Unity game development, Prefabs are crucial resources that hold GameObject hierarchies, component configurations, resource references, and serialization parameters. Characters, interfaces, level objects, effects, and interactive objects are typically stored and reused as Prefabs. As projects iterate, the same Prefab may be modified in different branches, versions, and art or design configuration processes. Developers need to verify whether there are any additions or deletions of hierarchical nodes, components, changes to GameObject basic properties, or changes to component serialization fields between two Prefabs.

[0003] In existing development workflows, common practices include using Unity's native Prefab Override panel to view the overridden items of a single Prefab instance relative to the source Prefab; comparing version differences using text-based YAML files; performing file-level diffs or merges using version control tools such as Git and SVN; or relying on information such as resource GUIDs, version commit records, and CI change lists to determine whether resources have changed. While these methods can help developers locate changes to some extent, their focus is usually limited to instance overriding, text lines, and file or resource dependencies, making it difficult to directly map to differences in GameObject nodes, components, and serialization properties between two Prefab assets.

[0004] For resources like Prefabs, which have a tree-like hierarchy and component-based structure, text-based comparison tools alone often fail to accurately express semantic information such as "which node corresponds to which node at the same level," "which component corresponds to which component on the same object," and "whether object reference fields point to the same resource." Especially when situations arise such as nodes with the same name, multiple components of the same type, MissingScript, nested Prefab instances, Prefab Variant, or object references, text-level comparisons or manual comparisons are prone to misjudgments or omissions. Summary of the Invention

[0005] To overcome the shortcomings of the prior art, the present invention provides a method, apparatus, electronic device and storage medium for processing resource object differences, which can accurately identify the structural and attribute differences of resource objects, support bidirectional selective synchronization and closed-loop verification, and improve the accuracy and operability of difference processing.

[0006] A first aspect of this application provides a method for processing differences in resource objects, the method comprising: Obtain a first resource object and a second resource object; perform structured parsing on the first resource object to generate a first structure snapshot corresponding to the first resource object; perform structured parsing on the second resource object to generate a second structure snapshot corresponding to the second resource object. Based on the first structural snapshot and the second structural snapshot, a difference tree is recursively constructed starting from the root node. The difference tree consists of difference nodes, and each difference node records at least a first side node, a second side node, and a difference type. The difference types include those that exist only on the first side, those that exist only on the second side, those that exist on both sides and have differences, and those that exist on both sides and are consistent. If both the first root node of the first structural snapshot and the second root node of the second structural snapshot exist, after performing a matching operation on the child nodes of the first root node and the second root node, each child difference node is recursively constructed. The matching operation performed on the child nodes of the first root node and the second root node includes: Get all child nodes on the first side of the current parent node as the first child node set, and get all child nodes on the second side of the current parent node as the second child node set; Group the child nodes in the second set of child nodes using the name of each child node as the grouping key; Iterate through each first child node in the first child node set in turn, and calculate the structural matching metric between the first child node and each candidate second child node in the unmatched second child node with the same name as the first child node. The candidate second child node with the best structural matching metric is selected as the matching node of the first child node, and the candidate second child node is marked as matched; After traversal, mark the first child node that is not matched as existing only on the first side, and mark each second child node in the second child node set that is not marked as matched as existing only on the second side; In response to a user's selective operation on a target difference item in the difference tree, the content corresponding to the target difference item is copied from the first side to the second side, or copied from the second side to the first side. The synchronized content is written back to the target resource object, and the structured parsing and difference tree construction operations are re-executed to update the difference tree; the target resource object is either the first resource object or the second resource object.

[0007] In an optional implementation, the step of performing structured parsing on the first resource object to generate a first structure snapshot corresponding to the first resource object includes: Starting from the root structural unit of the first resource object, the hierarchical structure is recursively traversed, and each traversed structural unit is converted into a node object; the node object contains at least the hierarchical position information, attribute information and child node set of the corresponding structural unit; For each node object traversed, extract each component attached to that node object and generate a component snapshot for each component; the component snapshot includes at least component type information and serialization attribute information; All the node objects are organized into a tree structure according to the original hierarchical relationship of each node in the first resource object, and the first structure snapshot is obtained.

[0008] In an optional implementation, the recursive construction of the difference tree starting from the root node based on the first structural snapshot and the second structural snapshot includes: Obtain the root node of the first structure snapshot as the first root node, and obtain the root node of the second structure snapshot as the second root node; Determine whether both the first root node and the second root node exist; If only the first root node exists, create a difference node with the difference type "exists only on the first side", and recursively traverse all descendant nodes of the first root node, creating a difference node with the difference type "exists only on the first side" for each descendant node; If only the second root node exists, create a difference node with the difference type "exists only on the second side", and recursively traverse all descendant nodes of the second root node, creating a difference node with the difference type "exists only on the second side" for each descendant node; If both the first root node and the second root node exist, compare the node attribute information of the first root node and the second root node to generate node-level attribute difference information; perform component matching on the component snapshots associated with the first root node and the second root node respectively, and compare the serialized attributes of each successfully matched component to generate component-level difference information. A difference node is generated based on the node-level attribute difference information and the component-level difference information; wherein, if a difference exists, the difference type is that both sides exist but there is a difference, and if no difference exists, the difference type is that both sides exist and are consistent. After performing matching operations on the child nodes of the first root node and the second root node, each child difference node is recursively constructed.

[0009] In an optional implementation, performing the matching operation on the child nodes of the first root node and the second root node includes: Get all child nodes on the first side of the current parent node as the first child node set, and get all child nodes on the second side of the current parent node as the second child node set; Group the child nodes in the second set of child nodes using the name of each child node as the grouping key; Iterate through each first child node in the first child node set in turn, and calculate the structural matching metric between the first child node and each candidate second child node in the unmatched second child node with the same name as the first child node. The candidate second child node with the best structural matching metric is selected as the matching node of the first child node, and the candidate second child node is marked as matched; After traversal, mark the first child node that is not matched as existing only on the first side, and mark each second child node in the second child node set that is not marked as matched as existing only on the second side.

[0010] In an optional implementation, the structure matching metric is determined based on a weighted calculation of at least two of the following factors: sibling index difference, number of associated components difference, difference metric of component type set, and difference metric of direct child node name set; wherein the difference metric of component type set is the number of differences in all component type multisets mounted on the two nodes, and the difference metric of direct child node name set is the number of differences in all direct child node name multisets of the two nodes.

[0011] In an optional implementation, copying the content corresponding to the target difference item from the first side to the second side, or from the second side to the first side, includes: When the target difference item is a node attribute difference, the attribute value of the source node is copied to the corresponding node on the target side; When the target difference item is a component difference, if a corresponding component exists on the target side, all difference attribute values ​​of the corresponding component on the source side are copied to the corresponding component on the target side; if a corresponding component does not exist on the target side, a component of the same type as the source side is created on the target side, and all attribute values ​​of the component on the source side are copied to the newly created component on the target side. When the target difference item is a node difference, the source node, all its child nodes, and associated components are copied to the corresponding parent node on the target side. When the source node is a nested resource object instance, after copying the source node, all its child nodes, and associated components to the target side, the link and overlay relationships between the nested resource object instance and the source resource object asset are maintained.

[0012] In an optional implementation, writing the synchronized content back to the target resource object includes: Before performing the write-back operation, verify that the target resource object is a valid writable resource asset; During the write-back operation, the write-back operation is recorded through an undo logging mechanism; After performing the write-back operation, the target resource object is saved.

[0013] A second aspect of this application provides a resource object difference processing apparatus, the apparatus comprising: The parsing module is used to obtain a first resource object and a second resource object, perform structured parsing on the first resource object to generate a first structure snapshot corresponding to the first resource object, and perform structured parsing on the second resource object to generate a second structure snapshot corresponding to the second resource object. The difference tree generation module is used to recursively construct a difference tree starting from the root node based on the first structure snapshot and the second structure snapshot. The difference tree is composed of difference nodes, and each difference node records at least a first side node, a second side node, and a difference type. The difference type includes only existing on the first side, only existing on the second side, existing on both sides and having differences, and existing on both sides and being consistent. The targeted synchronous write-back module is used to respond to a user's selective operation on a target difference item in the difference tree by copying the content corresponding to the target difference item from the first side to the second side, or from the second side to the first side; writing the synchronized content back to the target resource object, and re-executing the structured parsing and difference tree construction operations to update the difference tree; the target resource object is the first resource object or the second resource object.

[0014] A third aspect of this application provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the resource object difference processing method.

[0015] A fourth aspect of this application provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the steps of the resource object difference processing method described above.

[0016] In summary, the resource object difference processing method, apparatus, electronic device, and storage medium provided in this application have at least one of the following beneficial effects: 1. The system performs structured parsing on two resource objects, generating a snapshot containing hierarchical paths, component lists, attribute key-value pairs, and resource GUIDs, rather than retaining the original YAML text lines. Based on this, a difference tree is recursively constructed from the root node, precisely matching the nodes on the left and right sides according to the path. Each difference node in the difference tree explicitly records the first-side node, the second-side node, and the difference type (left only, right only, both with differences, both with consistency). Therefore, the comparison between two resource objects is no longer a simple addition or subtraction of text characters, but a logical mapping of tree nodes, directly answering semantic-level questions such as "which node corresponds to which node," "which component corresponds to which component," and "do object references point to the same resource?" 2. Because structural snapshots independently record node hierarchy (parent-child relationships, child node list) and serialized attribute fields within nodes, clear categorization is possible when recursively constructing the difference tree. If a path is missing on one side, it indicates a node addition or deletion; if paths exist on both sides but the number of child nodes or component types differ, it indicates a structural difference; if nodes and components match but attribute values ​​differ, it indicates an attribute difference. The four difference types in the difference tree naturally separate structural changes from content changes, avoiding the problem of added and deleted lines being mixed together and difficult to interpret in text diffs. 3. Allows users to select target differences from the difference tree as needed and perform bidirectional structured copying (copying from the first side to the second side, or vice versa). Since the difference node fully preserves the node objects, components, and attribute data of both sides, this copying operation is a semantic-level copy, not text replacement, ensuring the hierarchical and reference integrity of the target resource. After synchronization, structured parsing and difference tree construction are re-executed, allowing users to instantly verify the operation's effect and confirm whether differences have been eliminated or new problems have been introduced. This closed-loop mechanism overcomes the shortcomings of Unity's native panels and version control tools, which either "only display without operation" or "have no feedback after operation," enabling developers to efficiently and accurately complete difference review and bidirectional synchronization between two resource objects. Attached Figure Description

[0017] Figure 1 This is a flowchart illustrating a method for handling resource object differences according to an embodiment of this application; Figure 2 This is another flowchart illustrating a method for handling resource object differences, as shown in an embodiment of this application; Figure 3 This is a schematic diagram illustrating a process for matching nodes at the same level, as shown in an embodiment of this application. Figure 4 This is a schematic diagram illustrating a directed synchronous write-back process according to an embodiment of this application; Figure 5 This is a schematic diagram illustrating a process for copying a nested Prefab instance, as shown in an embodiment of this application. Figure 6 This is a functional block diagram of a resource object difference processing device shown in an embodiment of this application; Figure 7 This is a schematic diagram of the structure of an electronic device shown in an embodiment of this application. Detailed Implementation

[0018] The present invention will be further described below with reference to the accompanying drawings and embodiments.

[0019] The following will clearly and completely describe the concept, specific structure, and technical effects of the present invention in conjunction with embodiments and accompanying drawings, so as to fully understand the purpose, features, and effects of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, not all of them. Other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative effort are all within the scope of protection of the present invention. Furthermore, all connections / linkages involved in the patent do not simply refer to direct contact between components, but rather to the ability to form a better connection structure by adding or reducing connecting accessories according to specific implementation conditions. The various technical features in this invention can be combined interactively without contradicting each other.

[0020] Reference Figure 1 and Figure 2 The diagram shown is a flowchart illustrating a resource object difference processing method according to an embodiment of this application. The resource object difference processing method includes the following steps.

[0021] S11, obtain the first resource object and the second resource object.

[0022] To facilitate understanding of the inventive concept of this application, the following embodiments all use prefabs in the Unity game engine as resource objects to describe in detail the resource object difference processing method.

[0023] When the user specifies a first prefab (referred to as the first Prefab object) and a second prefab (referred to as the second Prefab object) in the prefab input area of ​​the Unity editor window, in response to the user's comparison command, the first and second Prefab objects selected by the user are obtained as inputs to be compared. If either the first or second Prefab object is empty, processing stops and an empty input error message is returned, and subsequent structured parsing and difference tree construction operations are not performed; if neither the first nor the second prefab is empty, the first prefab is used as the first-side input and the second prefab is used as the second-side input, proceeding to the next step S12 or S13.

[0024] S12, perform structured parsing on the first resource object to generate a first structure snapshot corresponding to the first resource object.

[0025] Once it is determined that both the first Prefab object and the second Prefab object are not empty, tree snapshot parsing is performed on the first Prefab object and the second Prefab object respectively.

[0026] During parsing, the Transform hierarchy is recursively traversed starting from the root GameObject. Each GameObject is converted into a PrefabNode, and information such as node name, full path, sibling index, hierarchy depth, activeSelf, tag, layer, parent-child relationship, original GameObject reference, and component list is recorded.

[0027] In an optional implementation, the step of performing structured parsing on the first resource object to generate a first structure snapshot corresponding to the first resource object includes: Starting from the root structural unit of the first resource object, the hierarchical structure is recursively traversed, and each traversed structural unit is converted into a node object; the node object contains at least the hierarchical position information, attribute information and child node set of the corresponding structural unit; For each node object traversed, extract each component attached to that node object and generate a component snapshot for each component; the component snapshot includes at least component type information and serialization attribute information; All the node objects are organized into a tree structure according to the original hierarchical relationship of each node in the first resource object, and the first structure snapshot is obtained.

[0028] In some embodiments, starting from the root GameObject of the first Prefab object, its Transform hierarchy is recursively traversed, and each GameObject encountered is converted into a PrefabNode object. Each PrefabNode object records at least the node name, full path, sibling index, depth, active self, tag, layer, parent-child relationship, original GameObject reference, and component list of the corresponding GameObject. The full path can be recorded in the form of "root node name / child node name [sibling index]" to balance readability and the location of duplicate named nodes.

[0029] For each PrefabNode object encountered during traversal, extract all components attached to the corresponding GameObject and generate a ComponentSnapshot for each component. A component snapshot must include at least the component's fully qualified name, display name, component index (of the same type), original component reference, a flag indicating whether it contains missing scripts, and the component's serializable property set. When a component has a null reference, it is recorded as a MissingScript component to avoid interrupting the parsing process. For multiple components of the same type on the same GameObject, they are processed according to UnityGetComponents. <component>() Returns the order setting of components of the same type.

[0030] The serialized attribute information is extracted in the following way: obtaining the serialized attribute iterator of the component based on the serialized object interface; obtaining each serialized attribute and its corresponding attribute path and attribute value from the serialized attribute iterator; filtering out serialized attributes whose attribute paths belong to a predetermined set of filter fields; the predetermined set of filter fields includes internal reference fields used to maintain the internal hierarchical structure and instance relationships of resource objects; and organizing the remaining serialized attributes after filtering into the serialized attribute information according to the attribute path.

[0031] Specifically, for the collection of serialized properties in the component snapshot, extraction is performed based on Unity's SerializedObject and SerializedProperty interfaces. The SerializedProperty of each component is iterated over by first calling GetIterator() to obtain the serialized property iterator, then using Next(enterChildren) to enter the first-level child properties, and subsequently continuously traversing the visible serialized properties. For Array / List types, the array size and element properties are entered into the property collection through the propertyPath generated by Unity. During parsing, Unity's internal structure reference fields, including m_PrefabAsset, m_GameObject, m_Father, m_Children, m_PrefabInstance, and m_RootOrder, are filtered to avoid interference from parent-child structures, internal Prefab connections, and root order fields in determining business differences.

[0032] After extracting the properties, a display value and a comparison value are generated for each property. The display value is used for UI presentation, and the comparison value is used for consistency checks. For properties such as integers, booleans, strings, colors, enumerations, vectors, rectangles, boundaries, LayerMasks, curves, and characters, they are converted to strings according to their SerializedPropertyType and used as display and comparison values. For object reference properties, the comparison value is (None) when the reference is null; when the reference is not null, the GlobalObjectId is used first to obtain the global object identifier as the comparison value; if the GlobalObjectId fails to be obtained, it falls back to the object reference instance ID string as the comparison value; if the reference is lost or cannot be resolved across projects, the reference state, instance ID, or (None) that Unity can obtain is used as the comparison value, and the display value is retained as the object name and type or a null reference marker.

[0033] All PrefabNode objects are organized into a tree structure according to the original hierarchical relationship of each GameObject in the first prefab, resulting in the first structural snapshot (i.e., the first PrefabNode tree) of the first prefab. The root node of this first structural snapshot corresponds to the root GameObject of the first prefab. The Children field of each PrefabNode stores the set of PrefabNodes corresponding to its direct child GameObjects, the Components field stores the set of component snapshots on that GameObject, and the Properties field in the component snapshot stores the set of serialized property snapshots of that component.

[0034] S13, perform structured parsing on the second resource object to generate a second structure snapshot corresponding to the second resource object.

[0035] Following the same implementation method as step S12 above, the second Prefab object is structurally parsed. Starting from the root GameObject of the second Prefab object, the Transform hierarchy is recursively traversed, converting each GameObject into a PrefabNode object. Information such as the node's name, full path, sibling index, hierarchy depth, activation state, tag, hierarchy, parent-child relationship, original GameObject reference, and component list is recorded. Component snapshots are extracted from the components attached to each node. The component snapshot includes the fully qualified name of the component type, the component's display name, the serial number of components of the same type, the original component reference, whether it is marked as Missing Script, and the component's serialization attribute set. The serial number of components of the same type is determined according to the actual arrangement order of the components on the GameObject. Missing script components are recorded when the component has an empty reference.

[0036] Based on Unity's SerializedObject and SerializedProperty interfaces, the serialized property collection of each component is extracted. The iteration method is to first call GetIterator(), then enter the first-level sub-properties with Next(enterChildren), and continuously traverse the visible serialized properties. For Array / List types, the array size and element properties are entered into the property collection through propertyPath. During parsing, internal structure reference fields such as m_PrefabAsset, m_GameObject, m_Father, m_Children, m_PrefabInstance, and m_RootOrder are filtered. A display value and comparison value are generated for each property. Among them, the object reference property first calls GlobalObjectId to get the global object identifier as the comparison value. If the retrieval fails, it falls back to the instance ID string. All node objects are organized into a tree structure according to the original hierarchical relationship to obtain a second structure snapshot (i.e., the second PrefabNode tree) that is independent of the first structure snapshot, as the other side of the input for subsequent difference comparison.

[0037] Therefore, the first and second Prefab objects are converted from Unity runtime objects into traversable, matchable, and comparable static snapshot data for subsequent use in difference tree construction, UI display, and synchronous positioning.

[0038] S14, Based on the first structural snapshot and the second structural snapshot, recursively construct the difference tree starting from the root node.

[0039] Furthermore, a difference tree (DiffNode) is recursively constructed starting from the two root PrefabNodes. This difference tree consists of difference nodes, each recording at least a first-side node, a second-side node, and a difference type. The difference types include those existing only on the first side, existing only on the second side, existing on both sides with differences, and existing on both sides with consistency.

[0040] In an optional implementation, the recursive construction of the difference tree starting from the root node based on the first structural snapshot and the second structural snapshot includes: Obtain the root node of the first structure snapshot as the first root node, and obtain the root node of the second structure snapshot as the second root node; Determine whether both the first root node and the second root node exist; If only the first root node exists, create a difference node with the difference type "exists only on the first side", and recursively traverse all descendant nodes of the first root node, creating a difference node with the difference type "exists only on the first side" for each descendant node; If only the second root node exists, create a difference node with the difference type "exists only on the second side", and recursively traverse all descendant nodes of the second root node, creating a difference node with the difference type "exists only on the second side" for each descendant node; If both the first root node and the second root node exist, compare the node attribute information of the first root node and the second root node to generate node-level attribute difference information; perform component matching on the component snapshots associated with the first root node and the second root node respectively, and compare the serialized attributes of each successfully matched component to generate component-level difference information. A difference node is generated based on the node-level attribute difference information and the component-level difference information; wherein, if a difference exists, the difference type is that both sides exist but there is a difference, and if no difference exists, the difference type is that both sides exist and are consistent. After performing matching operations on the child nodes of the first root node and the second root node, each child difference node is recursively constructed.

[0041] Refer to together Figure 3 In some embodiments, the construction of the difference tree begins with the root node of the first structural snapshot and the root node of the second structural snapshot. First, the root node of the first structural snapshot is obtained as the first root node, and the root node of the second structural snapshot is obtained as the second root node. The first root node and the second root node are used as nodes to be compared, and it is determined whether both the first root node and the second root node exist.

[0042] Scenario 1: Only the first side (also known as side A) has a root node.

[0043] If the first root node exists but the second root node does not, a difference node with the difference type "OnlyInA" is created. The first-side node of this difference node points to the first root node, and the second-side node is set to null. Then, all descendant nodes of the first root node are recursively traversed, and a difference node with the difference type "OnlyInA" is created for each descendant node. These nodes are then organized into a difference subtree according to the original hierarchical relationship.

[0044] That is, when the node to be compared only exists on side A, the DiffType of the current DiffNode is set to OnlyInA, NodeA is set to point to the PrefabNode on side A, NodeB is set to null, and the component snapshot on the PrefabNode on side A is converted to ComponentDiff of type OnlyInA; at the same time, all child nodes of the PrefabNode on side A are traversed, and a child DiffNode with null NodeB is recursively created for each child node and added to the Children list of the current DiffNode.

[0045] Scenario 2: Only the second side (also known as the B side) has a root node.

[0046] If the second root node exists but the first root node does not, a difference node with the difference type "OnlyInB" is created. The second-side node of this difference node points to the second root node, and the first-side node is set to null. Then, all descendant nodes of the second root node are recursively traversed, and a difference node with the difference type "OnlyInB" is created for each descendant node. These nodes are then organized into a difference subtree according to the original hierarchical relationship.

[0047] That is, when the node to be compared only exists on side B, set the DiffType of the current DiffNode to OnlyInB, point NodeB to the PrefabNode on side B, set NodeA to null, and generate component differences and child DiffNodes of type OnlyInB in the same way.

[0048] Scenario 3: Both root nodes exist.

[0049] If both the first and second root nodes exist, then perform the following operations: First, the node attribute information of the first and second root nodes is compared to generate node-level attribute difference information. Each attribute difference is recorded as a property difference object (PropertyDiff) and written into the node attribute difference set (GameObjectPropertyDiffs) of the current differing node. The node attribute information consists of GameObject basic attributes such as sibling index, active self, tag, layer, and name recorded in step S12. For each attribute, if the values ​​on both sides are the same, it is marked as consistent; otherwise, the attribute values ​​on both sides are recorded and marked as differing.

[0050] Then, component matching is performed on the component snapshots associated with the first and second root nodes. Component matching uses the fully qualified name of the component type as the grouping key and establishes a correspondence according to the order in which components of the same type appear—that is, the first component of a certain type on side A corresponds to the first component of a certain type on side B, the second on side A corresponds to the second on side B, and so on. Components that exist on side A but are missing on side B are marked as existing only on the first side (OnlyInA), a component difference object (ComponentDiff) is generated and written to the component difference set (ComponentDiffs) of the current difference node; components that exist on side B but are missing on side A are marked as existing only on the second side (OnlyInB), a component difference object is generated and written to the component difference set of the current difference node. Missing Script components can participate in the difference display, but are prohibited from being added or overwritten as source components during synchronous write-back.

[0051] For each successfully matched component, property comparison is performed. Property dictionaries are constructed for side A and side B, using the property path as the key. If properties with the same path exist on both sides, the SerializedPropertyType is compared first; if the types differ, it is marked as Modified. If the types are the same, the property values ​​are compared. Floating-point numbers are compared using absolute tolerance; they are considered consistent only if abs(FloatA - FloatB) < 1e-6. If any floating-point string cannot be parsed using InvariantCulture, comparison of the comparison value string is used as a fallback. Other types are compared using Ordinal strings with comparison value priority and explicit value as a fallback. If a property exists only on one side, it is marked as OnlyInA or OnlyInB. The property comparison results are recorded as property difference objects and written to the internal property difference collection of the corresponding component's difference object.

[0052] Subsequently, the difference type of the current differing node is determined based on the node-level attribute difference information and the component-level difference information: if there are inconsistent difference items in the node attribute difference set or component difference set of the current differing node, the difference type of the current differing node is set to "Modified" (exists on both sides but differs); if all attributes are consistent and all components are consistent, the difference type is set to "Identical" (exists on both sides and is consistent). Empty node lists are treated as empty sets, and empty component lists are treated as empty sets.

[0053] Finally, perform a matching operation on the direct child nodes of the current root node.

[0054] In an optional implementation, performing the matching operation on the child nodes of the first root node and the second root node includes: Get all child nodes on the first side of the current parent node as the first child node set, and get all child nodes on the second side of the current parent node as the second child node set; Group the child nodes in the second set of child nodes using the name of each child node as the grouping key; Iterate through each first child node in the first child node set in turn, and calculate the structural matching metric between the first child node and each candidate second child node in the unmatched second child node with the same name as the first child node. The candidate second child node with the best structural matching metric is selected as the matching node of the first child node, and the candidate second child node is marked as matched. After traversal, mark the first child node that is not matched as existing only on the first side, and mark each second child node in the second child node set that is not marked as matched as existing only on the second side.

[0055] In some embodiments, when matching child nodes (i.e., the first set of child nodes) under the same parent node, the second-side candidate nodes (i.e., the second set of child nodes) are first grouped by node name, and then the first-side nodes are traversed. Among the unconsumed candidates with the same name, the structure matching score is calculated and the one with the lowest score is selected. The structure matching metric is represented by the structure matching score and is determined based on a weighted calculation of at least two of the following factors: the difference in sibling indexes, the difference in the number of associated components, the difference metric for the set of component types, and the difference metric for the set of direct child node names. The difference metric for the set of component types is the number of differences in all multisets of component types attached to the two nodes, and the difference metric for the set of direct child node names is the number of differences in all multisets of direct child node names of the two nodes.

[0056] Specifically, the structure matching score is defined as: Score(A,B) = W1 |IndexA-IndexB|+W2 |ComponentCountA-ComponentCountB|+W3 ComponentTypeDistance(A,B)+W4 ChildNameDistance(A,B); Where IndexA and IndexB are the sibling indices of nodes A and B, respectively; ComponentCountA and ComponentCountB are the number of components; ComponentTypeDistance(A,B) is the sum of the differences in the multisets of component types between the two nodes; and ChildNameDistance(A,B) is the sum of the differences in the multisets of the names of the direct child nodes between the two nodes. In a preferred embodiment, W1=1, W2=2, W3=1, and W4=1, meaning that the component quantity difference has a higher weight. The above items are not normalized to retain integer costs and reduce runtime overhead. In other embodiments, the items can be normalized or their weights adjusted according to the node size.

[0057] When multiple candidate nodes have the same structural matching score, the candidate with the smaller index distance at the same level is preferred; if they are still the same, the candidate that appears earlier in the second-side candidate list and has not yet been consumed is selected. Unmatched first-side nodes are marked as OnlyInA, and unconsumed second-side nodes are marked as OnlyInB. Nodes are matched only within the same parent node range, not across parent nodes.

[0058] For each successfully matched child node pair, recursively perform the above-described difference node creation operation; for child nodes that exist only on the first side or only on the second side, create the corresponding difference nodes respectively. The recursive process continues until all descendant nodes have been processed.

[0059] After all recursion is complete, a bottom-up backtracking marking and statistics process is performed on the difference tree. If the difference type of a certain difference node is not Identical, or if the HasDifference of any of its child difference nodes is true, then the HasDifference of that difference node is set to true; and the total number of differences, the number of nodes unique to side A, the number of nodes unique to side B, the number of modified nodes, the number of consistent nodes, the number of component differences, and the number of attribute differences are counted. The recursive structure formed by the root difference node and all its child difference nodes is the complete difference tree, which, together with the first structure snapshot, the second structure snapshot, and the difference statistics, constitutes the final difference comparison result for subsequent visualization and targeted synchronization operations.

[0060] S15, in response to a user's selective operation on a target difference item in the difference tree, copy the content corresponding to the target difference item from the first side to the second side, or copy it from the second side to the first side.

[0061] The target resource object is either the first resource object or the second resource object.

[0062] Refer to together Figure 4 In one embodiment, after the difference tree is constructed, the difference results are displayed in the Unity editor window. The window includes a resource object input area, a comparison button, a filter area, a search box, a tree hierarchy view, and a difference details panel. The tree view displays the difference tree and highlights the difference nodes; the details panel displays the GameObject basic attribute differences, component differences, and attribute differences for the current node.

[0063] In response to the user's filter input, only difference nodes whose difference type matches the filter condition are displayed.

[0064] Users can select the target difference item from the difference tree by clicking, checking, or other interactive methods, and choose the synchronization direction (copy from the first side to the second side, or copy from the second side to the first side) to perform a targeted synchronization operation for the difference item.

[0065] In an optional implementation, copying the content corresponding to the target difference item from the first side to the second side, or from the second side to the first side, includes: When the target difference item is a node attribute difference, the attribute value of the source node is copied to the corresponding node on the target side; When the target difference item is a component difference, if a corresponding component exists on the target side, all difference attribute values ​​of the corresponding component on the source side are copied to the corresponding component on the target side; if a corresponding component does not exist on the target side, a component of the same type as the source side is created on the target side, and all attribute values ​​of the component on the source side are copied to the newly created component on the target side. When the target difference item is a node difference, the source node, all its child nodes, and associated components are copied to the corresponding parent node on the target side. When the source node is a nested resource object instance, after copying the source node, all its child nodes, and associated components to the target side, the link and overlay relationships between the nested resource object instance and the source resource object asset are maintained.

[0066] Refer to together Figure 5 In some embodiments, the system supports the following directed synchronization operations: (1) Differences in basic GameObject attributes (corresponding to differences in node attributes): For differences in basic attributes such as activeSelf, tag, or layer, the attribute values ​​from the source side are copied to the corresponding attributes on the target side.

[0067] (2) Individual component property differences (corresponding to the case where the target side has a corresponding component in the component differences): For individual component property differences, copy the source component SerializedProperty to the target component by PropertyPath.

[0068] (3) Complete component difference (corresponding to the case where the target side does not have the corresponding component in the component difference): For component difference, copy all inconsistent attributes; if the target node is missing the component, add the corresponding component on the target side and copy all serialized values.

[0069] (4) Missing Nodes and Their Subtrees (Corresponding to Node Differences): For nodes that exist only on one side, the complete subtree of the source node is copied to the corresponding parent node of the target resource object. Specifically, the source side missing node is received, and it is determined whether the source side missing node is part of the nested resource object instance; if not, the subtree is cloned as a normal node; if so, it is further determined whether the node is the root node of the nested resource object instance; if the node is not the root node of the nested resource object instance, the subtree is cloned as a normal node; if the node is the root node of the nested resource object instance, the source resource object asset corresponding to the nested resource object instance is obtained, and a new nested resource object instance is instantiated based on the source resource object asset under the corresponding parent node on the target side. The property modification record (PropertyModification) and the override property (Override) of the newly added node and newly added component of the nested resource object instance are copied to maintain the link relationship and override relationship between the target side nested resource object instance and the source resource object asset, and to avoid the nested resource object from degenerating into a normal node.

[0070] Furthermore, the target resource object is saved, and the structured parsing and difference tree construction operations are re-executed to update the difference tree, i.e., step S16 is executed.

[0071] S16, write the synchronized content back to the target resource object, and re-execute the structured parsing and difference tree construction operations to update the difference tree.

[0072] In one embodiment, during synchronous write-back, Prefab asset verification, Undo recording, and saving are performed.

[0073] In an optional implementation, writing the synchronized content back to the target resource object includes: Before performing the write-back operation, verify that the target resource object is a valid writable resource asset; During the write-back operation, the write-back operation is recorded through an undo logging mechanism; After performing the write-back operation, the target resource object is saved.

[0074] In some embodiments, when performing a synchronous write-back, the target resource object is first verified to be a valid writable resource asset, that is, it is confirmed that the target resource object belongs to a Prefab asset in the Unity project, and the scene instance is not directly modified. If the verification fails, the write-back operation is aborted and an error message is returned.

[0075] During the write-back operation, the write-back operation is recorded through an undo recording mechanism. For property synchronization, the undo operation is recorded using Undo.RecordObject so that users can undo and roll back in the Unity editor; for adding components, Undo.AddComponent is used to make the addition of components undone; for copying missing nodes, the target Prefab content is loaded using PrefabUtility.LoadPrefabContents, a copy is created after locating the target parent node, and modifications are made to the loaded content.

[0076] After performing the write-back operation, the target resource object is saved, and the modified content is persisted to the target Prefab asset file.

[0077] After the synchronous write-back is completed, the structured parsing operations of S12 and S13 and the difference tree construction operation of S14 are automatically re-executed to update the difference tree and refresh the UI, so that the fixed difference items disappear from the difference list.

[0078] To facilitate understanding of the inventive concept of this application, a specific application example is provided below.

[0079] There are two Prefabs, one with a Root / Button node on the left and the other with a Root / Button node on the right. However, the Button on the right has an additional child node named Text.

[0080] The existing text diff shows that a new line - Text (depending on the diff tool) has been added, but it cannot tell you whether this Text is a child node of the Button or somewhere else.

[0081] The embodiments of this application are as follows: In the structural snapshot, the list of child nodes for the left Button is [], and the list for the right Button is [Text].

[0082] When recursively tracing down to the Button level, it was found that the Root / Button / Text on the left side does not exist, while it does on the right side → the difference type is "exists only on the second side".

[0083] The path of this difference item in the difference tree is Root / Button / Text, which explicitly states that "the Text child node under Button has been added".

[0084] Users can choose to copy this new node from the right to the left, or ignore it.

[0085] After copying, a new snapshot is generated on the left and compared with the right; the differences disappear.

[0086] Compared to existing technologies, this application transforms a Prefab into an object tree through structured snapshots, preserving all semantics (path, type, GUID, attributes); it recursively matches paths, and the difference tree explicitly records the correspondence between "node A" and "node B"; snapshots support indexes, GUIDs, and type tags, and can distinguish between identical names, multiple components, Missing, nested, and Variant objects; it provides bidirectional selective synchronization, and automatically recalculates the difference tree after synchronization, forming a verifiable closed loop. Specifically, First, by parsing resource objects into tree snapshots and using difference nodes to carry the results, the difference expression is elevated from the file text level to the resource object semantic level. Developers can directly locate nodes, components, and attribute fields without having to repeatedly map between text content and Unity objects.

[0087] Second, by introducing structural similarity scoring among candidates with the same name at the same layer, the probability of mismatch in scenarios of duplicate naming, node rearrangement, and local addition and deletion is reduced, thus solving the technical problem of difficulty in matching nodes with the same name.

[0088] Third, by matching component types and serial numbers of the same type, it can handle the situation where multiple components of the same type are mounted on the same node, making the component difference results more consistent with the actual structure of the resource object.

[0089] Fourth, by using stable comparison keys such as serialized attribute paths and global object identifiers for attribute comparison, the serialized fields of built-in components and custom components of resource objects can be covered, and misjudgments caused by identical object reference names or interference from internal fields can be reduced.

[0090] Fifth, by integrating difference discovery, display, filtering, and synchronized write-back into the editor window, developers can directly repair target resource objects at the attribute, component, or node granularity after discovering differences, reducing manual operation paths and realizing an integrated closed loop of difference comparison and targeted synchronization.

[0091] Sixth, the synchronous write-back is handled by the synchronization service and includes resource asset verification, record revocation, missing script component restrictions, resource content loading and saving process and refresh mechanism, which helps to reduce the risk of incorrect writing to scene instances or damage to resource assets; after synchronization is completed, it automatically triggers a re-comparison and refresh of the difference display, so that the repaired difference items disappear from the difference list, ensuring that the difference display results are synchronized with the actual resource status.

[0092] Reference Figure 6 The diagram shown is a functional block diagram of a resource object difference processing device according to an embodiment of this application.

[0093] In some embodiments, the resource object difference processing apparatus 60 may include a plurality of functional modules composed of computer program segments. The computer programs for each program segment of the resource object difference processing apparatus 60 may be stored in the memory of an electronic device and executed by at least one processor to perform (see details). Figure 1 (Description) The function of resource object difference processing. Based on its function, it can be divided into multiple functional modules. These functional modules may include: a parsing module 601, a difference tree generation module 602, and a directed synchronous write-back module 603. The module referred to in this application is a series of computer program segments that can be executed by at least one processor and perform a fixed function, stored in memory. In this embodiment, the functions of each module will be detailed in subsequent embodiments.

[0094] The parsing module 601 is used to obtain a first resource object and a second resource object, perform structured parsing on the first resource object to generate a first structure snapshot corresponding to the first resource object, and perform structured parsing on the second resource object to generate a second structure snapshot corresponding to the second resource object.

[0095] The difference tree generation module 602 is used to recursively construct a difference tree starting from the root node based on the first structure snapshot and the second structure snapshot; the difference tree is composed of difference nodes, and each difference node records at least a first side node, a second side node and a difference type; the difference type includes existing only on the first side, existing only on the second side, existing on both sides and having differences, and existing on both sides and being consistent.

[0096] The targeted synchronization write-back module 603 is used to respond to the user's selective operation on the target difference item in the difference tree, to copy the content corresponding to the target difference item from the first side to the second side, or from the second side to the first side; to write the synchronized content back to the target resource object, and to re-execute the structured parsing and difference tree construction operations to update the difference tree; the target resource object is the first resource object or the second resource object.

[0097] It should be understood that the various variations and specific embodiments of the resource object difference processing method provided in the above embodiments are also applicable to the resource object difference processing device of this embodiment. Through the foregoing detailed description of the resource object difference processing method, those skilled in the art can clearly understand the implementation method of the resource object difference processing device in this embodiment. For the sake of brevity, it will not be described in detail here.

[0098] See Figure 7 The diagram shown is a schematic representation of the structure of an electronic device according to an embodiment of this application. In a preferred embodiment of this application, the electronic device 7 includes a memory 71, at least one processor 72, and at least one communication bus 73.

[0099] Those skilled in the art should understand that Figure 7 The structure of the electronic device shown does not constitute a limitation of the embodiments of this application. It can be a bus structure or a star structure. The electronic device 7 may also include more or fewer other hardware or software than shown, or different component arrangements.

[0100] In some embodiments, the electronic device 7 is a device capable of automatically performing numerical calculations and / or information processing according to pre-set or stored instructions. Its hardware includes, but is not limited to, microprocessors, application-specific integrated circuits (ASICs), programmable gate arrays (FPGAs), digital processors, and embedded devices. The electronic device 7 may also include user equipment, which includes, but is not limited to, any electronic product capable of human-computer interaction with a user via a keyboard, mouse, remote control, touchpad, or voice control device, such as a personal computer, tablet computer, smartphone, or digital camera.

[0101] In the embodiments provided in this application, it should be understood that the disclosed methods, apparatuses, computer-readable storage media, and electronic devices can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative. For instance, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple components or modules may be combined or integrated into another device, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices, components, or modules may be electrical, mechanical, or other forms.

[0102] The components described as separate parts may or may not be physically separate. The components shown as components may or may not be physical modules; that is, they may be located in one place or distributed across multiple network modules. Some or all of the components can be selected to achieve the purpose of this embodiment according to actual needs.

[0103] Furthermore, the functional modules in the various embodiments of the present invention can be integrated into one processing module, or each component can exist physically separately, or two or more modules can be integrated into one module. The integrated modules described above can be implemented in hardware or as software functional modules.

[0104] If the integrated module is implemented as a software functional module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes: USB flash drive, portable hard drive, read-only memory (ROM). Various media that can store program code, such as only memory, random access memory (RAM), magnetic disks or optical disks.

[0105] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that the present invention is not limited to the described order of actions, because according to the present invention, some steps can be performed in other orders or simultaneously. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions and modules involved are not necessarily essential to the present invention.

[0106] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.

[0107] The above is a detailed description of the preferred embodiments of the present invention. However, the present invention is not limited to the embodiments described. Those skilled in the art can make various equivalent modifications or substitutions without departing from the spirit of the present invention. All such equivalent modifications or substitutions are included within the scope defined by the claims of this application.< / component>

Claims

1. A method for handling resource object differences, characterized in that, The method includes: Obtain a first resource object and a second resource object; perform structured parsing on the first resource object to generate a first structure snapshot corresponding to the first resource object; perform structured parsing on the second resource object to generate a second structure snapshot corresponding to the second resource object. Based on the first structural snapshot and the second structural snapshot, a difference tree is recursively constructed starting from the root node. The difference tree consists of difference nodes, and each difference node records at least a first side node, a second side node, and a difference type. The difference types include those that exist only on the first side, those that exist only on the second side, those that exist on both sides and have differences, and those that exist on both sides and are consistent. If both the first root node of the first structural snapshot and the second root node of the second structural snapshot exist, after performing a matching operation on the child nodes of the first root node and the second root node, each child difference node is recursively constructed. The matching operation on the child nodes of the first root node and the second root node includes: obtaining all child nodes on the first side under the current parent node as a first child node set, and obtaining all child nodes on the second side under the current parent node as a second child node set; grouping each child node in the second child node set using the name of each child node as a grouping key; sequentially traversing each first child node in the first child node set, and calculating the structural matching metric between the first child node and each candidate second child node among the unmatched second child node candidates with the same name as the first child node; selecting the candidate second child node with the best structural matching metric as the matching node of the first child node, and marking the candidate second child node as matched; marking the first child nodes that were not matched after traversal as existing only on the first side, and marking each second child node in the second child node set that was not marked as matched as existing only on the second side; In response to a user's selective operation on a target difference item in the difference tree, the content corresponding to the target difference item is copied from the first side to the second side, or copied from the second side to the first side. The synchronized content is written back to the target resource object, and the structured parsing and difference tree construction operations are re-executed to update the difference tree; the target resource object is either the first resource object or the second resource object.

2. The resource object difference processing method according to claim 1, characterized in that, The step of performing structured parsing on the first resource object to generate a first structure snapshot corresponding to the first resource object includes: Starting from the root structural unit of the first resource object, the hierarchical structure is recursively traversed, and each traversed structural unit is converted into a node object; the node object contains at least the hierarchical position information, attribute information and child node set of the corresponding structural unit; For each node object traversed, extract each component attached to that node object and generate a component snapshot for each component; the component snapshot includes at least component type information and serialization attribute information; All the node objects are organized into a tree structure according to the original hierarchical relationship of each node in the first resource object, and the first structure snapshot is obtained.

3. The resource object difference processing method according to claim 1, characterized in that, The recursive construction of the difference tree starting from the root node based on the first structural snapshot and the second structural snapshot includes: Obtain the root node of the first structure snapshot as the first root node, and obtain the root node of the second structure snapshot as the second root node; Determine whether both the first root node and the second root node exist; If only the first root node exists, create a difference node with the difference type "exists only on the first side", and recursively traverse all descendant nodes of the first root node, creating a difference node with the difference type "exists only on the first side" for each descendant node; If only the second root node exists, create a difference node with the difference type "exists only on the second side", and recursively traverse all descendant nodes of the second root node, creating a difference node with the difference type "exists only on the second side" for each descendant node; If both the first root node and the second root node exist, compare the node attribute information of the first root node and the second root node to generate node-level attribute difference information; perform component matching on the component snapshots associated with the first root node and the second root node respectively, and compare the serialized attributes of each successfully matched component to generate component-level difference information. A difference node is generated based on the node-level attribute difference information and the component-level difference information; wherein, if a difference exists, the difference type is that both sides exist but there is a difference, and if no difference exists, the difference type is that both sides exist and are consistent. After performing matching operations on the child nodes of the first root node and the second root node, each child difference node is recursively constructed.

4. The resource object difference processing method according to claim 1, characterized in that, The structure matching metric is determined based on a weighted calculation of at least two of the following factors: sibling index difference, number of associated components difference, component type set difference metric, and direct child node name set difference metric; wherein the component type set difference metric is the number of differences in all component type multisets mounted on the two nodes, and the direct child node name set difference metric is the number of differences in all direct child node name multisets of the two nodes.

5. The resource object difference processing method according to claim 1, characterized in that, The step of copying the content corresponding to the target difference item from the first side to the second side, or from the second side to the first side, includes: When the target difference item is a node attribute difference, the attribute value of the source node is copied to the corresponding node on the target side; When the target difference item is a component difference, if a corresponding component exists on the target side, all difference attribute values ​​of the corresponding component on the source side are copied to the corresponding component on the target side; if a corresponding component does not exist on the target side, a component of the same type as the source side is created on the target side, and all attribute values ​​of the component on the source side are copied to the newly created component on the target side. When the target difference item is a node difference, the source node, all its child nodes, and associated components are copied to the corresponding parent node on the target side. When the source node is a nested resource object instance, after copying the source node, all its child nodes, and associated components to the target side, the link and overlay relationships between the nested resource object instance and the source resource object asset are maintained.

6. The resource object difference processing method according to claim 1, characterized in that, The step of writing the synchronized content back to the target resource object includes: Before performing the write-back operation, verify that the target resource object is a valid writable resource asset; During the write-back operation, the write-back operation is recorded through an undo logging mechanism; After performing the write-back operation, the target resource object is saved.

7. A resource object difference processing device, characterized in that, The device includes: The parsing module is used to obtain a first resource object and a second resource object, perform structured parsing on the first resource object to generate a first structure snapshot corresponding to the first resource object, and perform structured parsing on the second resource object to generate a second structure snapshot corresponding to the second resource object. A difference tree generation module is used to recursively construct a difference tree starting from the root node based on the first structural snapshot and the second structural snapshot. The difference tree is composed of difference nodes, and each difference node records at least a first side node, a second side node, and a difference type. The difference type includes existing only on the first side, existing only on the second side, existing on both sides with differences, and existing on both sides with consistency. If both the first root node of the first structural snapshot and the second root node of the second structural snapshot exist, a matching operation is performed on the child nodes of the first root node and the second root node, and then each child difference node is recursively constructed. The matching operation on the child nodes of the first root node and the second root node includes: obtaining all child nodes on the first side under the current parent node as the first... The child node set is obtained by taking all child nodes on the second side of the current parent node as the second child node set; the child nodes in the second child node set are grouped by their names as the grouping key; the first child nodes in the first child node set are traversed sequentially, and among the unmatched second child node candidates with the same name as the first child node, the structural matching metric between the first child node and each candidate second child node is calculated; the candidate second child node with the best structural matching metric is selected as the matching node of the first child node, and the candidate second child node is marked as matched; the first child nodes that are not matched after traversal are marked as existing only on the first side, and the second child nodes in the second child node set that are not marked as matched are marked as existing only on the second side; The targeted synchronous write-back module is used to respond to a user's selective operation on a target difference item in the difference tree by copying the content corresponding to the target difference item from the first side to the second side, or from the second side to the first side; writing the synchronized content back to the target resource object, and re-executing the structured parsing and difference tree construction operations to update the difference tree; the target resource object is the first resource object or the second resource object.

8. An electronic device, characterized in that, The method includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the resource object difference processing method according to any one of claims 1 to 6.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the steps of the resource object difference processing method according to any one of claims 1 to 6.